Skip to content

Unify verifyTsc and verifyTscWithEdits and make them look like verifyTscWatch for easy copy paste #51798

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 3 commits into from
Dec 7, 2022
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
11 changes: 5 additions & 6 deletions src/testRunner/unittests/tsbuild/amdModulesWithOut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
removeRest,
replaceText,
verifyTsc,
verifyTscWithEdits,
} from "../tsc/helpers";

describe("unittests:: tsbuild:: outFile:: on amd modules with --out", () => {
Expand All @@ -35,7 +34,7 @@ describe("unittests:: tsbuild:: outFile:: on amd modules with --out", () => {
modifyFs,
modifyAgainFs
}: VerifyOutFileScenarioInput) {
verifyTscWithEdits({
verifyTsc({
scenario: "amdModulesWithOut",
subScenario,
fs: () => outFileFs,
Expand All @@ -44,12 +43,12 @@ describe("unittests:: tsbuild:: outFile:: on amd modules with --out", () => {
modifyFs,
edits: [
{
subScenario: "incremental-declaration-doesnt-change",
modifyFs: fs => appendText(fs, "/src/lib/file1.ts", "console.log(x);")
caption: "incremental-declaration-doesnt-change",
edit: fs => appendText(fs, "/src/lib/file1.ts", "console.log(x);")
},
...(modifyAgainFs ? [{
subScenario: "incremental-headers-change-without-dts-changes",
modifyFs: modifyAgainFs
caption: "incremental-headers-change-without-dts-changes",
edit: modifyAgainFs
}] : ts.emptyArray),
]
});
Expand Down
176 changes: 88 additions & 88 deletions src/testRunner/unittests/tsbuild/commandLine.ts

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions src/testRunner/unittests/tsbuild/configFileErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
noChangeRun,
replaceText,
verifyTsc,
verifyTscWithEdits,
} from "../tsc/helpers";
import { dedent } from "../../_namespaces/Utils";

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

describe("unittests:: tsbuild:: configFileErrors:: reports syntax errors in config file", () => {
verifyTscWithEdits({
verifyTsc({
scenario: "configFileErrors",
subScenario: "reports syntax errors in config file",
fs: () => loadProjectFromFiles({
Expand All @@ -39,28 +38,28 @@ describe("unittests:: tsbuild:: configFileErrors:: reports syntax errors in conf
commandLineArgs: ["--b", "/src/tsconfig.json"],
edits: [
{
modifyFs: fs => replaceText(fs, "/src/tsconfig.json", ",", `,
edit: fs => replaceText(fs, "/src/tsconfig.json", ",", `,
"declaration": true,`),
subScenario: "reports syntax errors after change to config file",
caption: "reports syntax errors after change to config file",
discrepancyExplanation: () => [
"During incremental build, tsbuildinfo is not emitted, so declaration option is not present",
"Clean build has declaration option in tsbuildinfo",
],
},
{
modifyFs: fs => appendText(fs, "/src/a.ts", "export function fooBar() { }"),
subScenario: "reports syntax errors after change to ts file",
edit: fs => appendText(fs, "/src/a.ts", "export function fooBar() { }"),
caption: "reports syntax errors after change to ts file",
},
noChangeRun,
{
modifyFs: fs => fs.writeFileSync(
edit: fs => fs.writeFileSync(
"/src/tsconfig.json",
JSON.stringify({
compilerOptions: { composite: true, declaration: true },
files: ["a.ts", "b.ts"]
})
),
subScenario: "builds after fixing config file errors"
caption: "builds after fixing config file errors"
},
]
});
Expand Down
10 changes: 5 additions & 5 deletions src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import {
loadProjectFromFiles,
noChangeOnlyRuns,
replaceText,
verifyTscWithEdits,
verifyTsc,
} from "../tsc/helpers";

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

verifyTscWithEdits({
verifyTsc({
scenario: "containerOnlyReferenced",
subScenario: "when solution is referenced indirectly",
fs: () => loadProjectFromFiles({
Expand All @@ -41,8 +41,8 @@ describe("unittests:: tsbuild:: when containerOnly project is referenced", () =>
}),
commandLineArgs: ["--b", "/src/project4", "--verbose", "--explainFiles"],
edits: [{
subScenario: "modify project3 file",
modifyFs: fs => replaceText(fs, "/src/project3/src/c.ts", "c = ", "cc = "),
caption: "modify project3 file",
edit: fs => replaceText(fs, "/src/project3/src/c.ts", "c = ", "cc = "),
}],
});
});
18 changes: 9 additions & 9 deletions src/testRunner/unittests/tsbuild/emitDeclarationOnly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as vfs from "../../_namespaces/vfs";
import {
loadProjectFromDisk,
replaceText,
verifyTscWithEdits,
verifyTsc,
} from "../tsc/helpers";

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

function verifyEmitDeclarationOnly(disableMap?: true) {
verifyTscWithEdits({
verifyTsc({
subScenario: `only dts output in circular import project with emitDeclarationOnly${disableMap ? "" : " and declarationMap"}`,
fs: () => projFs,
scenario: "emitDeclarationOnly",
Expand All @@ -24,15 +24,15 @@ describe("unittests:: tsbuild:: on project with emitDeclarationOnly set to true"
(fs => replaceText(fs, "/src/tsconfig.json", `"declarationMap": true,`, "")) :
undefined,
edits: [{
subScenario: "incremental-declaration-changes",
modifyFs: fs => replaceText(fs, "/src/src/a.ts", "b: B;", "b: B; foo: any;"),
caption: "incremental-declaration-changes",
edit: fs => replaceText(fs, "/src/src/a.ts", "b: B;", "b: B; foo: any;"),
}],
});
}
verifyEmitDeclarationOnly();
verifyEmitDeclarationOnly(/*disableMap*/ true);

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

},
{
subScenario: "incremental-declaration-changes",
modifyFs: fs => replaceText(fs, "/src/src/a.ts", "b: B;", "b: B; foo: any;"),
caption: "incremental-declaration-changes",
edit: fs => replaceText(fs, "/src/src/a.ts", "b: B;", "b: B; foo: any;"),
},
],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
appendText,
loadProjectFromDisk,
replaceText,
verifyTscWithEdits,
verifyTsc,
} from "../tsc/helpers";

describe("unittests:: tsbuild:: inferredTypeFromTransitiveModule::", () => {
Expand All @@ -15,42 +15,42 @@ describe("unittests:: tsbuild:: inferredTypeFromTransitiveModule::", () => {
projFs = undefined!;
});

verifyTscWithEdits({
verifyTsc({
scenario: "inferredTypeFromTransitiveModule",
subScenario: "inferred type from transitive module",
fs: () => projFs,
commandLineArgs: ["--b", "/src", "--verbose"],
edits: [
{
subScenario: "incremental-declaration-changes",
modifyFs: changeBarParam,
caption: "incremental-declaration-changes",
edit: changeBarParam,
},
{
subScenario: "incremental-declaration-changes",
modifyFs: changeBarParamBack,
caption: "incremental-declaration-changes",
edit: changeBarParamBack,
},
],
});

verifyTscWithEdits({
verifyTsc({
subScenario: "inferred type from transitive module with isolatedModules",
fs: () => projFs,
scenario: "inferredTypeFromTransitiveModule",
commandLineArgs: ["--b", "/src", "--verbose"],
modifyFs: changeToIsolatedModules,
edits: [
{
subScenario: "incremental-declaration-changes",
modifyFs: changeBarParam
caption: "incremental-declaration-changes",
edit: changeBarParam
},
{
subScenario: "incremental-declaration-changes",
modifyFs: changeBarParamBack,
caption: "incremental-declaration-changes",
edit: changeBarParamBack,
},
]
});

verifyTscWithEdits({
verifyTsc({
scenario: "inferredTypeFromTransitiveModule",
subScenario: "reports errors in files affected by change in signature with isolatedModules",
fs: () => projFs,
Expand All @@ -63,20 +63,20 @@ bar("hello");`);
},
edits: [
{
subScenario: "incremental-declaration-changes",
modifyFs: changeBarParam
caption: "incremental-declaration-changes",
edit: changeBarParam
},
{
subScenario: "incremental-declaration-changes",
modifyFs: changeBarParamBack,
caption: "incremental-declaration-changes",
edit: changeBarParamBack,
},
{
subScenario: "incremental-declaration-changes",
modifyFs: changeBarParam
caption: "incremental-declaration-changes",
edit: changeBarParam
},
{
subScenario: "Fix Error",
modifyFs: fs => replaceText(fs, "/src/lazyIndex.ts", `bar("hello")`, "bar()")
caption: "Fix Error",
edit: fs => replaceText(fs, "/src/lazyIndex.ts", `bar("hello")`, "bar()")
},
]
});
Expand Down
7 changes: 3 additions & 4 deletions src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
replaceText,
symbolLibContent,
verifyTsc,
verifyTscWithEdits,
} from "../tsc/helpers";

describe("unittests:: tsbuild:: javascriptProjectEmit::", () => {
Expand Down Expand Up @@ -96,7 +95,7 @@ describe("unittests:: tsbuild:: javascriptProjectEmit::", () => {
commandLineArgs: ["-b", "/src"]
});

verifyTscWithEdits({
verifyTsc({
scenario: "javascriptProjectEmit",
subScenario: `modifies outfile js projects and concatenates them correctly`,
fs: () => loadProjectFromFiles({
Expand Down Expand Up @@ -185,8 +184,8 @@ describe("unittests:: tsbuild:: javascriptProjectEmit::", () => {
}, symbolLibContent),
commandLineArgs: ["-b", "/src"],
edits: [{
subScenario: "incremental-declaration-doesnt-change",
modifyFs: fs => replaceText(fs, "/src/sub-project/index.js", "null", "undefined")
caption: "incremental-declaration-doesnt-change",
edit: fs => replaceText(fs, "/src/sub-project/index.js", "null", "undefined")
}]
});

Expand Down
12 changes: 6 additions & 6 deletions src/testRunner/unittests/tsbuild/lateBoundSymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import {
appendText,
loadProjectFromDisk,
replaceText,
verifyTscWithEdits,
verifyTsc,
} from "../tsc/helpers";

describe("unittests:: tsbuild:: lateBoundSymbol:: interface is merged and contains late bound member", () => {
verifyTscWithEdits({
verifyTsc({
subScenario: "interface is merged and contains late bound member",
fs: () => loadProjectFromDisk("tests/projects/lateBoundSymbol"),
scenario: "lateBoundSymbol",
commandLineArgs: ["--b", "/src/tsconfig.json", "--verbose"],
edits: [
{
subScenario: "incremental-declaration-doesnt-change",
modifyFs: fs => replaceText(fs, "/src/src/main.ts", "const x = 10;", ""),
caption: "incremental-declaration-doesnt-change",
edit: fs => replaceText(fs, "/src/src/main.ts", "const x = 10;", ""),
},
{
subScenario: "incremental-declaration-doesnt-change",
modifyFs: fs => appendText(fs, "/src/src/main.ts", "const x = 10;"),
caption: "incremental-declaration-doesnt-change",
edit: fs => appendText(fs, "/src/src/main.ts", "const x = 10;"),
},
]
});
Expand Down
5 changes: 1 addition & 4 deletions src/testRunner/unittests/tsbuild/moduleResolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
loadProjectFromFiles,
noChangeOnlyRuns,
verifyTsc,
verifyTscWithEdits,
} from "../tsc/helpers";
import { verifyTscWatch } from "../tscWatch/helpers";

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

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

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

describe("unittests:: tsbuild:: moduleResolution:: impliedNodeFormat differs between projects for shared file", () => {
verifyTscWithEdits({
verifyTsc({
scenario: "moduleResolution",
subScenario: "impliedNodeFormat differs between projects for shared file",
fs: () => loadProjectFromFiles({
Expand Down
8 changes: 4 additions & 4 deletions src/testRunner/unittests/tsbuild/noEmit.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
loadProjectFromFiles,
noChangeRun,
verifyTscWithEdits,
verifyTsc,
} from "../tsc/helpers";

describe("unittests:: tsbuild:: noEmit", () => {
function verifyNoEmitWorker(subScenario: string, aTsContent: string, commandLineArgs: readonly string[]) {
verifyTscWithEdits({
verifyTsc({
scenario: "noEmit",
subScenario,
fs: () => loadProjectFromFiles({
Expand All @@ -19,8 +19,8 @@ describe("unittests:: tsbuild:: noEmit", () => {
edits: [
noChangeRun,
{
subScenario: "Fix error",
modifyFs: fs => fs.writeFileSync("/src/a.ts", `const a = "hello"`),
caption: "Fix error",
edit: fs => fs.writeFileSync("/src/a.ts", `const a = "hello"`),
},
noChangeRun,
],
Expand Down
Loading