Skip to content

Sort the whole diagnostic, plus giving up on isolating tests #24186

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

Merged
merged 2 commits into from
May 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 8 additions & 28 deletions src/harness/externalCompileRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,9 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
const cls = this;
describe(`${this.kind()} code samples`, function(this: Mocha.ISuiteCallbackContext) {
this.timeout(600_000); // 10 minutes
const cwd = path.join(Harness.IO.getWorkspaceRoot(), cls.testDir);
const placeholderName = ".node_modules";
const moduleDirName = "node_modules";
before(() => {
ts.forEachAncestorDirectory(cwd, dir => {
try {
fs.renameSync(path.join(dir, moduleDirName), path.join(dir, placeholderName));
}
catch {
// empty
}
});
});
for (const test of testList) {
cls.runTest(typeof test === "string" ? test : test.file);
}
after(() => {
ts.forEachAncestorDirectory(cwd, dir => {
try {
fs.renameSync(path.join(dir, placeholderName), path.join(dir, moduleDirName));
}
catch {
// empty
}
});
});
});
}
private runTest(directoryName: string) {
Expand Down Expand Up @@ -137,14 +114,16 @@ ${stripAbsoluteImportPaths(result.stderr.toString().replace(/\r\n/g, "\n"))}`;
function stripAbsoluteImportPaths(result: string) {
return result
.replace(/import\(".*?\/tests\/cases\/user\//g, `import("/`)
.replace(/Module '".*?\/tests\/cases\/user\//g, `Module '"/`);
.replace(/Module '".*?\/tests\/cases\/user\//g, `Module '"/`)
.replace(/import\(".*?\/TypeScript\/node_modules\//g, `import("../../../node_modules`)
.replace(/Module '".*?\/TypeScript\/node_modules\//g, `Module '"../../../node_modules`);
}

function sortErrors(result: string) {
return ts.flatten(splitBy(result.split("\n"), s => /^\S+/.test(s)).sort(compareErrorStrings)).join("\n");
}

const errorRegexp = /^(.+\.[tj]sx?)\((\d+),(\d+)\): error TS/;
const errorRegexp = /^(.+\.[tj]sx?)\((\d+),(\d+)\)(: error TS.*)/;
function compareErrorStrings(a: string[], b: string[]) {
ts.Debug.assertGreaterThanOrEqual(a.length, 1);
ts.Debug.assertGreaterThanOrEqual(b.length, 1);
Expand All @@ -156,11 +135,12 @@ function compareErrorStrings(a: string[], b: string[]) {
if (!matchB) {
return 1;
}
const [, errorFileA, lineNumberStringA, columnNumberStringA] = matchA;
const [, errorFileB, lineNumberStringB, columnNumberStringB] = matchB;
const [, errorFileA, lineNumberStringA, columnNumberStringA, remainderA] = matchA;
const [, errorFileB, lineNumberStringB, columnNumberStringB, remainderB] = matchB;
return ts.comparePathsCaseSensitive(errorFileA, errorFileB) ||
ts.compareValues(parseInt(lineNumberStringA), parseInt(lineNumberStringB)) ||
ts.compareValues(parseInt(columnNumberStringA), parseInt(columnNumberStringB));
ts.compareValues(parseInt(columnNumberStringA), parseInt(columnNumberStringB)) ||
ts.compareStringsCaseSensitive(remainderA, remainderB);
}

class DefinitelyTypedRunner extends ExternalCompileRunnerBase {
Expand Down