Skip to content

Fix issue with some baselines for tsbuildinfo not getting generated #43218

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 1 commit into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
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
10 changes: 7 additions & 3 deletions src/testRunner/unittests/tsbuild/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ interface Symbol {
}
}

export function generateSourceMapBaselineFiles(sys: System & { writtenFiles: ReadonlyCollection<string>; }) {
export function generateSourceMapBaselineFiles(sys: System & { writtenFiles: ReadonlyCollection<Path>; }) {
const mapFileNames = mapDefinedIterator(sys.writtenFiles.keys(), f => f.endsWith(".map") ? f : undefined);
while (true) {
const result = mapFileNames.next();
Expand Down Expand Up @@ -297,14 +297,18 @@ interface Symbol {
}
}

export function toPathWithSystem(sys: System, fileName: string): Path {
return toPath(fileName, sys.getCurrentDirectory(), createGetCanonicalFileName(sys.useCaseSensitiveFileNames));
}

export function baselineBuildInfo(
options: CompilerOptions,
sys: System & { writtenFiles: ReadonlyCollection<string>; },
sys: System & { writtenFiles: ReadonlyCollection<Path>; },
originalReadCall?: System["readFile"],
originalWriteFile?: System["writeFile"],
) {
const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
if (!buildInfoPath || !sys.writtenFiles.has(buildInfoPath)) return;
if (!buildInfoPath || !sys.writtenFiles.has(toPathWithSystem(sys, buildInfoPath))) return;
if (!sys.fileExists(buildInfoPath)) return;

const buildInfo = getBuildInfo((originalReadCall || sys.readFile).call(sys, buildInfoPath, "utf8")!);
Expand Down
11 changes: 6 additions & 5 deletions src/testRunner/unittests/tsc/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace ts {
export type TscCompileSystem = fakes.System & {
writtenFiles: Set<string>;
writtenFiles: Set<Path>;
baseLine(): { file: string; text: string; };
};

Expand Down Expand Up @@ -42,7 +42,7 @@ namespace ts {
return !!(program as Program | EmitAndSemanticDiagnosticsBuilderProgram).getCompilerOptions;
}
export function commandLineCallbacks(
sys: System & { writtenFiles: ReadonlyCollection<string>; },
sys: System & { writtenFiles: ReadonlyCollection<Path>; },
originalReadCall?: System["readFile"],
originalWriteFile?: System["writeFile"],
): CommandLineCallbacks {
Expand Down Expand Up @@ -84,11 +84,12 @@ namespace ts {
// Create system
const sys = new fakes.System(fs, { executingFilePath: "/lib/tsc" }) as TscCompileSystem;
fakes.patchHostForBuildInfoReadWrite(sys);
const writtenFiles = sys.writtenFiles = new Set<string>();
const writtenFiles = sys.writtenFiles = new Set();
const originalWriteFile = sys.writeFile;
sys.writeFile = (fileName, content, writeByteOrderMark) => {
assert.isFalse(writtenFiles.has(fileName));
writtenFiles.add(fileName);
const path = toPathWithSystem(sys, fileName);
assert.isFalse(writtenFiles.has(path));
writtenFiles.add(path);
return originalWriteFile.call(sys, fileName, content, writeByteOrderMark);
};
const actualReadFileMap: MapLike<number> = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export declare const World = "hello";
//// [/src/core/anotherModule.d.ts.map]
{"version":3,"file":"anotherModule.d.ts","sourceRoot":"","sources":["anotherModule.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,UAAU,CAAC"}

//// [/src/core/anotherModule.d.ts.map.baseline.txt]
//// [/src/core/anothermodule.d.ts.map.baseline.txt]
===================================================================
JsFile: anotherModule.d.ts
mapUrl: anotherModule.d.ts.map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export declare const World = "hello";
//// [/src/core/anotherModule.d.ts.map]
{"version":3,"file":"anotherModule.d.ts","sourceRoot":"","sources":["anotherModule.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,UAAU,CAAC"}

//// [/src/core/anotherModule.d.ts.map.baseline.txt]
//// [/src/core/anothermodule.d.ts.map.baseline.txt]
===================================================================
JsFile: anotherModule.d.ts
mapUrl: anotherModule.d.ts.map
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Output::

[12:00:30 AM] Building project '/user/username/projects/sample1/core/tsconfig.json'...

[12:00:44 AM] Found 0 errors. Watching for file changes.
[12:00:46 AM] Found 0 errors. Watching for file changes.



Expand Down Expand Up @@ -102,6 +102,49 @@ export declare function multiply(a: number, b: number): number;
//// [/user/username/projects/sample1/core/outDir/tsconfig.tsbuildinfo]
{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../anothermodule.ts","../index.ts"],"fileInfos":[{"version":"-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }","signature":"-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }","affectsGlobalScope":true},{"version":"-2676574883-export const World = \"hello\";\r\n","signature":"-9234818176-export declare const World = \"hello\";\n","affectsGlobalScope":false},{"version":"-18749805970-export const someString: string = \"HELLO WORLD\";\r\nexport function leftPad(s: string, n: number) { return s + n; }\r\nexport function multiply(a: number, b: number) { return a * b; }\r\n","signature":"-7362568283-export declare const someString: string;\nexport declare function leftPad(s: string, n: number): string;\nexport declare function multiply(a: number, b: number): number;\n","affectsGlobalScope":false}],"options":{"composite":true,"outDir":"./","watch":true,"configFilePath":"../tsconfig.json"},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}

//// [/user/username/projects/sample1/core/outDir/tsconfig.tsbuildinfo.readable.baseline.txt]
{
"program": {
"fileNames": [
"../../../../../../a/lib/lib.d.ts",
"../anothermodule.ts",
"../index.ts"
],
"fileInfos": {
"../../../../../../a/lib/lib.d.ts": {
"version": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
"signature": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
"affectsGlobalScope": true
},
"../anothermodule.ts": {
"version": "-2676574883-export const World = \"hello\";\r\n",
"signature": "-9234818176-export declare const World = \"hello\";\n",
"affectsGlobalScope": false
},
"../index.ts": {
"version": "-18749805970-export const someString: string = \"HELLO WORLD\";\r\nexport function leftPad(s: string, n: number) { return s + n; }\r\nexport function multiply(a: number, b: number) { return a * b; }\r\n",
"signature": "-7362568283-export declare const someString: string;\nexport declare function leftPad(s: string, n: number): string;\nexport declare function multiply(a: number, b: number): number;\n",
"affectsGlobalScope": false
}
},
"options": {
"composite": true,
"outDir": "./",
"watch": true,
"configFilePath": "../tsconfig.json"
},
"referencedMap": {},
"exportedModulesMap": {},
"semanticDiagnosticsPerFile": [
"../../../../../../a/lib/lib.d.ts",
"../anothermodule.ts",
"../index.ts"
]
},
"version": "FakeTSVersion",
"size": 1681
}


Change:: No change

Expand Down Expand Up @@ -135,15 +178,15 @@ export const y = 10;

Output::
>> Screen clear
[12:00:47 AM] File change detected. Starting incremental compilation...
[12:00:49 AM] File change detected. Starting incremental compilation...

[12:00:48 AM] Project 'sample1/core/tsconfig.json' is out of date because oldest output 'sample1/core/outDir/anotherModule.js' is older than newest input 'sample1/core/file3.ts'
[12:00:50 AM] Project 'sample1/core/tsconfig.json' is out of date because oldest output 'sample1/core/outDir/anotherModule.js' is older than newest input 'sample1/core/file3.ts'

[12:00:49 AM] Building project '/user/username/projects/sample1/core/tsconfig.json'...
[12:00:51 AM] Building project '/user/username/projects/sample1/core/tsconfig.json'...

[12:00:58 AM] Updating unchanged output timestamps of project '/user/username/projects/sample1/core/tsconfig.json'...
[12:01:00 AM] Updating unchanged output timestamps of project '/user/username/projects/sample1/core/tsconfig.json'...

[12:00:59 AM] Found 0 errors. Watching for file changes.
[12:01:04 AM] Found 0 errors. Watching for file changes.



Expand Down Expand Up @@ -184,6 +227,56 @@ exitCode:: ExitStatus.undefined
//// [/user/username/projects/sample1/core/outDir/tsconfig.tsbuildinfo]
{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../anothermodule.ts","../file3.ts","../index.ts"],"fileInfos":[{"version":"-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }","signature":"-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }","affectsGlobalScope":true},{"version":"-2676574883-export const World = \"hello\";\r\n","signature":"-9234818176-export declare const World = \"hello\";\n","affectsGlobalScope":false},{"version":"-13729955264-export const y = 10;","signature":"-7152472870-export declare const y = 10;\n","affectsGlobalScope":false},{"version":"-18749805970-export const someString: string = \"HELLO WORLD\";\r\nexport function leftPad(s: string, n: number) { return s + n; }\r\nexport function multiply(a: number, b: number) { return a * b; }\r\n","signature":"-7362568283-export declare const someString: string;\nexport declare function leftPad(s: string, n: number): string;\nexport declare function multiply(a: number, b: number): number;\n","affectsGlobalScope":false}],"options":{"composite":true,"outDir":"./","watch":true,"configFilePath":"../tsconfig.json"},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3,4]},"version":"FakeTSVersion"}

//// [/user/username/projects/sample1/core/outDir/tsconfig.tsbuildinfo.readable.baseline.txt]
{
"program": {
"fileNames": [
"../../../../../../a/lib/lib.d.ts",
"../anothermodule.ts",
"../file3.ts",
"../index.ts"
],
"fileInfos": {
"../../../../../../a/lib/lib.d.ts": {
"version": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
"signature": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
"affectsGlobalScope": true
},
"../anothermodule.ts": {
"version": "-2676574883-export const World = \"hello\";\r\n",
"signature": "-9234818176-export declare const World = \"hello\";\n",
"affectsGlobalScope": false
},
"../file3.ts": {
"version": "-13729955264-export const y = 10;",
"signature": "-7152472870-export declare const y = 10;\n",
"affectsGlobalScope": false
},
"../index.ts": {
"version": "-18749805970-export const someString: string = \"HELLO WORLD\";\r\nexport function leftPad(s: string, n: number) { return s + n; }\r\nexport function multiply(a: number, b: number) { return a * b; }\r\n",
"signature": "-7362568283-export declare const someString: string;\nexport declare function leftPad(s: string, n: number): string;\nexport declare function multiply(a: number, b: number): number;\n",
"affectsGlobalScope": false
}
},
"options": {
"composite": true,
"outDir": "./",
"watch": true,
"configFilePath": "../tsconfig.json"
},
"referencedMap": {},
"exportedModulesMap": {},
"semanticDiagnosticsPerFile": [
"../../../../../../a/lib/lib.d.ts",
"../anothermodule.ts",
"../file3.ts",
"../index.ts"
]
},
"version": "FakeTSVersion",
"size": 1829
}

//// [/user/username/projects/sample1/core/outDir/file3.js]
"use strict";
exports.__esModule = true;
Expand Down
Loading