Skip to content

Commit bc301f6

Browse files
committed
Test consecutive incremental invocations with seperate file lists
1 parent 28dc248 commit bc301f6

File tree

3 files changed

+250
-1
lines changed

3 files changed

+250
-1
lines changed

src/testRunner/unittests/tsc/helpers.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,31 @@ ${patch ? vfs.formatPatch(patch) : ""}`
237237
/**
238238
* Verify by baselining after initializing FS and command line compile
239239
*/
240-
export function verifyTsc(input: TestTscCompile) {
240+
export function verifyTsc(input: TestTscCompile) {
241241
verifyTscCompileLike(testTscCompile, input);
242242
}
243+
244+
export function verifyMultiTsc(input: TestTscCompile & {nextArgs: TestTscCompile["commandLineArgs"]}) {
245+
describe(`tsc ${input.commandLineArgs.join(" ")} ${input.scenario}:: ${input.subScenario}`, () => {
246+
describe(input.scenario, () => {
247+
describe(input.subScenario, () => {
248+
it(`Generates files matching the baseline`, () => {
249+
const result = testTscCompile({
250+
...input,
251+
fs: () => input.fs().makeReadonly()
252+
});
253+
const { file, text } = result.baseLine();
254+
255+
const { file: _, text: second } = testTscCompile({
256+
...input,
257+
commandLineArgs: input.nextArgs,
258+
fs: () => result.vfs.makeReadonly()
259+
}).baseLine();
260+
261+
Harness.Baseline.runBaseline(file, text + "\n\nnext:\n\n" + second);
262+
});
263+
});
264+
});
265+
});
266+
}
243267
}

src/testRunner/unittests/tscWatch/incremental.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,5 +374,19 @@ export const Fragment: unique symbol;
374374
},
375375
});
376376
});
377+
378+
describe("invoking tsc multiple times with seperate arguments", () => {
379+
verifyMultiTsc({
380+
scenario: "commandLineOverridesConfig",
381+
subScenario: "incremental build across multiple invocations invalidate buildinfo",
382+
fs: () => loadProjectFromFiles({
383+
"/src/project/src/main.ts": "export const x = 10;",
384+
"/src/project/src/file.ts": "export const y: string = undefined;",
385+
}),
386+
commandLineArgs: ["--incremental", "--tsBuildInfoFile", ".tsbuildinfo", "--strict", "src/project/src/main.ts"],
387+
environmentVariables: {},
388+
nextArgs: ["--incremental", "--tsBuildInfoFile", ".tsbuildinfo", "--strict", "src/project/src/file.ts"]
389+
});
390+
});
377391
});
378392
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
Input::
2+
//// [/lib/lib.d.ts]
3+
/// <reference no-default-lib="true"/>
4+
interface Boolean {}
5+
interface Function {}
6+
interface CallableFunction {}
7+
interface NewableFunction {}
8+
interface IArguments {}
9+
interface Number { toExponential: any; }
10+
interface Object {}
11+
interface RegExp {}
12+
interface String { charAt: any; }
13+
interface Array<T> { length: number; [n: number]: T; }
14+
interface ReadonlyArray<T> {}
15+
declare const console: { log(msg: any): void; };
16+
17+
//// [/src/project/src/file.ts]
18+
export const y: string = undefined;
19+
20+
//// [/src/project/src/main.ts]
21+
export const x = 10;
22+
23+
24+
25+
Output::
26+
/lib/tsc --incremental --tsBuildInfoFile .tsbuildinfo --strict src/project/src/main.ts
27+
exitCode:: ExitStatus.Success
28+
29+
30+
//// [/.tsbuildinfo]
31+
{"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"}
32+
33+
//// [/.tsbuildinfo.readable.baseline.txt]
34+
{
35+
"program": {
36+
"fileNames": [
37+
"./lib/lib.d.ts",
38+
"./src/project/src/main.ts"
39+
],
40+
"fileInfos": {
41+
"./lib/lib.d.ts": {
42+
"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; };",
43+
"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; };",
44+
"affectsGlobalScope": true
45+
},
46+
"./src/project/src/main.ts": {
47+
"version": "-10726455937-export const x = 10;",
48+
"signature": "-10726455937-export const x = 10;"
49+
}
50+
},
51+
"options": {
52+
"strict": true,
53+
"tsBuildInfoFile": "./.tsbuildinfo"
54+
},
55+
"referencedMap": {},
56+
"exportedModulesMap": {},
57+
"semanticDiagnosticsPerFile": [
58+
"./lib/lib.d.ts",
59+
"./src/project/src/main.ts"
60+
]
61+
},
62+
"version": "FakeTSVersion",
63+
"size": 766
64+
}
65+
66+
//// [/src/project/src/main.js]
67+
"use strict";
68+
exports.__esModule = true;
69+
exports.x = void 0;
70+
exports.x = 10;
71+
72+
73+
74+
75+
next:
76+
77+
Input::
78+
//// [/.tsbuildinfo]
79+
{"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"}
80+
81+
//// [/.tsbuildinfo.readable.baseline.txt]
82+
{
83+
"program": {
84+
"fileNames": [
85+
"./lib/lib.d.ts",
86+
"./src/project/src/main.ts"
87+
],
88+
"fileInfos": {
89+
"./lib/lib.d.ts": {
90+
"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; };",
91+
"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; };",
92+
"affectsGlobalScope": true
93+
},
94+
"./src/project/src/main.ts": {
95+
"version": "-10726455937-export const x = 10;",
96+
"signature": "-10726455937-export const x = 10;"
97+
}
98+
},
99+
"options": {
100+
"strict": true,
101+
"tsBuildInfoFile": "./.tsbuildinfo"
102+
},
103+
"referencedMap": {},
104+
"exportedModulesMap": {},
105+
"semanticDiagnosticsPerFile": [
106+
"./lib/lib.d.ts",
107+
"./src/project/src/main.ts"
108+
]
109+
},
110+
"version": "FakeTSVersion",
111+
"size": 766
112+
}
113+
114+
//// [/lib/lib.d.ts]
115+
/// <reference no-default-lib="true"/>
116+
interface Boolean {}
117+
interface Function {}
118+
interface CallableFunction {}
119+
interface NewableFunction {}
120+
interface IArguments {}
121+
interface Number { toExponential: any; }
122+
interface Object {}
123+
interface RegExp {}
124+
interface String { charAt: any; }
125+
interface Array<T> { length: number; [n: number]: T; }
126+
interface ReadonlyArray<T> {}
127+
declare const console: { log(msg: any): void; };
128+
129+
//// [/src/project/src/file.ts]
130+
export const y: string = undefined;
131+
132+
//// [/src/project/src/main.js]
133+
"use strict";
134+
exports.__esModule = true;
135+
exports.x = void 0;
136+
exports.x = 10;
137+
138+
139+
//// [/src/project/src/main.ts]
140+
export const x = 10;
141+
142+
143+
144+
Output::
145+
/lib/tsc --incremental --tsBuildInfoFile .tsbuildinfo --strict src/project/src/file.ts
146+
src/project/src/file.ts:1:14 - error TS2322: Type 'undefined' is not assignable to type 'string'.
147+
148+
1 export const y: string = undefined;
149+
   ~
150+
151+
152+
Found 1 error in src/project/src/file.ts:1
153+
154+
exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated
155+
156+
157+
//// [/.tsbuildinfo]
158+
{"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"}
159+
160+
//// [/.tsbuildinfo.readable.baseline.txt]
161+
{
162+
"program": {
163+
"fileNames": [
164+
"./lib/lib.d.ts",
165+
"./src/project/src/file.ts"
166+
],
167+
"fileInfos": {
168+
"./lib/lib.d.ts": {
169+
"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; };",
170+
"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; };",
171+
"affectsGlobalScope": true
172+
},
173+
"./src/project/src/file.ts": {
174+
"version": "-14519709726-export const y: string = undefined;",
175+
"signature": "-8102077254-export declare const y: string;\r\n"
176+
}
177+
},
178+
"options": {
179+
"strict": true,
180+
"tsBuildInfoFile": "./.tsbuildinfo"
181+
},
182+
"referencedMap": {},
183+
"exportedModulesMap": {},
184+
"semanticDiagnosticsPerFile": [
185+
"./lib/lib.d.ts",
186+
[
187+
"./src/project/src/file.ts",
188+
[
189+
{
190+
"file": "./src/project/src/file.ts",
191+
"start": 13,
192+
"length": 1,
193+
"code": 2322,
194+
"category": 1,
195+
"messageText": "Type 'undefined' is not assignable to type 'string'."
196+
}
197+
]
198+
]
199+
]
200+
},
201+
"version": "FakeTSVersion",
202+
"size": 1012
203+
}
204+
205+
//// [/src/project/src/file.js]
206+
"use strict";
207+
exports.__esModule = true;
208+
exports.y = void 0;
209+
exports.y = undefined;
210+
211+

0 commit comments

Comments
 (0)