From d66e94d09e6e66574b06a8fe01d1db63eb7b6a74 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 10 Nov 2017 13:50:18 -0800 Subject: [PATCH 1/5] ExternalCompileRunner works with submodules If there is a test.json in the directory, it expects to find a submodule in the directory. The submodule should have the same name as the directory itself. test.json contains a list of global types that need to be available, or the empty list if none. --- .gitmodules | 6 +++++ src/harness/externalCompileRunner.ts | 26 ++++++++++++++++--- .../TypeScript-Node-Starter | 1 + .../TypeScript-React-Starter | 1 + 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 .gitmodules create mode 160000 tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter create mode 160000 tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000000..1a1c6e193fd --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter"] + path = tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter + url = https://github.com/Microsoft/TypeScript-React-Starter +[submodule "tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter"] + path = tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter + url = https://github.com/Microsoft/TypeScript-Node-Starter.git diff --git a/src/harness/externalCompileRunner.ts b/src/harness/externalCompileRunner.ts index 33803752f94..0f9386ddb0f 100644 --- a/src/harness/externalCompileRunner.ts +++ b/src/harness/externalCompileRunner.ts @@ -9,6 +9,10 @@ interface ExecResult { status: number; } +interface UserConfig { + types: string[]; +} + abstract class ExternalCompileRunnerBase extends RunnerBase { abstract testDir: string; abstract report(result: ExecResult, cwd: string): string; @@ -33,18 +37,34 @@ abstract class ExternalCompileRunnerBase extends RunnerBase { const cp = require("child_process"); it("should build successfully", () => { - const cwd = path.join(__dirname, "../../", this.testDir, directoryName); + let cwd = path.join(__dirname, "../../", this.testDir, directoryName); const timeout = 600000; // 600s = 10 minutes + const stdio = isWorker ? "pipe" : "inherit"; + let types: string[]; + if (fs.existsSync(path.join(cwd, "test.json"))) { + const update = cp.spawnSync('git', ["submodule", "update", "--remote"], { cwd, timeout, shell: true, stdio }) + if (update.status !== 0) throw new Error(`git submodule update for ${directoryName} failed!`); + + const config = JSON.parse(fs.readFileSync(path.join(cwd, "test.json"), { encoding: "utf8" })) as UserConfig; + ts.Debug.assert(!!config.types, "Git is the only reason for using test.json right now"); + types = config.types; + + cwd = path.join(cwd, directoryName); + } if (fs.existsSync(path.join(cwd, "package.json"))) { if (fs.existsSync(path.join(cwd, "package-lock.json"))) { fs.unlinkSync(path.join(cwd, "package-lock.json")); } - const stdio = isWorker ? "pipe" : "inherit"; const install = cp.spawnSync(`npm`, ["i"], { cwd, timeout, shell: true, stdio }); if (install.status !== 0) throw new Error(`NPM Install for ${directoryName} failed!`); } + const args = [path.join(__dirname, "tsc.js")]; + if (types) { + args.push("--types", types.join(",")); + } + args.push("--noEmit"); Harness.Baseline.runBaseline(`${this.kind()}/${directoryName}.log`, () => { - return this.report(cp.spawnSync(`node`, [path.join(__dirname, "tsc.js")], { cwd, timeout, shell: true }), cwd); + return this.report(cp.spawnSync(`node`, args, { cwd, timeout, shell: true }), cwd); }); }); }); diff --git a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter new file mode 160000 index 00000000000..ed149eb0c78 --- /dev/null +++ b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter @@ -0,0 +1 @@ +Subproject commit ed149eb0c787b1195a95b44105822c64bb6eb636 diff --git a/tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter b/tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter new file mode 160000 index 00000000000..96fb6237a9d --- /dev/null +++ b/tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter @@ -0,0 +1 @@ +Subproject commit 96fb6237a9dda8d17059eea7fa7c22dd7db82c97 From d4c001d47c90d14a1ca020d2877babf58fffeb90 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 10 Nov 2017 14:20:55 -0800 Subject: [PATCH 2/5] Add test w/submodules for our starter kits --- .gitmodules | 9 +++++++++ tests/cases/user/TypeScript-Node-Starter/test.json | 3 +++ .../TypeScript-React-Native-Starter | 1 + .../cases/user/TypeScript-React-Native-Starter/test.json | 3 +++ tests/cases/user/TypeScript-React-Starter/test.json | 3 +++ .../user/TypeScript-Vue-Starter/TypeScript-Vue-Starter | 1 + tests/cases/user/TypeScript-Vue-Starter/test.json | 3 +++ .../TypeScript-WeChat-Starter/TypeScript-WeChat-Starter | 1 + tests/cases/user/TypeScript-WeChat-Starter/test.json | 3 +++ 9 files changed, 27 insertions(+) create mode 100644 tests/cases/user/TypeScript-Node-Starter/test.json create mode 160000 tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter create mode 100644 tests/cases/user/TypeScript-React-Native-Starter/test.json create mode 100644 tests/cases/user/TypeScript-React-Starter/test.json create mode 160000 tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter create mode 100644 tests/cases/user/TypeScript-Vue-Starter/test.json create mode 160000 tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter create mode 100644 tests/cases/user/TypeScript-WeChat-Starter/test.json diff --git a/.gitmodules b/.gitmodules index 1a1c6e193fd..f83d0f77c9e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,12 @@ [submodule "tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter"] path = tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter url = https://github.com/Microsoft/TypeScript-Node-Starter.git +[submodule "tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter"] + path = tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter + url = https://github.com/Microsoft/TypeScript-React-Native-Starter.git +[submodule "tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter"] + path = tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter + url = https://github.com/Microsoft/TypeScript-Vue-Starter.git +[submodule "tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter"] + path = tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter + url = https://github.com/Microsoft/TypeScript-WeChat-Starter.git diff --git a/tests/cases/user/TypeScript-Node-Starter/test.json b/tests/cases/user/TypeScript-Node-Starter/test.json new file mode 100644 index 00000000000..11d2aa87c59 --- /dev/null +++ b/tests/cases/user/TypeScript-Node-Starter/test.json @@ -0,0 +1,3 @@ +{ + "types": ["jquery"] +} diff --git a/tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter b/tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter new file mode 160000 index 00000000000..2c62f5a4ea5 --- /dev/null +++ b/tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter @@ -0,0 +1 @@ +Subproject commit 2c62f5a4ea51978e3715b475e17962cdeca75e38 diff --git a/tests/cases/user/TypeScript-React-Native-Starter/test.json b/tests/cases/user/TypeScript-React-Native-Starter/test.json new file mode 100644 index 00000000000..8b177c575aa --- /dev/null +++ b/tests/cases/user/TypeScript-React-Native-Starter/test.json @@ -0,0 +1,3 @@ +{ + "types": ["jest"] +} diff --git a/tests/cases/user/TypeScript-React-Starter/test.json b/tests/cases/user/TypeScript-React-Starter/test.json new file mode 100644 index 00000000000..8b177c575aa --- /dev/null +++ b/tests/cases/user/TypeScript-React-Starter/test.json @@ -0,0 +1,3 @@ +{ + "types": ["jest"] +} diff --git a/tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter b/tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter new file mode 160000 index 00000000000..713c6986f04 --- /dev/null +++ b/tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter @@ -0,0 +1 @@ +Subproject commit 713c6986f043f2c31976b8bc2c03aa0a2b05590b diff --git a/tests/cases/user/TypeScript-Vue-Starter/test.json b/tests/cases/user/TypeScript-Vue-Starter/test.json new file mode 100644 index 00000000000..e0d4d26bdca --- /dev/null +++ b/tests/cases/user/TypeScript-Vue-Starter/test.json @@ -0,0 +1,3 @@ +{ + "types": [] +} diff --git a/tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter b/tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter new file mode 160000 index 00000000000..5fca1032eda --- /dev/null +++ b/tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter @@ -0,0 +1 @@ +Subproject commit 5fca1032edaab5414ec1c167f42d3dc59220d9aa diff --git a/tests/cases/user/TypeScript-WeChat-Starter/test.json b/tests/cases/user/TypeScript-WeChat-Starter/test.json new file mode 100644 index 00000000000..e0d4d26bdca --- /dev/null +++ b/tests/cases/user/TypeScript-WeChat-Starter/test.json @@ -0,0 +1,3 @@ +{ + "types": [] +} From 0d63589fb2da23c0a243a8fd47cb0c96df6deac7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 10 Nov 2017 14:21:53 -0800 Subject: [PATCH 3/5] Fix quote lint --- src/harness/externalCompileRunner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/externalCompileRunner.ts b/src/harness/externalCompileRunner.ts index 0f9386ddb0f..75ccecb047d 100644 --- a/src/harness/externalCompileRunner.ts +++ b/src/harness/externalCompileRunner.ts @@ -42,7 +42,7 @@ abstract class ExternalCompileRunnerBase extends RunnerBase { const stdio = isWorker ? "pipe" : "inherit"; let types: string[]; if (fs.existsSync(path.join(cwd, "test.json"))) { - const update = cp.spawnSync('git', ["submodule", "update", "--remote"], { cwd, timeout, shell: true, stdio }) + const update = cp.spawnSync("git", ["submodule", "update", "--remote"], { cwd, timeout, shell: true, stdio }); if (update.status !== 0) throw new Error(`git submodule update for ${directoryName} failed!`); const config = JSON.parse(fs.readFileSync(path.join(cwd, "test.json"), { encoding: "utf8" })) as UserConfig; From ba232b2164e7d0789bdc668e6b750696f8f7a8e2 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 10 Nov 2017 14:36:49 -0800 Subject: [PATCH 4/5] Update baselines --- tests/baselines/reference/user/electron.log | 2 +- tests/baselines/reference/user/leveldown.log | 2 +- tests/baselines/reference/user/rxjs.log | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/baselines/reference/user/electron.log b/tests/baselines/reference/user/electron.log index e5eef689d49..7ba43481c3b 100644 --- a/tests/baselines/reference/user/electron.log +++ b/tests/baselines/reference/user/electron.log @@ -1,4 +1,4 @@ -Exit Code: 2 +Exit Code: 1 Standard output: node_modules/electron/electron.d.ts(5390,13): error TS2430: Interface 'WebviewTag' incorrectly extends interface 'HTMLElement'. Types of property 'addEventListener' are incompatible. diff --git a/tests/baselines/reference/user/leveldown.log b/tests/baselines/reference/user/leveldown.log index c37a983f73d..011071ebc52 100644 --- a/tests/baselines/reference/user/leveldown.log +++ b/tests/baselines/reference/user/leveldown.log @@ -1,4 +1,4 @@ -Exit Code: 2 +Exit Code: 1 Standard output: node_modules/abstract-leveldown/index.d.ts(2,3): error TS7010: 'open', which lacks return-type annotation, implicitly has an 'any' return type. node_modules/abstract-leveldown/index.d.ts(3,3): error TS7010: 'open', which lacks return-type annotation, implicitly has an 'any' return type. diff --git a/tests/baselines/reference/user/rxjs.log b/tests/baselines/reference/user/rxjs.log index 73058119ce9..c17014c5c13 100644 --- a/tests/baselines/reference/user/rxjs.log +++ b/tests/baselines/reference/user/rxjs.log @@ -1,4 +1,4 @@ -Exit Code: 2 +Exit Code: 1 Standard output: node_modules/rxjs/scheduler/VirtualTimeScheduler.d.ts(22,22): error TS2415: Class 'VirtualAction' incorrectly extends base class 'AsyncAction'. Types of property 'work' are incompatible. From 4d0139084596a18a2ba0af583bd2cc3bad164aab Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 10 Nov 2017 15:55:29 -0800 Subject: [PATCH 5/5] Improve assert message --- src/harness/externalCompileRunner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/externalCompileRunner.ts b/src/harness/externalCompileRunner.ts index 75ccecb047d..2a44badd813 100644 --- a/src/harness/externalCompileRunner.ts +++ b/src/harness/externalCompileRunner.ts @@ -46,7 +46,7 @@ abstract class ExternalCompileRunnerBase extends RunnerBase { if (update.status !== 0) throw new Error(`git submodule update for ${directoryName} failed!`); const config = JSON.parse(fs.readFileSync(path.join(cwd, "test.json"), { encoding: "utf8" })) as UserConfig; - ts.Debug.assert(!!config.types, "Git is the only reason for using test.json right now"); + ts.Debug.assert(!!config.types, "Bad format from test.json: Types field must be present."); types = config.types; cwd = path.join(cwd, directoryName);