diff --git a/Jakefile.js b/Jakefile.js
index 7f0915ad7e990..147270e0a5924 100644
--- a/Jakefile.js
+++ b/Jakefile.js
@@ -105,7 +105,7 @@ var harnessCoreSources = [
"projectsRunner.ts",
"loggedIO.ts",
"rwcRunner.ts",
- "userRunner.ts",
+ "externalCompileRunner.ts",
"test262Runner.ts",
"./parallel/shared.ts",
"./parallel/host.ts",
diff --git a/src/harness/externalCompileRunner.ts b/src/harness/externalCompileRunner.ts
new file mode 100644
index 0000000000000..9b8fc8c4fc59e
--- /dev/null
+++ b/src/harness/externalCompileRunner.ts
@@ -0,0 +1,67 @@
+///
+///
+abstract class ExternalCompileRunnerBase extends RunnerBase {
+ abstract testDir: string;
+ public enumerateTestFiles() {
+ return Harness.IO.getDirectories(this.testDir);
+ }
+ /** Setup the runner's tests so that they are ready to be executed by the harness
+ * The first test should be a describe/it block that sets up the harness's compiler instance appropriately
+ */
+ public initializeTests(): void {
+ // Read in and evaluate the test list
+ const testList = this.tests && this.tests.length ? this.tests : this.enumerateTestFiles();
+
+ describe(`${this.kind()} code samples`, () => {
+ for (const test of testList) {
+ this.runTest(test);
+ }
+ });
+ }
+ private runTest(directoryName: string) {
+ describe(directoryName, () => {
+ const cp = require("child_process");
+ const path = require("path");
+ const fs = require("fs");
+
+ it("should build successfully", () => {
+ const cwd = path.join(__dirname, "../../", this.testDir, directoryName);
+ const timeout = 600000; // 600s = 10 minutes
+ 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!`);
+ }
+ Harness.Baseline.runBaseline(`${this.kind()}/${directoryName}.log`, () => {
+ const result = cp.spawnSync(`node`, [path.join(__dirname, "tsc.js")], { cwd, timeout, shell: true });
+ // tslint:disable-next-line:no-null-keyword
+ return result.status === 0 && !result.stdout.length && !result.stderr.length ? null : `Exit Code: ${result.status}
+Standard output:
+${result.stdout.toString().replace(/\r\n/g, "\n")}
+
+
+Standard error:
+${result.stderr.toString().replace(/\r\n/g, "\n")}`;
+ });
+ });
+ });
+ }
+}
+
+class UserCodeRunner extends ExternalCompileRunnerBase {
+ public readonly testDir = "tests/cases/user/";
+ public kind(): TestRunnerKind {
+ return "user";
+ }
+}
+
+class DefinitelyTypedRunner extends ExternalCompileRunnerBase {
+ public readonly testDir = "../DefinitelyTyped/types/";
+ public workingDirectory = this.testDir;
+ public kind(): TestRunnerKind {
+ return "dt";
+ }
+}
diff --git a/src/harness/parallel/host.ts b/src/harness/parallel/host.ts
index f37a3b1099e70..e278d267e1ff6 100644
--- a/src/harness/parallel/host.ts
+++ b/src/harness/parallel/host.ts
@@ -77,18 +77,18 @@ namespace Harness.Parallel.Host {
console.log("Discovering runner-based tests...");
const discoverStart = +(new Date());
const { statSync }: { statSync(path: string): { size: number }; } = require("fs");
+ const path: { join: (...args: string[]) => string } = require("path");
for (const runner of runners) {
- const files = runner.enumerateTestFiles();
- for (const file of files) {
+ for (const file of runner.enumerateTestFiles()) {
let size: number;
if (!perfData) {
try {
- size = statSync(file).size;
+ size = statSync(path.join(runner.workingDirectory, file)).size;
}
catch {
// May be a directory
try {
- size = Harness.IO.listFiles(file, /.*/g, { recursive: true }).reduce((acc, elem) => acc + statSync(elem).size, 0);
+ size = Harness.IO.listFiles(path.join(runner.workingDirectory, file), /.*/g, { recursive: true }).reduce((acc, elem) => acc + statSync(elem).size, 0);
}
catch {
// Unknown test kind, just return 0 and let the historical analysis take over after one run
diff --git a/src/harness/runner.ts b/src/harness/runner.ts
index 70954e9e853d6..a121059109010 100644
--- a/src/harness/runner.ts
+++ b/src/harness/runner.ts
@@ -18,7 +18,7 @@
///
///
///
-///
+///
///
///
@@ -62,6 +62,8 @@ function createRunner(kind: TestRunnerKind): RunnerBase {
return new Test262BaselineRunner();
case "user":
return new UserCodeRunner();
+ case "dt":
+ return new DefinitelyTypedRunner();
}
ts.Debug.fail(`Unknown runner kind ${kind}`);
}
@@ -183,6 +185,9 @@ function handleTestConfig() {
case "user":
runners.push(new UserCodeRunner());
break;
+ case "dt":
+ runners.push(new DefinitelyTypedRunner());
+ break;
}
}
}
diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts
index 2fef2264b73ea..2858738f4b56a 100644
--- a/src/harness/runnerbase.ts
+++ b/src/harness/runnerbase.ts
@@ -1,7 +1,7 @@
///
-type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "test262" | "user";
+type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "test262" | "user" | "dt";
type CompilerTestKind = "conformance" | "compiler";
type FourslashTestKind = "fourslash" | "fourslash-shims" | "fourslash-shims-pp" | "fourslash-server";
@@ -24,6 +24,9 @@ abstract class RunnerBase {
abstract enumerateTestFiles(): string[];
+ /** The working directory where tests are found. Needed for batch testing where the input path will differ from the output path inside baselines */
+ public workingDirectory = "";
+
/** Setup the runner's tests so that they are ready to be executed by the harness
* The first test should be a describe/it block that sets up the harness's compiler instance appropriately
*/
diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json
index 6e61b7690bc79..1ab2cb955c8c3 100644
--- a/src/harness/tsconfig.json
+++ b/src/harness/tsconfig.json
@@ -92,7 +92,7 @@
"projectsRunner.ts",
"loggedIO.ts",
"rwcRunner.ts",
- "userRunner.ts",
+ "externalCompileRunner.ts",
"test262Runner.ts",
"./parallel/shared.ts",
"./parallel/host.ts",
diff --git a/src/harness/userRunner.ts b/src/harness/userRunner.ts
deleted file mode 100644
index 9be652aebf8ae..0000000000000
--- a/src/harness/userRunner.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-///
-///
-class UserCodeRunner extends RunnerBase {
- private static readonly testDir = "tests/cases/user/";
- public enumerateTestFiles() {
- return Harness.IO.getDirectories(UserCodeRunner.testDir);
- }
-
- public kind(): TestRunnerKind {
- return "user";
- }
-
- /** Setup the runner's tests so that they are ready to be executed by the harness
- * The first test should be a describe/it block that sets up the harness's compiler instance appropriately
- */
- public initializeTests(): void {
- // Read in and evaluate the test list
- const testList = this.tests && this.tests.length ? this.tests : this.enumerateTestFiles();
-
- describe(`${this.kind()} code samples`, () => {
- for (const test of testList) {
- this.runTest(test);
- }
- });
- }
-
- private runTest(directoryName: string) {
- describe(directoryName, () => {
- const cp = require("child_process");
- const path = require("path");
-
- it("should build successfully", () => {
- const cwd = path.join(__dirname, "../../", UserCodeRunner.testDir, directoryName);
- const timeout = 600000; // 10 minutes
- 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!`);
- Harness.Baseline.runBaseline(`${this.kind()}/${directoryName}.log`, () => {
- const result = cp.spawnSync(`node`, ["../../../../built/local/tsc.js"], { cwd, timeout, shell: true });
- return `Exit Code: ${result.status}
-Standard output:
-${result.stdout.toString().replace(/\r\n/g, "\n")}
-
-
-Standard error:
-${result.stderr.toString().replace(/\r\n/g, "\n")}`;
- });
- });
- });
- }
-}
diff --git a/tests/baselines/reference/user/ajv.log b/tests/baselines/reference/user/ajv.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/ajv.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/antd.log b/tests/baselines/reference/user/antd.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/antd.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/axios.log b/tests/baselines/reference/user/axios.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/axios.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/bignumber.js.log b/tests/baselines/reference/user/bignumber.js.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/bignumber.js.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/discord.js.log b/tests/baselines/reference/user/discord.js.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/discord.js.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/eventemitter2.log b/tests/baselines/reference/user/eventemitter2.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/eventemitter2.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/eventemitter3.log b/tests/baselines/reference/user/eventemitter3.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/eventemitter3.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/firebase.log b/tests/baselines/reference/user/firebase.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/firebase.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/github.log b/tests/baselines/reference/user/github.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/github.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/immutable.log b/tests/baselines/reference/user/immutable.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/immutable.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/isobject.log b/tests/baselines/reference/user/isobject.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/isobject.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/jimp.log b/tests/baselines/reference/user/jimp.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/jimp.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/jsonschema.log b/tests/baselines/reference/user/jsonschema.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/jsonschema.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/keycode.log b/tests/baselines/reference/user/keycode.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/keycode.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/localforage.log b/tests/baselines/reference/user/localforage.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/localforage.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/log4js.log b/tests/baselines/reference/user/log4js.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/log4js.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/mobx.log b/tests/baselines/reference/user/mobx.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/mobx.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/moment.log b/tests/baselines/reference/user/moment.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/moment.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/mqtt.log b/tests/baselines/reference/user/mqtt.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/mqtt.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/parse5.log b/tests/baselines/reference/user/parse5.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/parse5.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/portfinder.log b/tests/baselines/reference/user/portfinder.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/portfinder.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/postcss.log b/tests/baselines/reference/user/postcss.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/postcss.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/protobufjs.log b/tests/baselines/reference/user/protobufjs.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/protobufjs.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/redux.log b/tests/baselines/reference/user/redux.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/redux.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/reselect.log b/tests/baselines/reference/user/reselect.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/reselect.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/should.log b/tests/baselines/reference/user/should.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/should.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/sift.log b/tests/baselines/reference/user/sift.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/sift.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/soap.log b/tests/baselines/reference/user/soap.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/soap.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/sugar.log b/tests/baselines/reference/user/sugar.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/sugar.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/tslint.log b/tests/baselines/reference/user/tslint.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/tslint.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/vue.log b/tests/baselines/reference/user/vue.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/vue.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/vuex.log b/tests/baselines/reference/user/vuex.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/vuex.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/xlsx.log b/tests/baselines/reference/user/xlsx.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/xlsx.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/xpath.log b/tests/baselines/reference/user/xpath.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/xpath.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error:
diff --git a/tests/baselines/reference/user/zone.js.log b/tests/baselines/reference/user/zone.js.log
deleted file mode 100644
index 15b10503c1f77..0000000000000
--- a/tests/baselines/reference/user/zone.js.log
+++ /dev/null
@@ -1,6 +0,0 @@
-Exit Code: 0
-Standard output:
-
-
-
-Standard error: