From 3733461edeab91bdefdffae550b1849d3eb90229 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 16 May 2018 14:38:11 -0700 Subject: [PATCH 1/2] Sort the whole diagnostic --- src/harness/externalCompileRunner.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/harness/externalCompileRunner.ts b/src/harness/externalCompileRunner.ts index 8cc5201228f7d..2daef10a984db 100644 --- a/src/harness/externalCompileRunner.ts +++ b/src/harness/externalCompileRunner.ts @@ -144,7 +144,7 @@ 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); @@ -156,11 +156,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 { From ae97530e0e5fba96b8b25ce9915e179743d4bf7a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 16 May 2018 15:15:28 -0700 Subject: [PATCH 2/2] Also strip references to our repos node_modules, since removing it is hard --- src/harness/externalCompileRunner.ts | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/harness/externalCompileRunner.ts b/src/harness/externalCompileRunner.ts index 2daef10a984db..eac5d92d3e406 100644 --- a/src/harness/externalCompileRunner.ts +++ b/src/harness/externalCompileRunner.ts @@ -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) { @@ -137,7 +114,9 @@ ${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) {