Skip to content

Commit 159c808

Browse files
authored
Sort the whole diagnostic, plus giving up on isolating tests (#24186)
* Sort the whole diagnostic * Also strip references to our repos node_modules, since removing it is hard
1 parent 6af5d8b commit 159c808

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

src/harness/externalCompileRunner.ts

+8-28
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,9 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
3131
const cls = this;
3232
describe(`${this.kind()} code samples`, function(this: Mocha.ISuiteCallbackContext) {
3333
this.timeout(600_000); // 10 minutes
34-
const cwd = path.join(Harness.IO.getWorkspaceRoot(), cls.testDir);
35-
const placeholderName = ".node_modules";
36-
const moduleDirName = "node_modules";
37-
before(() => {
38-
ts.forEachAncestorDirectory(cwd, dir => {
39-
try {
40-
fs.renameSync(path.join(dir, moduleDirName), path.join(dir, placeholderName));
41-
}
42-
catch {
43-
// empty
44-
}
45-
});
46-
});
4734
for (const test of testList) {
4835
cls.runTest(typeof test === "string" ? test : test.file);
4936
}
50-
after(() => {
51-
ts.forEachAncestorDirectory(cwd, dir => {
52-
try {
53-
fs.renameSync(path.join(dir, placeholderName), path.join(dir, moduleDirName));
54-
}
55-
catch {
56-
// empty
57-
}
58-
});
59-
});
6037
});
6138
}
6239
private runTest(directoryName: string) {
@@ -137,14 +114,16 @@ ${stripAbsoluteImportPaths(result.stderr.toString().replace(/\r\n/g, "\n"))}`;
137114
function stripAbsoluteImportPaths(result: string) {
138115
return result
139116
.replace(/import\(".*?\/tests\/cases\/user\//g, `import("/`)
140-
.replace(/Module '".*?\/tests\/cases\/user\//g, `Module '"/`);
117+
.replace(/Module '".*?\/tests\/cases\/user\//g, `Module '"/`)
118+
.replace(/import\(".*?\/TypeScript\/node_modules\//g, `import("../../../node_modules`)
119+
.replace(/Module '".*?\/TypeScript\/node_modules\//g, `Module '"../../../node_modules`);
141120
}
142121

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

147-
const errorRegexp = /^(.+\.[tj]sx?)\((\d+),(\d+)\): error TS/;
126+
const errorRegexp = /^(.+\.[tj]sx?)\((\d+),(\d+)\)(: error TS.*)/;
148127
function compareErrorStrings(a: string[], b: string[]) {
149128
ts.Debug.assertGreaterThanOrEqual(a.length, 1);
150129
ts.Debug.assertGreaterThanOrEqual(b.length, 1);
@@ -156,11 +135,12 @@ function compareErrorStrings(a: string[], b: string[]) {
156135
if (!matchB) {
157136
return 1;
158137
}
159-
const [, errorFileA, lineNumberStringA, columnNumberStringA] = matchA;
160-
const [, errorFileB, lineNumberStringB, columnNumberStringB] = matchB;
138+
const [, errorFileA, lineNumberStringA, columnNumberStringA, remainderA] = matchA;
139+
const [, errorFileB, lineNumberStringB, columnNumberStringB, remainderB] = matchB;
161140
return ts.comparePathsCaseSensitive(errorFileA, errorFileB) ||
162141
ts.compareValues(parseInt(lineNumberStringA), parseInt(lineNumberStringB)) ||
163-
ts.compareValues(parseInt(columnNumberStringA), parseInt(columnNumberStringB));
142+
ts.compareValues(parseInt(columnNumberStringA), parseInt(columnNumberStringB)) ||
143+
ts.compareStringsCaseSensitive(remainderA, remainderB);
164144
}
165145

166146
class DefinitelyTypedRunner extends ExternalCompileRunnerBase {

0 commit comments

Comments
 (0)