-
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
Conversation
Assumes that ../DefinitelyTyped holds the DefinitelyTyped repo.
1. Only `npm install` packages with a package.json 2. Add `workingDirectory` to runnerBase to differentiate input directory from output directory (which should be different for definitelyRunner). 3. Don't output anything on success.
By the way, for @andy-ms, 31 of the 78 errors that DefinitelyTyped has when compiling on master were from missing lib entries from dependencies. The others are a random mish-mash of errors that have been introduced since 2.0. |
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.
Also, maybe dt
instead of definitely
mostly because I think t=dt
is shorter and I'm liable to misspell t=definitely
a few times.
src/harness/definitelyRunner.ts
Outdated
const timeout = 600000; // 600s = 10 minutes | ||
if (fs.existsSync(path.join(cwd, 'package.json'))) { | ||
const stdio = isWorker ? "pipe" : "inherit"; | ||
const install = cp.spawnSync(`npm`, ["i"], { cwd, timeout, shell: true, stdio }); |
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.
Should we delete a package-lock.json
before running npm i
? As is, if a DT package updates a dep, I don't think it'd get tested here.
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.
Ugggg. Is there a way not to emit package-lock.json
? I'd rather do that instead.
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.
Nope! Guess I'll have to remove it!
If we're not committing the baselines, I suppose we have no interest in adding it to the daily cron build? Would this be something we'd be more comfortable with as like a weekly build? Or is it because the DT repo already has similar associated tests? |
|
we already have another test run going against DT. this one is more of a local validation after a change. |
src/harness/dtRunner.ts
Outdated
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 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.
src/harness/dtRunner.ts
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth throwing an error if DefinitelyTypedRunner.testDir
is empty/does not exist (rather than the usual behavior of getDirectories
, which I believe just produces undefined
or an empty list). After all, without that, an empty or missing folder is a passing DT suite, which could be misleading if you run this with DefinitelyTyped
cloned in the wrong location.
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.
Turns out getDirectories throws already, which I think is good enough.
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.
Why does a function called enumerateTestFiles
return a list of directories?
@andy-ms can you take a look as well. |
src/harness/dtRunner.ts
Outdated
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like code copied from elsewhere -- can you just inherit?
src/harness/dtRunner.ts
Outdated
} | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: use // tslint:disable-next-line
, and indent it with the other statements.
Also, can this code be shared with code elsewhere?
src/harness/tsconfig.json
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
The file you added is named dtRunner
instead, which implies this isn't being used?
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.
Just by gulp. Fixed.
OK, I pulled everything up into a superclass except a couple of properties. I stuck all three classes in one file since the subclasses are now, essentially, just pieces of configuration (that still needs to be |
src/harness/externalCompileRunner.ts
Outdated
} | ||
} | ||
|
||
class DefinitelyTypedRunner extends ExternalCompileRunnerBase { |
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.
This is starting to look like it should be just another instance of a class instead of its own class.
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.
True, except that Wesley is shortly going to want to put in more code into the UserCodeRunner, and I already need to put more code into the DefinitelyTypedRunner to skip ExpectErrors. I'll keep it the way it is for now and we can simplify later if neither of those efforts work out.
src/harness/externalCompileRunner.ts
Outdated
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 ? null : `Exit Code: ${result.status} |
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.
As mentioned in person, check result.status
and result.stdout
and result.stderr
instead of just result.status
- we want to capture any output even when we report success.
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.
Yep, done.
I've got git problems and I'm not even on Windows!
@@ -105,7 +105,7 @@ var harnessCoreSources = [ | |||
"projectsRunner.ts", | |||
"loggedIO.ts", | |||
"rwcRunner.ts", | |||
"userRunner.ts", | |||
"externalCompileRunner.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.
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.
Adds a test runner that compiles DefinitelyTyped packages with the currently built compiler. You must have a DefinitelyTyped repo named
DefinitelyTyped
next to your Typescript repo.The test only outputs a log file to
baselines/local/definitely/
when there is a failure. Currently about 75 packages have compile failures. I expect this number to fluctuate up and down rapidly based on DefinitelyTyped's amount of traffic, so I have not included the baselines here, after discussion with @mhegazy. A run takes about 15 minutes on my machine, so it's simple, if slow, to baseline from master when needed.I just tested on #17765 and the experience is many times better and faster than the shell scripts I used before.