-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DefinitelyTyped runner #19815
Add DefinitelyTyped runner #19815
Changes from all commits
e6c38bf
f2d4b36
9a415a2
2378ff3
88a31d6
5e5b565
d64a8f6
397b549
bb79308
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/// <reference path="harness.ts"/> | ||
/// <reference path="runnerbase.ts" /> | ||
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"; | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jakefile, but not gulp?
The official TS homepage refers to gulp. Does it mean both gulp/jake need to be used, depending on area of the project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they don't behave the same it's a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gulp uses the tsconfig edited below.