-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Batch enumerateFiles into a single web request #23972
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
Changes from all commits
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 |
---|---|---|
|
@@ -36,6 +36,7 @@ class FourSlashRunner extends RunnerBase { | |
} | ||
|
||
public enumerateTestFiles() { | ||
// see also: `enumerateTestFiles` in tests/webTestServer.ts | ||
return this.enumerateFiles(this.basePath, /\.ts/i, { recursive: false }); | ||
} | ||
|
||
|
@@ -45,22 +46,23 @@ class FourSlashRunner extends RunnerBase { | |
|
||
public initializeTests() { | ||
if (this.tests.length === 0) { | ||
this.tests = this.enumerateTestFiles(); | ||
this.tests = Harness.IO.enumerateTestFiles(this); | ||
} | ||
|
||
describe(this.testSuiteName + " tests", () => { | ||
this.tests.forEach((fn: string) => { | ||
describe(fn, () => { | ||
fn = ts.normalizeSlashes(fn); | ||
const justName = fn.replace(/^.*[\\\/]/, ""); | ||
this.tests.forEach(test => { | ||
const file = typeof test === "string" ? test : test.file; | ||
describe(file, () => { | ||
let fn = ts.normalizeSlashes(file); | ||
const justName = fn.replace(/^.*[\\\/]/, ""); | ||
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. Is this 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. Possibly, but that source is unchanged from the original (aside from indentation). |
||
|
||
// Convert to relative path | ||
const testIndex = fn.indexOf("tests/"); | ||
if (testIndex >= 0) fn = fn.substr(testIndex); | ||
// Convert to relative path | ||
const testIndex = fn.indexOf("tests/"); | ||
if (testIndex >= 0) fn = fn.substr(testIndex); | ||
|
||
if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) { | ||
it(this.testSuiteName + " test " + justName + " runs correctly", () => { | ||
FourSlash.runFourSlashTest(this.basePath, this.testType, fn); | ||
if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) { | ||
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. If we somehow got an empty name we don't run the test -- maybe this should be an assert instead of an 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. Possibly, but that source is unchanged from the original (aside from indentation). |
||
it(this.testSuiteName + " test " + justName + " runs correctly", () => { | ||
FourSlash.runFourSlashTest(this.basePath, this.testType, fn); | ||
}); | ||
} | ||
}); | ||
|
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.
Took me a minute to realize this meant
fileName
notfunction
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.
Yeah, but in general I am just trying to preserve as much of the original source here as I can.