Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fixed the node tracking and a harness bug
(cherry picked from commit 2ab1143)
  • Loading branch information
billti committed Jul 11, 2016
commit 5eba2e09fb8ab58be895e93c16daf2571ef14f65
2 changes: 2 additions & 0 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1921,6 +1921,7 @@ namespace ts {
// If the file was previously found via a node_modules search, but is now being processed as a root file,
// then everything it sucks in may also be marked incorrectly, and needs to be checked again.
if (file && lookUp(sourceFilesFoundSearchingNodeModules, file.path) && currentNodeModulesDepth == 0) {
sourceFilesFoundSearchingNodeModules[file.path] = false;
if (!options.noResolve) {
processReferencedFiles(file, getDirectoryPath(fileName), isDefaultLib);
processTypeReferenceDirectives(file);
Expand Down Expand Up @@ -1953,6 +1954,7 @@ namespace ts {

filesByName.set(path, file);
if (file) {
sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0);
file.path = path;

if (host.useCaseSensitiveFileNames()) {
Expand Down
28 changes: 19 additions & 9 deletions src/harness/projectsRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,17 +479,27 @@ class ProjectRunner extends RunnerBase {

it("Baseline of emitted result (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => {
if (testCase.baselineCheck) {
let errs = [];
ts.forEach(compilerResult.outputFiles, outputFile => {

Harness.Baseline.runBaseline("Baseline of emitted result (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => {
try {
return Harness.IO.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind));
}
catch (e) {
return undefined;
}
});
// There may be multiple files with different baselines. Run all and report at the end, else
// it stops copying the remaining emitted files from 'local/projectOutput' to 'local/project'.
try {
Harness.Baseline.runBaseline("Baseline of emitted result (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => {
try {
return Harness.IO.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind));
}
catch (e) {
return undefined;
}
});
}
catch (e) {
errs.push(e);
}
});
if (errs.length) {
throw Error(errs.join("\n "));
}
}
});

Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/moduleAugmentationInDependency2.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export {};
//// [app.ts]
import "A"

//// [index.js]
"use strict";
//// [app.js]
"use strict";
require("A");
2 changes: 0 additions & 2 deletions tests/baselines/reference/nodeResolution6.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ export declare var y;
import y = require("a");


//// [ref.js]
var x = 1;
//// [b.js]
"use strict";
2 changes: 0 additions & 2 deletions tests/baselines/reference/nodeResolution8.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@ export declare var y;
//// [b.ts]
import y = require("a");

//// [ref.js]
var x = 1;
//// [b.js]
"use strict";
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ exports.x = 1;
//// [file2.js]
"use strict";
exports.y = 1;
//// [file4.js]
"use strict";
exports.z1 = 1;
//// [file1.js]
"use strict";
var file1_1 = require("folder2/file1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ maxDepthExceeded/root.ts(4,1): error TS2322: Type 'number' is not assignable to
==== relative.js (0 errors) ====
exports.relativeProp = true;

==== index.js (0 errors) ====
==== maxDepthExceeded/node_modules/m1/index.js (0 errors) ====
var m2 = require('m2');
var rel = require('./relative');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"maxDepthExceeded/root.ts"
],
"emittedFiles": [
"maxDepthExceeded/root.js"
"maxDepthExceeded/built/node_modules/m1/relative.js",
"maxDepthExceeded/built/node_modules/m1/index.js",
"maxDepthExceeded/built/root.js"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ maxDepthExceeded/root.ts(4,1): error TS2322: Type 'number' is not assignable to
==== relative.js (0 errors) ====
exports.relativeProp = true;

==== index.js (0 errors) ====
==== maxDepthExceeded/node_modules/m1/index.js (0 errors) ====
var m2 = require('m2');
var rel = require('./relative');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"maxDepthExceeded/root.ts"
],
"emittedFiles": [
"maxDepthExceeded/root.js"
"maxDepthExceeded/built/node_modules/m1/relative.js",
"maxDepthExceeded/built/node_modules/m1/index.js",
"maxDepthExceeded/built/root.js"
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"compilerOptions": {
"allowJs": true
}
"allowJs": true,
"maxNodeModuleJsDepth": 1, // Note: Module m1 is already included as a root file
"outDir": "built"
},
"include": ["**/*"],
"exclude": ["node_modules/m2/**/*"]
}