Skip to content

Commit 7771d0c

Browse files
authored
Merge pull request #19934 from Microsoft/add-starter-kit-to-user-tests
Add starter kit to user tests
2 parents b8fbf88 + 4d01390 commit 7771d0c

File tree

15 files changed

+61
-6
lines changed

15 files changed

+61
-6
lines changed

.gitmodules

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[submodule "tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter"]
2+
path = tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter
3+
url = https://github.com/Microsoft/TypeScript-React-Starter
4+
[submodule "tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter"]
5+
path = tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter
6+
url = https://github.com/Microsoft/TypeScript-Node-Starter.git
7+
[submodule "tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter"]
8+
path = tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter
9+
url = https://github.com/Microsoft/TypeScript-React-Native-Starter.git
10+
[submodule "tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter"]
11+
path = tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter
12+
url = https://github.com/Microsoft/TypeScript-Vue-Starter.git
13+
[submodule "tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter"]
14+
path = tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter
15+
url = https://github.com/Microsoft/TypeScript-WeChat-Starter.git

src/harness/externalCompileRunner.ts

+23-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ interface ExecResult {
99
status: number;
1010
}
1111

12+
interface UserConfig {
13+
types: string[];
14+
}
15+
1216
abstract class ExternalCompileRunnerBase extends RunnerBase {
1317
abstract testDir: string;
1418
abstract report(result: ExecResult, cwd: string): string;
@@ -33,18 +37,34 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
3337
const cp = require("child_process");
3438

3539
it("should build successfully", () => {
36-
const cwd = path.join(__dirname, "../../", this.testDir, directoryName);
40+
let cwd = path.join(__dirname, "../../", this.testDir, directoryName);
3741
const timeout = 600000; // 600s = 10 minutes
42+
const stdio = isWorker ? "pipe" : "inherit";
43+
let types: string[];
44+
if (fs.existsSync(path.join(cwd, "test.json"))) {
45+
const update = cp.spawnSync("git", ["submodule", "update", "--remote"], { cwd, timeout, shell: true, stdio });
46+
if (update.status !== 0) throw new Error(`git submodule update for ${directoryName} failed!`);
47+
48+
const config = JSON.parse(fs.readFileSync(path.join(cwd, "test.json"), { encoding: "utf8" })) as UserConfig;
49+
ts.Debug.assert(!!config.types, "Bad format from test.json: Types field must be present.");
50+
types = config.types;
51+
52+
cwd = path.join(cwd, directoryName);
53+
}
3854
if (fs.existsSync(path.join(cwd, "package.json"))) {
3955
if (fs.existsSync(path.join(cwd, "package-lock.json"))) {
4056
fs.unlinkSync(path.join(cwd, "package-lock.json"));
4157
}
42-
const stdio = isWorker ? "pipe" : "inherit";
4358
const install = cp.spawnSync(`npm`, ["i"], { cwd, timeout, shell: true, stdio });
4459
if (install.status !== 0) throw new Error(`NPM Install for ${directoryName} failed!`);
4560
}
61+
const args = [path.join(__dirname, "tsc.js")];
62+
if (types) {
63+
args.push("--types", types.join(","));
64+
}
65+
args.push("--noEmit");
4666
Harness.Baseline.runBaseline(`${this.kind()}/${directoryName}.log`, () => {
47-
return this.report(cp.spawnSync(`node`, [path.join(__dirname, "tsc.js")], { cwd, timeout, shell: true }), cwd);
67+
return this.report(cp.spawnSync(`node`, args, { cwd, timeout, shell: true }), cwd);
4868
});
4969
});
5070
});

tests/baselines/reference/user/electron.log

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Exit Code: 2
1+
Exit Code: 1
22
Standard output:
33
node_modules/electron/electron.d.ts(5390,13): error TS2430: Interface 'WebviewTag' incorrectly extends interface 'HTMLElement'.
44
Types of property 'addEventListener' are incompatible.

tests/baselines/reference/user/leveldown.log

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Exit Code: 2
1+
Exit Code: 1
22
Standard output:
33
node_modules/abstract-leveldown/index.d.ts(2,3): error TS7010: 'open', which lacks return-type annotation, implicitly has an 'any' return type.
44
node_modules/abstract-leveldown/index.d.ts(3,3): error TS7010: 'open', which lacks return-type annotation, implicitly has an 'any' return type.

tests/baselines/reference/user/rxjs.log

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Exit Code: 2
1+
Exit Code: 1
22
Standard output:
33
node_modules/rxjs/scheduler/VirtualTimeScheduler.d.ts(22,22): error TS2415: Class 'VirtualAction<T>' incorrectly extends base class 'AsyncAction<T>'.
44
Types of property 'work' are incompatible.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"types": ["jquery"]
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"types": ["jest"]
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"types": ["jest"]
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"types": []
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"types": []
3+
}

0 commit comments

Comments
 (0)