Skip to content

Commit

Permalink
Test consecutive incremental invocations with seperate file lists
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Jul 8, 2022
1 parent 28dc248 commit bc301f6
Show file tree
Hide file tree
Showing 3 changed files with 250 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/testRunner/unittests/tsc/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,31 @@ ${patch ? vfs.formatPatch(patch) : ""}`
/**
* Verify by baselining after initializing FS and command line compile
*/
export function verifyTsc(input: TestTscCompile) {
export function verifyTsc(input: TestTscCompile) {
verifyTscCompileLike(testTscCompile, input);
}

export function verifyMultiTsc(input: TestTscCompile & {nextArgs: TestTscCompile["commandLineArgs"]}) {
describe(`tsc ${input.commandLineArgs.join(" ")} ${input.scenario}:: ${input.subScenario}`, () => {
describe(input.scenario, () => {
describe(input.subScenario, () => {
it(`Generates files matching the baseline`, () => {
const result = testTscCompile({
...input,
fs: () => input.fs().makeReadonly()
});
const { file, text } = result.baseLine();

const { file: _, text: second } = testTscCompile({
...input,
commandLineArgs: input.nextArgs,
fs: () => result.vfs.makeReadonly()
}).baseLine();

Harness.Baseline.runBaseline(file, text + "\n\nnext:\n\n" + second);
});
});
});
});
}
}
14 changes: 14 additions & 0 deletions src/testRunner/unittests/tscWatch/incremental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,5 +374,19 @@ export const Fragment: unique symbol;
},
});
});

describe("invoking tsc multiple times with seperate arguments", () => {
verifyMultiTsc({
scenario: "commandLineOverridesConfig",
subScenario: "incremental build across multiple invocations invalidate buildinfo",
fs: () => loadProjectFromFiles({
"/src/project/src/main.ts": "export const x = 10;",
"/src/project/src/file.ts": "export const y: string = undefined;",
}),
commandLineArgs: ["--incremental", "--tsBuildInfoFile", ".tsbuildinfo", "--strict", "src/project/src/main.ts"],
environmentVariables: {},
nextArgs: ["--incremental", "--tsBuildInfoFile", ".tsbuildinfo", "--strict", "src/project/src/file.ts"]
});
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
Input::
//// [/lib/lib.d.ts]
/// <reference no-default-lib="true"/>
interface Boolean {}
interface Function {}
interface CallableFunction {}
interface NewableFunction {}
interface IArguments {}
interface Number { toExponential: any; }
interface Object {}
interface RegExp {}
interface String { charAt: any; }
interface Array<T> { length: number; [n: number]: T; }
interface ReadonlyArray<T> {}
declare const console: { log(msg: any): void; };

//// [/src/project/src/file.ts]
export const y: string = undefined;

//// [/src/project/src/main.ts]
export const x = 10;



Output::
/lib/tsc --incremental --tsBuildInfoFile .tsbuildinfo --strict src/project/src/main.ts
exitCode:: ExitStatus.Success


//// [/.tsbuildinfo]
{"program":{"fileNames":["./lib/lib.d.ts","./src/project/src/main.ts"],"fileInfos":[{"version":"3858781397-/// <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; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-10726455937-export const x = 10;"],"options":{"strict":true,"tsBuildInfoFile":"./.tsbuildinfo"},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2]},"version":"FakeTSVersion"}

//// [/.tsbuildinfo.readable.baseline.txt]
{
"program": {
"fileNames": [
"./lib/lib.d.ts",
"./src/project/src/main.ts"
],
"fileInfos": {
"./lib/lib.d.ts": {
"version": "3858781397-/// <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; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"signature": "3858781397-/// <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; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"affectsGlobalScope": true
},
"./src/project/src/main.ts": {
"version": "-10726455937-export const x = 10;",
"signature": "-10726455937-export const x = 10;"
}
},
"options": {
"strict": true,
"tsBuildInfoFile": "./.tsbuildinfo"
},
"referencedMap": {},
"exportedModulesMap": {},
"semanticDiagnosticsPerFile": [
"./lib/lib.d.ts",
"./src/project/src/main.ts"
]
},
"version": "FakeTSVersion",
"size": 766
}

//// [/src/project/src/main.js]
"use strict";
exports.__esModule = true;
exports.x = void 0;
exports.x = 10;




next:

Input::
//// [/.tsbuildinfo]
{"program":{"fileNames":["./lib/lib.d.ts","./src/project/src/main.ts"],"fileInfos":[{"version":"3858781397-/// <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; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-10726455937-export const x = 10;"],"options":{"strict":true,"tsBuildInfoFile":"./.tsbuildinfo"},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2]},"version":"FakeTSVersion"}

//// [/.tsbuildinfo.readable.baseline.txt]
{
"program": {
"fileNames": [
"./lib/lib.d.ts",
"./src/project/src/main.ts"
],
"fileInfos": {
"./lib/lib.d.ts": {
"version": "3858781397-/// <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; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"signature": "3858781397-/// <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; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"affectsGlobalScope": true
},
"./src/project/src/main.ts": {
"version": "-10726455937-export const x = 10;",
"signature": "-10726455937-export const x = 10;"
}
},
"options": {
"strict": true,
"tsBuildInfoFile": "./.tsbuildinfo"
},
"referencedMap": {},
"exportedModulesMap": {},
"semanticDiagnosticsPerFile": [
"./lib/lib.d.ts",
"./src/project/src/main.ts"
]
},
"version": "FakeTSVersion",
"size": 766
}

//// [/lib/lib.d.ts]
/// <reference no-default-lib="true"/>
interface Boolean {}
interface Function {}
interface CallableFunction {}
interface NewableFunction {}
interface IArguments {}
interface Number { toExponential: any; }
interface Object {}
interface RegExp {}
interface String { charAt: any; }
interface Array<T> { length: number; [n: number]: T; }
interface ReadonlyArray<T> {}
declare const console: { log(msg: any): void; };

//// [/src/project/src/file.ts]
export const y: string = undefined;

//// [/src/project/src/main.js]
"use strict";
exports.__esModule = true;
exports.x = void 0;
exports.x = 10;


//// [/src/project/src/main.ts]
export const x = 10;



Output::
/lib/tsc --incremental --tsBuildInfoFile .tsbuildinfo --strict src/project/src/file.ts
src/project/src/file.ts:1:14 - error TS2322: Type 'undefined' is not assignable to type 'string'.

1 export const y: string = undefined;
   ~


Found 1 error in src/project/src/file.ts:1

exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated


//// [/.tsbuildinfo]
{"program":{"fileNames":["./lib/lib.d.ts","./src/project/src/file.ts"],"fileInfos":[{"version":"3858781397-/// <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; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"-14519709726-export const y: string = undefined;","signature":"-8102077254-export declare const y: string;\r\n"}],"options":{"strict":true,"tsBuildInfoFile":"./.tsbuildinfo"},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,[2,[{"file":"./src/project/src/file.ts","start":13,"length":1,"code":2322,"category":1,"messageText":"Type 'undefined' is not assignable to type 'string'."}]]]},"version":"FakeTSVersion"}

//// [/.tsbuildinfo.readable.baseline.txt]
{
"program": {
"fileNames": [
"./lib/lib.d.ts",
"./src/project/src/file.ts"
],
"fileInfos": {
"./lib/lib.d.ts": {
"version": "3858781397-/// <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; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"signature": "3858781397-/// <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; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"affectsGlobalScope": true
},
"./src/project/src/file.ts": {
"version": "-14519709726-export const y: string = undefined;",
"signature": "-8102077254-export declare const y: string;\r\n"
}
},
"options": {
"strict": true,
"tsBuildInfoFile": "./.tsbuildinfo"
},
"referencedMap": {},
"exportedModulesMap": {},
"semanticDiagnosticsPerFile": [
"./lib/lib.d.ts",
[
"./src/project/src/file.ts",
[
{
"file": "./src/project/src/file.ts",
"start": 13,
"length": 1,
"code": 2322,
"category": 1,
"messageText": "Type 'undefined' is not assignable to type 'string'."
}
]
]
]
},
"version": "FakeTSVersion",
"size": 1012
}

//// [/src/project/src/file.js]
"use strict";
exports.__esModule = true;
exports.y = void 0;
exports.y = undefined;


0 comments on commit bc301f6

Please sign in to comment.