Skip to content

Commit 832a6e4

Browse files
authored
Unify verifyTsc and verifyTscWithEdits and make them look like verifyTscWatch for easy copy paste (#51798)
* Make edits optional in verifyTscWatch * Unify verifyTsc and verifyTscWithEdits and make them look like verifyTscWatch
1 parent e0293b5 commit 832a6e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+860
-918
lines changed

src/testRunner/unittests/tsbuild/amdModulesWithOut.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
removeRest,
1313
replaceText,
1414
verifyTsc,
15-
verifyTscWithEdits,
1615
} from "../tsc/helpers";
1716

1817
describe("unittests:: tsbuild:: outFile:: on amd modules with --out", () => {
@@ -35,7 +34,7 @@ describe("unittests:: tsbuild:: outFile:: on amd modules with --out", () => {
3534
modifyFs,
3635
modifyAgainFs
3736
}: VerifyOutFileScenarioInput) {
38-
verifyTscWithEdits({
37+
verifyTsc({
3938
scenario: "amdModulesWithOut",
4039
subScenario,
4140
fs: () => outFileFs,
@@ -44,12 +43,12 @@ describe("unittests:: tsbuild:: outFile:: on amd modules with --out", () => {
4443
modifyFs,
4544
edits: [
4645
{
47-
subScenario: "incremental-declaration-doesnt-change",
48-
modifyFs: fs => appendText(fs, "/src/lib/file1.ts", "console.log(x);")
46+
caption: "incremental-declaration-doesnt-change",
47+
edit: fs => appendText(fs, "/src/lib/file1.ts", "console.log(x);")
4948
},
5049
...(modifyAgainFs ? [{
51-
subScenario: "incremental-headers-change-without-dts-changes",
52-
modifyFs: modifyAgainFs
50+
caption: "incremental-headers-change-without-dts-changes",
51+
edit: modifyAgainFs
5352
}] : ts.emptyArray),
5453
]
5554
});

src/testRunner/unittests/tsbuild/commandLine.ts

+88-88
Large diffs are not rendered by default.

src/testRunner/unittests/tsbuild/configFileErrors.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
noChangeRun,
66
replaceText,
77
verifyTsc,
8-
verifyTscWithEdits,
98
} from "../tsc/helpers";
109
import { dedent } from "../../_namespaces/Utils";
1110

@@ -19,7 +18,7 @@ describe("unittests:: tsbuild:: configFileErrors:: when tsconfig extends the mis
1918
});
2019

2120
describe("unittests:: tsbuild:: configFileErrors:: reports syntax errors in config file", () => {
22-
verifyTscWithEdits({
21+
verifyTsc({
2322
scenario: "configFileErrors",
2423
subScenario: "reports syntax errors in config file",
2524
fs: () => loadProjectFromFiles({
@@ -39,28 +38,28 @@ describe("unittests:: tsbuild:: configFileErrors:: reports syntax errors in conf
3938
commandLineArgs: ["--b", "/src/tsconfig.json"],
4039
edits: [
4140
{
42-
modifyFs: fs => replaceText(fs, "/src/tsconfig.json", ",", `,
41+
edit: fs => replaceText(fs, "/src/tsconfig.json", ",", `,
4342
"declaration": true,`),
44-
subScenario: "reports syntax errors after change to config file",
43+
caption: "reports syntax errors after change to config file",
4544
discrepancyExplanation: () => [
4645
"During incremental build, tsbuildinfo is not emitted, so declaration option is not present",
4746
"Clean build has declaration option in tsbuildinfo",
4847
],
4948
},
5049
{
51-
modifyFs: fs => appendText(fs, "/src/a.ts", "export function fooBar() { }"),
52-
subScenario: "reports syntax errors after change to ts file",
50+
edit: fs => appendText(fs, "/src/a.ts", "export function fooBar() { }"),
51+
caption: "reports syntax errors after change to ts file",
5352
},
5453
noChangeRun,
5554
{
56-
modifyFs: fs => fs.writeFileSync(
55+
edit: fs => fs.writeFileSync(
5756
"/src/tsconfig.json",
5857
JSON.stringify({
5958
compilerOptions: { composite: true, declaration: true },
6059
files: ["a.ts", "b.ts"]
6160
})
6261
),
63-
subScenario: "builds after fixing config file errors"
62+
caption: "builds after fixing config file errors"
6463
},
6564
]
6665
});

src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import {
33
loadProjectFromFiles,
44
noChangeOnlyRuns,
55
replaceText,
6-
verifyTscWithEdits,
6+
verifyTsc,
77
} from "../tsc/helpers";
88

99
describe("unittests:: tsbuild:: when containerOnly project is referenced", () => {
10-
verifyTscWithEdits({
10+
verifyTsc({
1111
scenario: "containerOnlyReferenced",
1212
subScenario: "verify that subsequent builds after initial build doesnt build anything",
1313
fs: () => loadProjectFromDisk("tests/projects/containerOnlyReferenced"),
1414
commandLineArgs: ["--b", "/src", "--verbose"],
1515
edits: noChangeOnlyRuns
1616
});
1717

18-
verifyTscWithEdits({
18+
verifyTsc({
1919
scenario: "containerOnlyReferenced",
2020
subScenario: "when solution is referenced indirectly",
2121
fs: () => loadProjectFromFiles({
@@ -41,8 +41,8 @@ describe("unittests:: tsbuild:: when containerOnly project is referenced", () =>
4141
}),
4242
commandLineArgs: ["--b", "/src/project4", "--verbose", "--explainFiles"],
4343
edits: [{
44-
subScenario: "modify project3 file",
45-
modifyFs: fs => replaceText(fs, "/src/project3/src/c.ts", "c = ", "cc = "),
44+
caption: "modify project3 file",
45+
edit: fs => replaceText(fs, "/src/project3/src/c.ts", "c = ", "cc = "),
4646
}],
4747
});
4848
});

src/testRunner/unittests/tsbuild/emitDeclarationOnly.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as vfs from "../../_namespaces/vfs";
22
import {
33
loadProjectFromDisk,
44
replaceText,
5-
verifyTscWithEdits,
5+
verifyTsc,
66
} from "../tsc/helpers";
77

88
describe("unittests:: tsbuild:: on project with emitDeclarationOnly set to true", () => {
@@ -15,7 +15,7 @@ describe("unittests:: tsbuild:: on project with emitDeclarationOnly set to true"
1515
});
1616

1717
function verifyEmitDeclarationOnly(disableMap?: true) {
18-
verifyTscWithEdits({
18+
verifyTsc({
1919
subScenario: `only dts output in circular import project with emitDeclarationOnly${disableMap ? "" : " and declarationMap"}`,
2020
fs: () => projFs,
2121
scenario: "emitDeclarationOnly",
@@ -24,15 +24,15 @@ describe("unittests:: tsbuild:: on project with emitDeclarationOnly set to true"
2424
(fs => replaceText(fs, "/src/tsconfig.json", `"declarationMap": true,`, "")) :
2525
undefined,
2626
edits: [{
27-
subScenario: "incremental-declaration-changes",
28-
modifyFs: fs => replaceText(fs, "/src/src/a.ts", "b: B;", "b: B; foo: any;"),
27+
caption: "incremental-declaration-changes",
28+
edit: fs => replaceText(fs, "/src/src/a.ts", "b: B;", "b: B; foo: any;"),
2929
}],
3030
});
3131
}
3232
verifyEmitDeclarationOnly();
3333
verifyEmitDeclarationOnly(/*disableMap*/ true);
3434

35-
verifyTscWithEdits({
35+
verifyTsc({
3636
subScenario: `only dts output in non circular imports project with emitDeclarationOnly`,
3737
fs: () => projFs,
3838
scenario: "emitDeclarationOnly",
@@ -43,14 +43,14 @@ describe("unittests:: tsbuild:: on project with emitDeclarationOnly set to true"
4343
},
4444
edits: [
4545
{
46-
subScenario: "incremental-declaration-doesnt-change",
47-
modifyFs: fs => replaceText(fs, "/src/src/a.ts", "export interface A {", `class C { }
46+
caption: "incremental-declaration-doesnt-change",
47+
edit: fs => replaceText(fs, "/src/src/a.ts", "export interface A {", `class C { }
4848
export interface A {`),
4949

5050
},
5151
{
52-
subScenario: "incremental-declaration-changes",
53-
modifyFs: fs => replaceText(fs, "/src/src/a.ts", "b: B;", "b: B; foo: any;"),
52+
caption: "incremental-declaration-changes",
53+
edit: fs => replaceText(fs, "/src/src/a.ts", "b: B;", "b: B; foo: any;"),
5454
},
5555
],
5656
});

src/testRunner/unittests/tsbuild/inferredTypeFromTransitiveModule.ts

+20-20
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
appendText,
44
loadProjectFromDisk,
55
replaceText,
6-
verifyTscWithEdits,
6+
verifyTsc,
77
} from "../tsc/helpers";
88

99
describe("unittests:: tsbuild:: inferredTypeFromTransitiveModule::", () => {
@@ -15,42 +15,42 @@ describe("unittests:: tsbuild:: inferredTypeFromTransitiveModule::", () => {
1515
projFs = undefined!;
1616
});
1717

18-
verifyTscWithEdits({
18+
verifyTsc({
1919
scenario: "inferredTypeFromTransitiveModule",
2020
subScenario: "inferred type from transitive module",
2121
fs: () => projFs,
2222
commandLineArgs: ["--b", "/src", "--verbose"],
2323
edits: [
2424
{
25-
subScenario: "incremental-declaration-changes",
26-
modifyFs: changeBarParam,
25+
caption: "incremental-declaration-changes",
26+
edit: changeBarParam,
2727
},
2828
{
29-
subScenario: "incremental-declaration-changes",
30-
modifyFs: changeBarParamBack,
29+
caption: "incremental-declaration-changes",
30+
edit: changeBarParamBack,
3131
},
3232
],
3333
});
3434

35-
verifyTscWithEdits({
35+
verifyTsc({
3636
subScenario: "inferred type from transitive module with isolatedModules",
3737
fs: () => projFs,
3838
scenario: "inferredTypeFromTransitiveModule",
3939
commandLineArgs: ["--b", "/src", "--verbose"],
4040
modifyFs: changeToIsolatedModules,
4141
edits: [
4242
{
43-
subScenario: "incremental-declaration-changes",
44-
modifyFs: changeBarParam
43+
caption: "incremental-declaration-changes",
44+
edit: changeBarParam
4545
},
4646
{
47-
subScenario: "incremental-declaration-changes",
48-
modifyFs: changeBarParamBack,
47+
caption: "incremental-declaration-changes",
48+
edit: changeBarParamBack,
4949
},
5050
]
5151
});
5252

53-
verifyTscWithEdits({
53+
verifyTsc({
5454
scenario: "inferredTypeFromTransitiveModule",
5555
subScenario: "reports errors in files affected by change in signature with isolatedModules",
5656
fs: () => projFs,
@@ -63,20 +63,20 @@ bar("hello");`);
6363
},
6464
edits: [
6565
{
66-
subScenario: "incremental-declaration-changes",
67-
modifyFs: changeBarParam
66+
caption: "incremental-declaration-changes",
67+
edit: changeBarParam
6868
},
6969
{
70-
subScenario: "incremental-declaration-changes",
71-
modifyFs: changeBarParamBack,
70+
caption: "incremental-declaration-changes",
71+
edit: changeBarParamBack,
7272
},
7373
{
74-
subScenario: "incremental-declaration-changes",
75-
modifyFs: changeBarParam
74+
caption: "incremental-declaration-changes",
75+
edit: changeBarParam
7676
},
7777
{
78-
subScenario: "Fix Error",
79-
modifyFs: fs => replaceText(fs, "/src/lazyIndex.ts", `bar("hello")`, "bar()")
78+
caption: "Fix Error",
79+
edit: fs => replaceText(fs, "/src/lazyIndex.ts", `bar("hello")`, "bar()")
8080
},
8181
]
8282
});

src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
replaceText,
55
symbolLibContent,
66
verifyTsc,
7-
verifyTscWithEdits,
87
} from "../tsc/helpers";
98

109
describe("unittests:: tsbuild:: javascriptProjectEmit::", () => {
@@ -96,7 +95,7 @@ describe("unittests:: tsbuild:: javascriptProjectEmit::", () => {
9695
commandLineArgs: ["-b", "/src"]
9796
});
9897

99-
verifyTscWithEdits({
98+
verifyTsc({
10099
scenario: "javascriptProjectEmit",
101100
subScenario: `modifies outfile js projects and concatenates them correctly`,
102101
fs: () => loadProjectFromFiles({
@@ -185,8 +184,8 @@ describe("unittests:: tsbuild:: javascriptProjectEmit::", () => {
185184
}, symbolLibContent),
186185
commandLineArgs: ["-b", "/src"],
187186
edits: [{
188-
subScenario: "incremental-declaration-doesnt-change",
189-
modifyFs: fs => replaceText(fs, "/src/sub-project/index.js", "null", "undefined")
187+
caption: "incremental-declaration-doesnt-change",
188+
edit: fs => replaceText(fs, "/src/sub-project/index.js", "null", "undefined")
190189
}]
191190
});
192191

src/testRunner/unittests/tsbuild/lateBoundSymbol.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ import {
22
appendText,
33
loadProjectFromDisk,
44
replaceText,
5-
verifyTscWithEdits,
5+
verifyTsc,
66
} from "../tsc/helpers";
77

88
describe("unittests:: tsbuild:: lateBoundSymbol:: interface is merged and contains late bound member", () => {
9-
verifyTscWithEdits({
9+
verifyTsc({
1010
subScenario: "interface is merged and contains late bound member",
1111
fs: () => loadProjectFromDisk("tests/projects/lateBoundSymbol"),
1212
scenario: "lateBoundSymbol",
1313
commandLineArgs: ["--b", "/src/tsconfig.json", "--verbose"],
1414
edits: [
1515
{
16-
subScenario: "incremental-declaration-doesnt-change",
17-
modifyFs: fs => replaceText(fs, "/src/src/main.ts", "const x = 10;", ""),
16+
caption: "incremental-declaration-doesnt-change",
17+
edit: fs => replaceText(fs, "/src/src/main.ts", "const x = 10;", ""),
1818
},
1919
{
20-
subScenario: "incremental-declaration-doesnt-change",
21-
modifyFs: fs => appendText(fs, "/src/src/main.ts", "const x = 10;"),
20+
caption: "incremental-declaration-doesnt-change",
21+
edit: fs => appendText(fs, "/src/src/main.ts", "const x = 10;"),
2222
},
2323
]
2424
});

src/testRunner/unittests/tsbuild/moduleResolution.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
loadProjectFromFiles,
99
noChangeOnlyRuns,
1010
verifyTsc,
11-
verifyTscWithEdits,
1211
} from "../tsc/helpers";
1312
import { verifyTscWatch } from "../tscWatch/helpers";
1413

@@ -68,15 +67,13 @@ describe("unittests:: tsbuild:: moduleResolution:: handles the modules and optio
6867
subScenario: `resolves specifier in output declaration file from referenced project correctly`,
6968
sys,
7069
commandLineArgs: ["-b", "packages/pkg1", "--verbose", "--traceResolution"],
71-
changes: ts.emptyArray
7270
});
7371

7472
verifyTscWatch({
7573
scenario: "moduleResolution",
7674
subScenario: `resolves specifier in output declaration file from referenced project correctly with preserveSymlinks`,
7775
sys: () => sys({ preserveSymlinks: true }),
7876
commandLineArgs: ["-b", "packages/pkg1", "--verbose", "--traceResolution"],
79-
changes: ts.emptyArray
8077
});
8178

8279
verifyTsc({
@@ -101,7 +98,7 @@ describe("unittests:: tsbuild:: moduleResolution:: handles the modules and optio
10198
});
10299

103100
describe("unittests:: tsbuild:: moduleResolution:: impliedNodeFormat differs between projects for shared file", () => {
104-
verifyTscWithEdits({
101+
verifyTsc({
105102
scenario: "moduleResolution",
106103
subScenario: "impliedNodeFormat differs between projects for shared file",
107104
fs: () => loadProjectFromFiles({

src/testRunner/unittests/tsbuild/noEmit.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {
22
loadProjectFromFiles,
33
noChangeRun,
4-
verifyTscWithEdits,
4+
verifyTsc,
55
} from "../tsc/helpers";
66

77
describe("unittests:: tsbuild:: noEmit", () => {
88
function verifyNoEmitWorker(subScenario: string, aTsContent: string, commandLineArgs: readonly string[]) {
9-
verifyTscWithEdits({
9+
verifyTsc({
1010
scenario: "noEmit",
1111
subScenario,
1212
fs: () => loadProjectFromFiles({
@@ -19,8 +19,8 @@ describe("unittests:: tsbuild:: noEmit", () => {
1919
edits: [
2020
noChangeRun,
2121
{
22-
subScenario: "Fix error",
23-
modifyFs: fs => fs.writeFileSync("/src/a.ts", `const a = "hello"`),
22+
caption: "Fix error",
23+
edit: fs => fs.writeFileSync("/src/a.ts", `const a = "hello"`),
2424
},
2525
noChangeRun,
2626
],

0 commit comments

Comments
 (0)