Skip to content

Commit 2ab1143

Browse files
committed
Fixed the node tracking and a harness bug
1 parent db54bda commit 2ab1143

File tree

13 files changed

+40
-19
lines changed

13 files changed

+40
-19
lines changed

src/compiler/program.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,6 +1921,7 @@ namespace ts {
19211921
// If the file was previously found via a node_modules search, but is now being processed as a root file,
19221922
// then everything it sucks in may also be marked incorrectly, and needs to be checked again.
19231923
if (file && lookUp(sourceFilesFoundSearchingNodeModules, file.path) && currentNodeModulesDepth == 0) {
1924+
sourceFilesFoundSearchingNodeModules[file.path] = false;
19241925
if (!options.noResolve) {
19251926
processReferencedFiles(file, getDirectoryPath(fileName), isDefaultLib);
19261927
processTypeReferenceDirectives(file);
@@ -1953,6 +1954,7 @@ namespace ts {
19531954

19541955
filesByName.set(path, file);
19551956
if (file) {
1957+
sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0);
19561958
file.path = path;
19571959

19581960
if (host.useCaseSensitiveFileNames()) {

src/harness/projectsRunner.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -479,17 +479,27 @@ class ProjectRunner extends RunnerBase {
479479

480480
it("Baseline of emitted result (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => {
481481
if (testCase.baselineCheck) {
482+
let errs = [];
482483
ts.forEach(compilerResult.outputFiles, outputFile => {
483-
484-
Harness.Baseline.runBaseline("Baseline of emitted result (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => {
485-
try {
486-
return Harness.IO.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind));
487-
}
488-
catch (e) {
489-
return undefined;
490-
}
491-
});
484+
// There may be multiple files with different baselines. Run all and report at the end, else
485+
// it stops copying the remaining emitted files from 'local/projectOutput' to 'local/project'.
486+
try {
487+
Harness.Baseline.runBaseline("Baseline of emitted result (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => {
488+
try {
489+
return Harness.IO.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind));
490+
}
491+
catch (e) {
492+
return undefined;
493+
}
494+
});
495+
}
496+
catch (e) {
497+
errs.push(e);
498+
}
492499
});
500+
if (errs.length) {
501+
throw Error(errs.join("\n "));
502+
}
493503
}
494504
});
495505

tests/baselines/reference/moduleAugmentationInDependency2.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export {};
88
//// [app.ts]
99
import "A"
1010

11+
//// [index.js]
12+
"use strict";
1113
//// [app.js]
1214
"use strict";
1315
require("A");

tests/baselines/reference/nodeResolution6.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@ export declare var y;
1313
import y = require("a");
1414

1515

16-
//// [ref.js]
17-
var x = 1;
1816
//// [b.js]
1917
"use strict";

tests/baselines/reference/nodeResolution8.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,5 @@ export declare var y;
1212
//// [b.ts]
1313
import y = require("a");
1414

15-
//// [ref.js]
16-
var x = 1;
1715
//// [b.js]
1816
"use strict";

tests/baselines/reference/pathMappingBasedModuleResolution5_node.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ exports.x = 1;
3131
//// [file2.js]
3232
"use strict";
3333
exports.y = 1;
34+
//// [file4.js]
35+
"use strict";
36+
exports.z1 = 1;
3437
//// [file1.js]
3538
"use strict";
3639
var file1_1 = require("folder2/file1");

tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ maxDepthExceeded/root.ts(4,1): error TS2322: Type 'number' is not assignable to
1414
==== relative.js (0 errors) ====
1515
exports.relativeProp = true;
1616

17-
==== index.js (0 errors) ====
17+
==== maxDepthExceeded/node_modules/m1/index.js (0 errors) ====
1818
var m2 = require('m2');
1919
var rel = require('./relative');
2020

tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"maxDepthExceeded/root.ts"
1414
],
1515
"emittedFiles": [
16-
"maxDepthExceeded/root.js"
16+
"maxDepthExceeded/built/node_modules/m1/relative.js",
17+
"maxDepthExceeded/built/node_modules/m1/index.js",
18+
"maxDepthExceeded/built/root.js"
1719
]
1820
}

0 commit comments

Comments
 (0)