-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Add DefinitelyTyped runner #19815
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
Changes from 6 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,62 @@ | ||
/// <reference path="harness.ts"/> | ||
/// <reference path="runnerbase.ts" /> | ||
class DefinitelyTypedRunner extends RunnerBase { | ||
private static readonly testDir = "../DefinitelyTyped/types/"; | ||
|
||
public workingDirectory = DefinitelyTypedRunner.testDir; | ||
|
||
public enumerateTestFiles() { | ||
return Harness.IO.getDirectories(DefinitelyTypedRunner.testDir); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be worth throwing an error if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out getDirectories throws already, which I think is good enough. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does a function called |
||
} | ||
|
||
public kind(): TestRunnerKind { | ||
return "dt"; | ||
} | ||
|
||
/** 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`, () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like code copied from elsewhere -- can you just inherit? |
||
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, "../../", DefinitelyTypedRunner.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:no-null-keyword | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: use |
||
return result.status === 0 ? 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")}`; | ||
// tslint:enable:no-null-keyword | ||
}); | ||
}); | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,7 @@ | |
"loggedIO.ts", | ||
"rwcRunner.ts", | ||
"userRunner.ts", | ||
"definitelyRunner.ts", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The file you added is named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just by gulp. Fixed. |
||
"test262Runner.ts", | ||
"./parallel/shared.ts", | ||
"./parallel/host.ts", | ||
|
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.
do you want to add an assert here or something to let users know that DefinitllyTyped was not found in the expected place instead of silently not running any tests.