mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 01:49:41 -05:00
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
This commit is contained in:
@@ -12,7 +12,6 @@ import {
|
||||
removeRest,
|
||||
replaceText,
|
||||
verifyTsc,
|
||||
verifyTscWithEdits,
|
||||
} from "../tsc/helpers";
|
||||
|
||||
describe("unittests:: tsbuild:: outFile:: on amd modules with --out", () => {
|
||||
@@ -35,7 +34,7 @@ describe("unittests:: tsbuild:: outFile:: on amd modules with --out", () => {
|
||||
modifyFs,
|
||||
modifyAgainFs
|
||||
}: VerifyOutFileScenarioInput) {
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "amdModulesWithOut",
|
||||
subScenario,
|
||||
fs: () => outFileFs,
|
||||
@@ -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),
|
||||
]
|
||||
});
|
||||
|
||||
@@ -6,32 +6,32 @@ import {
|
||||
noChangeRun,
|
||||
replaceText,
|
||||
TestTscEdit,
|
||||
verifyTscWithEdits,
|
||||
verifyTsc,
|
||||
} from "../tsc/helpers";
|
||||
|
||||
describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
describe("different options::", () => {
|
||||
function withOptionChange(subScenario: string, ...options: readonly string[]): TestTscEdit {
|
||||
function withOptionChange(caption: string, ...options: readonly string[]): TestTscEdit {
|
||||
return {
|
||||
subScenario,
|
||||
modifyFs: ts.noop,
|
||||
caption,
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project", "--verbose", ...options]
|
||||
};
|
||||
}
|
||||
function noChangeWithSubscenario(subScenario: string): TestTscEdit {
|
||||
return { ...noChangeRun, subScenario };
|
||||
function noChangeWithSubscenario(caption: string): TestTscEdit {
|
||||
return { ...noChangeRun, caption };
|
||||
}
|
||||
function withOptionChangeAndDiscrepancyExplanation(subScenario: string, option: string): TestTscEdit {
|
||||
function withOptionChangeAndDiscrepancyExplanation(caption: string, option: string): TestTscEdit {
|
||||
return {
|
||||
...withOptionChange(subScenario, option),
|
||||
...withOptionChange(caption, option),
|
||||
discrepancyExplanation: () => [
|
||||
`Clean build tsbuildinfo will have compilerOptions with composite and ${option.replace(/\-/g, "")}`,
|
||||
`Incremental build will detect that it doesnt need to rebuild so tsbuild info is from before which has option composite only`,
|
||||
]
|
||||
};
|
||||
}
|
||||
function withEmitDeclarationOnlyChangeAndDiscrepancyExplanation(subScenario: string): TestTscEdit {
|
||||
const edit = withOptionChangeAndDiscrepancyExplanation(subScenario, "--emitDeclarationOnly");
|
||||
function withEmitDeclarationOnlyChangeAndDiscrepancyExplanation(caption: string): TestTscEdit {
|
||||
const edit = withOptionChangeAndDiscrepancyExplanation(caption, "--emitDeclarationOnly");
|
||||
const discrepancyExplanation = edit.discrepancyExplanation!;
|
||||
edit.discrepancyExplanation = () => [
|
||||
...discrepancyExplanation(),
|
||||
@@ -61,8 +61,8 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
}
|
||||
function localChange(): TestTscEdit {
|
||||
return {
|
||||
subScenario: "local change",
|
||||
modifyFs: fs => replaceText(fs, "/src/project/a.ts", "Local = 1", "Local = 10"),
|
||||
caption: "local change",
|
||||
edit: fs => replaceText(fs, "/src/project/a.ts", "Local = 1", "Local = 10"),
|
||||
};
|
||||
}
|
||||
function fs(options: ts.CompilerOptions) {
|
||||
@@ -74,7 +74,7 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
"/src/project/d.ts": `import { b } from "./b";export const d = b;`,
|
||||
});
|
||||
}
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "different options",
|
||||
fs: () => fs({ composite: true }),
|
||||
@@ -95,7 +95,7 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "different options with outFile",
|
||||
fs: () => fs({ composite: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD }),
|
||||
@@ -116,7 +116,7 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "different options with incremental",
|
||||
fs: () => fs({ incremental: true }),
|
||||
@@ -138,7 +138,7 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "different options with incremental with outFile",
|
||||
fs: () => fs({ incremental: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD }),
|
||||
@@ -181,7 +181,7 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
});
|
||||
}
|
||||
function verifyWithIncremental(options: ts.CompilerOptions) {
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: subScenario("emitDeclarationOnly on commandline"),
|
||||
fs: () => fs(options),
|
||||
@@ -189,16 +189,16 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "local change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
caption: "local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
},
|
||||
{
|
||||
subScenario: "non local change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/a.ts", "export const aaa = 10;"),
|
||||
caption: "non local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "export const aaa = 10;"),
|
||||
},
|
||||
{
|
||||
subScenario: "emit js files",
|
||||
modifyFs: ts.noop,
|
||||
caption: "emit js files",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
{
|
||||
@@ -209,13 +209,13 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
]
|
||||
},
|
||||
{
|
||||
subScenario: "js emit with change without emitDeclarationOnly",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/b.ts", "const alocal = 10;"),
|
||||
caption: "js emit with change without emitDeclarationOnly",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const alocal = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
{
|
||||
subScenario: "local change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/b.ts", "const aaaa = 10;"),
|
||||
caption: "local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const aaaa = 10;"),
|
||||
// --out without composite doesnt emit buildInfo without emitting program so it wouldnt have project2 tsbuildInfo so no mismatch
|
||||
discrepancyExplanation: options.incremental && options.outFile ? undefined : () => [
|
||||
`Clean build tsbuildinfo for project2 will have compilerOptions with composite and emitDeclarationOnly`,
|
||||
@@ -223,18 +223,18 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
],
|
||||
},
|
||||
{
|
||||
subScenario: "non local change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/b.ts", "export const aaaaa = 10;"),
|
||||
caption: "non local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "export const aaaaa = 10;"),
|
||||
},
|
||||
{
|
||||
subScenario: "js emit with change without emitDeclarationOnly",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/b.ts", "export const a2 = 10;"),
|
||||
caption: "js emit with change without emitDeclarationOnly",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "export const a2 = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: subScenario("emitDeclarationOnly false on commandline"),
|
||||
fs: () => fs({ ...options, emitDeclarationOnly: true }),
|
||||
@@ -242,12 +242,12 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
caption: "change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
},
|
||||
{
|
||||
subScenario: "emit js files",
|
||||
modifyFs: ts.noop,
|
||||
caption: "emit js files",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
{
|
||||
@@ -258,13 +258,13 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
]
|
||||
},
|
||||
{
|
||||
subScenario: "no change run with js emit",
|
||||
modifyFs: ts.noop,
|
||||
caption: "no change run with js emit",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
{
|
||||
subScenario: "js emit with change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/b.ts", "const blocal = 10;"),
|
||||
caption: "js emit with change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const blocal = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
],
|
||||
@@ -279,7 +279,7 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
verifyWithIncremental({ composite: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD });
|
||||
verifyWithIncremental({ incremental: true, declaration: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD });
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "emitDeclarationOnly on commandline with declaration",
|
||||
fs: () => fs({ declaration: true }),
|
||||
@@ -287,42 +287,42 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "local change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
caption: "local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
},
|
||||
{
|
||||
subScenario: "non local change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/a.ts", "export const aaa = 10;"),
|
||||
caption: "non local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "export const aaa = 10;"),
|
||||
},
|
||||
{
|
||||
subScenario: "emit js files",
|
||||
modifyFs: ts.noop,
|
||||
caption: "emit js files",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "js emit with change without emitDeclarationOnly",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/b.ts", "const alocal = 10;"),
|
||||
caption: "js emit with change without emitDeclarationOnly",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const alocal = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
{
|
||||
subScenario: "local change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/b.ts", "const aaaa = 10;"),
|
||||
caption: "local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const aaaa = 10;"),
|
||||
},
|
||||
{
|
||||
subScenario: "non local change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/b.ts", "export const aaaaa = 10;"),
|
||||
caption: "non local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "export const aaaaa = 10;"),
|
||||
},
|
||||
{
|
||||
subScenario: "js emit with change without emitDeclarationOnly",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/b.ts", "export const a2 = 10;"),
|
||||
caption: "js emit with change without emitDeclarationOnly",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "export const a2 = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "emitDeclarationOnly false on commandline with declaration",
|
||||
fs: () => fs({ declaration: true, emitDeclarationOnly: true }),
|
||||
@@ -330,30 +330,30 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
caption: "change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
},
|
||||
{
|
||||
subScenario: "emit js files",
|
||||
modifyFs: ts.noop,
|
||||
caption: "emit js files",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "no change run with js emit",
|
||||
modifyFs: ts.noop,
|
||||
caption: "no change run with js emit",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
{
|
||||
subScenario: "js emit with change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/b.ts", "const blocal = 10;"),
|
||||
caption: "js emit with change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const blocal = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "emitDeclarationOnly on commandline with declaration with outFile",
|
||||
fs: () => fs({ declaration: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD }),
|
||||
@@ -361,42 +361,42 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "local change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
caption: "local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
},
|
||||
{
|
||||
subScenario: "non local change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/a.ts", "export const aaa = 10;"),
|
||||
caption: "non local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "export const aaa = 10;"),
|
||||
},
|
||||
{
|
||||
subScenario: "emit js files",
|
||||
modifyFs: ts.noop,
|
||||
caption: "emit js files",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "js emit with change without emitDeclarationOnly",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/b.ts", "const alocal = 10;"),
|
||||
caption: "js emit with change without emitDeclarationOnly",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const alocal = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
{
|
||||
subScenario: "local change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/b.ts", "const aaaa = 10;"),
|
||||
caption: "local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const aaaa = 10;"),
|
||||
},
|
||||
{
|
||||
subScenario: "non local change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/b.ts", "export const aaaaa = 10;"),
|
||||
caption: "non local change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "export const aaaaa = 10;"),
|
||||
},
|
||||
{
|
||||
subScenario: "js emit with change without emitDeclarationOnly",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/b.ts", "export const a2 = 10;"),
|
||||
caption: "js emit with change without emitDeclarationOnly",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "export const a2 = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose"],
|
||||
},
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "commandLine",
|
||||
subScenario: "emitDeclarationOnly false on commandline with declaration with outFile",
|
||||
fs: () => fs({ declaration: true, emitDeclarationOnly: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD }),
|
||||
@@ -404,23 +404,23 @@ describe("unittests:: tsbuild:: commandLine::", () => {
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
caption: "change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/a.ts", "const aa = 10;"),
|
||||
},
|
||||
{
|
||||
subScenario: "emit js files",
|
||||
modifyFs: ts.noop,
|
||||
caption: "emit js files",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "no change run with js emit",
|
||||
modifyFs: ts.noop,
|
||||
caption: "no change run with js emit",
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
{
|
||||
subScenario: "js emit with change",
|
||||
modifyFs: fs => appendText(fs, "/src/project1/src/b.ts", "const blocal = 10;"),
|
||||
caption: "js emit with change",
|
||||
edit: fs => appendText(fs, "/src/project1/src/b.ts", "const blocal = 10;"),
|
||||
commandLineArgs: ["--b", "/src/project2/src", "--verbose", "--emitDeclarationOnly", "false"],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
noChangeRun,
|
||||
replaceText,
|
||||
verifyTsc,
|
||||
verifyTscWithEdits,
|
||||
} from "../tsc/helpers";
|
||||
import { dedent } from "../../_namespaces/Utils";
|
||||
|
||||
@@ -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({
|
||||
@@ -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"
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
@@ -3,11 +3,11 @@ 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"),
|
||||
@@ -15,7 +15,7 @@ describe("unittests:: tsbuild:: when containerOnly project is referenced", () =>
|
||||
edits: noChangeOnlyRuns
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "containerOnlyReferenced",
|
||||
subScenario: "when solution is referenced indirectly",
|
||||
fs: () => loadProjectFromFiles({
|
||||
@@ -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 = "),
|
||||
}],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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", () => {
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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;"),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
appendText,
|
||||
loadProjectFromDisk,
|
||||
replaceText,
|
||||
verifyTscWithEdits,
|
||||
verifyTsc,
|
||||
} from "../tsc/helpers";
|
||||
|
||||
describe("unittests:: tsbuild:: inferredTypeFromTransitiveModule::", () => {
|
||||
@@ -15,24 +15,24 @@ 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",
|
||||
@@ -40,17 +40,17 @@ describe("unittests:: tsbuild:: inferredTypeFromTransitiveModule::", () => {
|
||||
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,
|
||||
@@ -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()")
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
replaceText,
|
||||
symbolLibContent,
|
||||
verifyTsc,
|
||||
verifyTscWithEdits,
|
||||
} from "../tsc/helpers";
|
||||
|
||||
describe("unittests:: tsbuild:: javascriptProjectEmit::", () => {
|
||||
@@ -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({
|
||||
@@ -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")
|
||||
}]
|
||||
});
|
||||
|
||||
|
||||
@@ -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;"),
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
loadProjectFromFiles,
|
||||
noChangeOnlyRuns,
|
||||
verifyTsc,
|
||||
verifyTscWithEdits,
|
||||
} from "../tsc/helpers";
|
||||
import { verifyTscWatch } from "../tscWatch/helpers";
|
||||
|
||||
@@ -68,7 +67,6 @@ 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({
|
||||
@@ -76,7 +74,6 @@ describe("unittests:: tsbuild:: moduleResolution:: handles the modules and optio
|
||||
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({
|
||||
@@ -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({
|
||||
|
||||
@@ -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({
|
||||
@@ -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,
|
||||
],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
loadProjectFromDisk,
|
||||
noChangeRun,
|
||||
verifyTscWithEdits,
|
||||
verifyTsc,
|
||||
} from "../tsc/helpers";
|
||||
import * as vfs from "../../_namespaces/vfs";
|
||||
|
||||
@@ -14,7 +14,7 @@ describe("unittests:: tsbuild - with noEmitOnError", () => {
|
||||
projFs = undefined!;
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "noEmitOnError",
|
||||
subScenario: "syntax errors",
|
||||
fs: () => projFs,
|
||||
@@ -22,8 +22,8 @@ describe("unittests:: tsbuild - with noEmitOnError", () => {
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "Fix error",
|
||||
modifyFs: fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db";
|
||||
caption: "Fix error",
|
||||
edit: fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db";
|
||||
const a = {
|
||||
lastName: 'sdsd'
|
||||
};`, "utf-8"),
|
||||
@@ -33,7 +33,7 @@ const a = {
|
||||
baselinePrograms: true,
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "noEmitOnError",
|
||||
subScenario: "syntax errors with incremental",
|
||||
fs: () => projFs,
|
||||
@@ -41,8 +41,8 @@ const a = {
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "Fix error",
|
||||
modifyFs: fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db";
|
||||
caption: "Fix error",
|
||||
edit: fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db";
|
||||
const a = {
|
||||
lastName: 'sdsd'
|
||||
};`, "utf-8"),
|
||||
@@ -52,7 +52,7 @@ const a = {
|
||||
baselinePrograms: true,
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "noEmitOnError",
|
||||
subScenario: "semantic errors",
|
||||
fs: () => projFs,
|
||||
@@ -62,8 +62,8 @@ const a: string = 10;`, "utf-8"),
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "Fix error",
|
||||
modifyFs: fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db";
|
||||
caption: "Fix error",
|
||||
edit: fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db";
|
||||
const a: string = "hello";`, "utf-8"),
|
||||
},
|
||||
noChangeRun,
|
||||
@@ -71,7 +71,7 @@ const a: string = "hello";`, "utf-8"),
|
||||
baselinePrograms: true,
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "noEmitOnError",
|
||||
subScenario: "semantic errors with incremental",
|
||||
fs: () => projFs,
|
||||
@@ -81,8 +81,8 @@ const a: string = 10;`, "utf-8"),
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "Fix error",
|
||||
modifyFs: fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db";
|
||||
caption: "Fix error",
|
||||
edit: fs => fs.writeFileSync("/src/src/main.ts", `import { A } from "../shared/types/db";
|
||||
const a: string = "hello";`, "utf-8"),
|
||||
},
|
||||
noChangeRun,
|
||||
|
||||
@@ -22,8 +22,6 @@ import {
|
||||
TscCompileSystem,
|
||||
verifyTsc,
|
||||
verifyTscCompileLike,
|
||||
verifyTscWithEdits,
|
||||
VerifyTscWithEditsInput,
|
||||
} from "../tsc/helpers";
|
||||
|
||||
describe("unittests:: tsbuild:: outFile::", () => {
|
||||
@@ -56,26 +54,26 @@ describe("unittests:: tsbuild:: outFile::", () => {
|
||||
baselineOnly,
|
||||
additionalCommandLineArgs,
|
||||
}: VerifyOutFileScenarioInput) {
|
||||
const edits: TestTscEdit[] = [];
|
||||
let edits: TestTscEdit[] | undefined;
|
||||
if (!ignoreDtsChanged) {
|
||||
edits.push({
|
||||
subScenario: "incremental-declaration-changes",
|
||||
modifyFs: fs => replaceText(fs, "/src/first/first_PART1.ts", "Hello", "Hola"),
|
||||
(edits ??= []).push({
|
||||
caption: "incremental-declaration-changes",
|
||||
edit: fs => replaceText(fs, "/src/first/first_PART1.ts", "Hello", "Hola"),
|
||||
});
|
||||
}
|
||||
if (!ignoreDtsUnchanged) {
|
||||
edits.push({
|
||||
subScenario: "incremental-declaration-doesnt-change",
|
||||
modifyFs: fs => appendText(fs, "/src/first/first_PART1.ts", "console.log(s);"),
|
||||
(edits ??= []).push({
|
||||
caption: "incremental-declaration-doesnt-change",
|
||||
edit: fs => appendText(fs, "/src/first/first_PART1.ts", "console.log(s);"),
|
||||
});
|
||||
}
|
||||
if (modifyAgainFs) {
|
||||
edits.push({
|
||||
subScenario: "incremental-headers-change-without-dts-changes",
|
||||
modifyFs: modifyAgainFs
|
||||
(edits ??= []).push({
|
||||
caption: "incremental-headers-change-without-dts-changes",
|
||||
edit: modifyAgainFs
|
||||
});
|
||||
}
|
||||
const input: VerifyTscWithEditsInput = {
|
||||
verifyTsc({
|
||||
subScenario,
|
||||
fs: () => outFileFs,
|
||||
scenario: "outfile-concat",
|
||||
@@ -84,10 +82,7 @@ describe("unittests:: tsbuild:: outFile::", () => {
|
||||
modifyFs,
|
||||
baselineReadFileCalls: !baselineOnly,
|
||||
edits,
|
||||
};
|
||||
return edits.length ?
|
||||
verifyTscWithEdits(input) :
|
||||
verifyTsc(input);
|
||||
});
|
||||
}
|
||||
|
||||
// Verify initial + incremental edits
|
||||
@@ -139,7 +134,7 @@ describe("unittests:: tsbuild:: outFile::", () => {
|
||||
return outFileWithBuildFs = fs;
|
||||
}
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "outFile",
|
||||
subScenario: "clean projects",
|
||||
fs: getOutFileFsAfterBuild,
|
||||
@@ -176,7 +171,7 @@ describe("unittests:: tsbuild:: outFile::", () => {
|
||||
}
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "outFile",
|
||||
subScenario: "rebuilds completely when command line incremental flag changes between non dts changes",
|
||||
fs: () => outFileFs,
|
||||
@@ -186,27 +181,27 @@ describe("unittests:: tsbuild:: outFile::", () => {
|
||||
commandLineArgs: ["--b", "/src/third", "--i", "--verbose"],
|
||||
edits: [
|
||||
{
|
||||
subScenario: "Make non incremental build with change in file that doesnt affect dts",
|
||||
modifyFs: fs => appendText(fs, "/src/first/first_PART1.ts", "console.log(s);"),
|
||||
caption: "Make non incremental build with change in file that doesnt affect dts",
|
||||
edit: fs => appendText(fs, "/src/first/first_PART1.ts", "console.log(s);"),
|
||||
commandLineArgs: ["--b", "/src/third", "--verbose"],
|
||||
},
|
||||
{
|
||||
subScenario: "Make incremental build with change in file that doesnt affect dts",
|
||||
modifyFs: fs => appendText(fs, "/src/first/first_PART1.ts", "console.log(s);"),
|
||||
caption: "Make incremental build with change in file that doesnt affect dts",
|
||||
edit: fs => appendText(fs, "/src/first/first_PART1.ts", "console.log(s);"),
|
||||
commandLineArgs: ["--b", "/src/third", "--verbose", "--incremental"],
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "outFile",
|
||||
subScenario: "when input file text does not change but its modified time changes",
|
||||
fs: () => outFileFs,
|
||||
commandLineArgs: ["--b", "/src/third", "--verbose"],
|
||||
edits: [
|
||||
{
|
||||
subScenario: "upstream project changes without changing file text",
|
||||
modifyFs: fs => {
|
||||
caption: "upstream project changes without changing file text",
|
||||
edit: fs => {
|
||||
const time = new Date(fs.time());
|
||||
fs.utimesSync("/src/first/first_PART1.ts", time, time);
|
||||
},
|
||||
|
||||
@@ -5,14 +5,14 @@ import {
|
||||
noChangeRun,
|
||||
TestTscEdit,
|
||||
TscCompileSystem,
|
||||
verifyTscWithEdits,
|
||||
verifyTsc,
|
||||
VerifyTscWithEditsInput,
|
||||
} from "../tsc/helpers";
|
||||
|
||||
describe("unittests:: tsbuild - output file paths", () => {
|
||||
const noChangeProject: TestTscEdit = {
|
||||
modifyFs: ts.noop,
|
||||
subScenario: "Normal build without change, that does not block emit on error to show files that get emitted",
|
||||
edit: ts.noop,
|
||||
caption: "Normal build without change, that does not block emit on error to show files that get emitted",
|
||||
commandLineArgs: ["-p", "/src/tsconfig.json"],
|
||||
};
|
||||
const edits: TestTscEdit[] = [
|
||||
@@ -21,7 +21,7 @@ describe("unittests:: tsbuild - output file paths", () => {
|
||||
];
|
||||
|
||||
function verify(input: Pick<VerifyTscWithEditsInput, "subScenario" | "fs" | "edits">, expectedOuptutNames: readonly string[]) {
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "outputPaths",
|
||||
commandLineArgs: ["--b", "/src/tsconfig.json", "-v"],
|
||||
...input
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
noChangeOnlyRuns,
|
||||
replaceText,
|
||||
verifyTsc,
|
||||
verifyTscWithEdits,
|
||||
} from "../tsc/helpers";
|
||||
|
||||
describe("unittests:: tsbuild:: with resolveJsonModule option on project resolveJsonModuleAndComposite", () => {
|
||||
@@ -59,7 +58,7 @@ export default hello.hello`);
|
||||
commandLineArgs: ["--b", "/src/tsconfig_withIncludeAndFiles.json", "--v", "--explainFiles"],
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "resolveJsonModule",
|
||||
subScenario: "sourcemap",
|
||||
fs: () => projFs,
|
||||
@@ -68,7 +67,7 @@ export default hello.hello`);
|
||||
edits: noChangeOnlyRuns
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "resolveJsonModule",
|
||||
subScenario: "without outDir",
|
||||
fs: () => projFs,
|
||||
@@ -79,7 +78,7 @@ export default hello.hello`);
|
||||
});
|
||||
|
||||
describe("unittests:: tsbuild:: with resolveJsonModule option on project importJsonFromProjectReference", () => {
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "resolveJsonModule",
|
||||
subScenario: "importing json module from project reference",
|
||||
fs: () => loadProjectFromDisk("tests/projects/importJsonFromProjectReference"),
|
||||
|
||||
@@ -25,7 +25,6 @@ import {
|
||||
TscCompileSystem,
|
||||
verifyTsc,
|
||||
verifyTscCompileLike,
|
||||
verifyTscWithEdits,
|
||||
} from "../tsc/helpers";
|
||||
|
||||
describe("unittests:: tsbuild:: on 'sample1' project", () => {
|
||||
@@ -100,7 +99,7 @@ describe("unittests:: tsbuild:: on 'sample1' project", () => {
|
||||
});
|
||||
|
||||
describe("clean builds", () => {
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "sample1",
|
||||
subScenario: "removes all files it built",
|
||||
fs: getSampleFsAfterBuild,
|
||||
@@ -134,7 +133,7 @@ describe("unittests:: tsbuild:: on 'sample1' project", () => {
|
||||
});
|
||||
|
||||
describe("force builds", () => {
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "sample1",
|
||||
subScenario: "always builds under with force option",
|
||||
fs: () => projFs,
|
||||
@@ -144,7 +143,7 @@ describe("unittests:: tsbuild:: on 'sample1' project", () => {
|
||||
});
|
||||
|
||||
describe("can detect when and what to rebuild", () => {
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "sample1",
|
||||
subScenario: "can detect when and what to rebuild",
|
||||
fs: getSampleFsAfterBuild,
|
||||
@@ -152,30 +151,30 @@ describe("unittests:: tsbuild:: on 'sample1' project", () => {
|
||||
edits: [
|
||||
// Update a file in the leaf node (tests), only it should rebuild the last one
|
||||
{
|
||||
subScenario: "Only builds the leaf node project",
|
||||
modifyFs: fs => fs.writeFileSync("/src/tests/index.ts", "const m = 10;"),
|
||||
caption: "Only builds the leaf node project",
|
||||
edit: fs => fs.writeFileSync("/src/tests/index.ts", "const m = 10;"),
|
||||
},
|
||||
// Update a file in the parent (without affecting types), should get fast downstream builds
|
||||
{
|
||||
subScenario: "Detects type-only changes in upstream projects",
|
||||
modifyFs: fs => replaceText(fs, "/src/core/index.ts", "HELLO WORLD", "WELCOME PLANET"),
|
||||
caption: "Detects type-only changes in upstream projects",
|
||||
edit: fs => replaceText(fs, "/src/core/index.ts", "HELLO WORLD", "WELCOME PLANET"),
|
||||
},
|
||||
{
|
||||
subScenario: "rebuilds when tsconfig changes",
|
||||
modifyFs: fs => replaceText(fs, "/src/tests/tsconfig.json", `"composite": true`, `"composite": true, "target": "es3"`),
|
||||
caption: "rebuilds when tsconfig changes",
|
||||
edit: fs => replaceText(fs, "/src/tests/tsconfig.json", `"composite": true`, `"composite": true, "target": "es3"`),
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "sample1",
|
||||
subScenario: "when input file text does not change but its modified time changes",
|
||||
fs: () => projFs,
|
||||
commandLineArgs: ["--b", "/src/tests", "--verbose"],
|
||||
edits: [
|
||||
{
|
||||
subScenario: "upstream project changes without changing file text",
|
||||
modifyFs: fs => {
|
||||
caption: "upstream project changes without changing file text",
|
||||
edit: fs => {
|
||||
const time = new Date(fs.time());
|
||||
fs.utimesSync("/src/core/index.ts", time, time);
|
||||
},
|
||||
@@ -183,19 +182,19 @@ describe("unittests:: tsbuild:: on 'sample1' project", () => {
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "sample1",
|
||||
subScenario: "when declarationMap changes",
|
||||
fs: () => projFs,
|
||||
commandLineArgs: ["--b", "/src/tests", "--verbose"],
|
||||
edits: [
|
||||
{
|
||||
subScenario: "Disable declarationMap",
|
||||
modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", `"declarationMap": true,`, `"declarationMap": false,`),
|
||||
caption: "Disable declarationMap",
|
||||
edit: fs => replaceText(fs, "/src/core/tsconfig.json", `"declarationMap": true,`, `"declarationMap": false,`),
|
||||
},
|
||||
{
|
||||
subScenario: "Enable declarationMap",
|
||||
modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", `"declarationMap": false,`, `"declarationMap": true,`),
|
||||
caption: "Enable declarationMap",
|
||||
edit: fs => replaceText(fs, "/src/core/tsconfig.json", `"declarationMap": false,`, `"declarationMap": true,`),
|
||||
},
|
||||
]
|
||||
});
|
||||
@@ -214,7 +213,7 @@ describe("unittests:: tsbuild:: on 'sample1' project", () => {
|
||||
commandLineArgs: ["--b", "/src/tests", "--verbose", "--force"],
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "sample1",
|
||||
subScenario: "tsbuildinfo has error",
|
||||
fs: () => loadProjectFromFiles({
|
||||
@@ -224,8 +223,8 @@ describe("unittests:: tsbuild:: on 'sample1' project", () => {
|
||||
}),
|
||||
commandLineArgs: ["--b", "src/project", "-i", "-v"],
|
||||
edits: [{
|
||||
subScenario: "tsbuildinfo written has error",
|
||||
modifyFs: fs => prependText(fs, "/src/project/tsconfig.tsbuildinfo", "Some random string"),
|
||||
caption: "tsbuildinfo written has error",
|
||||
edit: fs => prependText(fs, "/src/project/tsconfig.tsbuildinfo", "Some random string"),
|
||||
}]
|
||||
});
|
||||
|
||||
@@ -262,7 +261,7 @@ describe("unittests:: tsbuild:: on 'sample1' project", () => {
|
||||
},
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "sample1",
|
||||
subScenario: "rebuilds when extended config file changes",
|
||||
fs: () => projFs,
|
||||
@@ -272,8 +271,8 @@ describe("unittests:: tsbuild:: on 'sample1' project", () => {
|
||||
replaceText(fs, "/src/tests/tsconfig.json", `"references": [`, `"extends": "./tsconfig.base.json", "references": [`);
|
||||
},
|
||||
edits: [{
|
||||
subScenario: "incremental-declaration-changes",
|
||||
modifyFs: fs => fs.writeFileSync("/src/tests/tsconfig.base.json", JSON.stringify({ compilerOptions: {} }))
|
||||
caption: "incremental-declaration-changes",
|
||||
edit: fs => fs.writeFileSync("/src/tests/tsconfig.base.json", JSON.stringify({ compilerOptions: {} }))
|
||||
}]
|
||||
});
|
||||
|
||||
@@ -362,7 +361,7 @@ describe("unittests:: tsbuild:: on 'sample1' project", () => {
|
||||
});
|
||||
|
||||
describe("downstream-blocked compilations", () => {
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "sample1",
|
||||
subScenario: "does not build downstream projects if upstream projects have errors",
|
||||
fs: () => projFs,
|
||||
@@ -436,34 +435,34 @@ describe("unittests:: tsbuild:: on 'sample1' project", () => {
|
||||
|
||||
const coreChanges: TestTscEdit[] = [
|
||||
{
|
||||
subScenario: "incremental-declaration-changes",
|
||||
modifyFs: fs => appendText(fs, "/src/core/index.ts", `
|
||||
caption: "incremental-declaration-changes",
|
||||
edit: fs => appendText(fs, "/src/core/index.ts", `
|
||||
export class someClass { }`),
|
||||
},
|
||||
{
|
||||
subScenario: "incremental-declaration-doesnt-change",
|
||||
modifyFs: fs => appendText(fs, "/src/core/index.ts", `
|
||||
caption: "incremental-declaration-doesnt-change",
|
||||
edit: fs => appendText(fs, "/src/core/index.ts", `
|
||||
class someClass2 { }`),
|
||||
},
|
||||
noChangeRun,
|
||||
];
|
||||
|
||||
describe("lists files", () => {
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "sample1",
|
||||
subScenario: "listFiles",
|
||||
fs: () => projFs,
|
||||
commandLineArgs: ["--b", "/src/tests", "--listFiles"],
|
||||
edits: coreChanges
|
||||
});
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "sample1",
|
||||
subScenario: "listEmittedFiles",
|
||||
fs: () => projFs,
|
||||
commandLineArgs: ["--b", "/src/tests", "--listEmittedFiles"],
|
||||
edits: coreChanges
|
||||
});
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "sample1",
|
||||
subScenario: "explainFiles",
|
||||
fs: () => projFs,
|
||||
@@ -473,7 +472,7 @@ class someClass2 { }`),
|
||||
});
|
||||
|
||||
describe("emit output", () => {
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
subScenario: "sample",
|
||||
fs: () => projFs,
|
||||
scenario: "sample1",
|
||||
@@ -483,8 +482,8 @@ class someClass2 { }`),
|
||||
edits: [
|
||||
...coreChanges,
|
||||
{
|
||||
subScenario: "when logic config changes declaration dir",
|
||||
modifyFs: fs => replaceText(fs, "/src/logic/tsconfig.json", `"declaration": true,`, `"declaration": true,
|
||||
caption: "when logic config changes declaration dir",
|
||||
edit: fs => replaceText(fs, "/src/logic/tsconfig.json", `"declaration": true,`, `"declaration": true,
|
||||
"declarationDir": "decls",`),
|
||||
},
|
||||
noChangeRun,
|
||||
@@ -502,7 +501,7 @@ class someClass2 { }`),
|
||||
baselineReadFileCalls: true
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
subScenario: "when declaration option changes",
|
||||
fs: () => projFs,
|
||||
scenario: "sample1",
|
||||
@@ -514,12 +513,12 @@ class someClass2 { }`),
|
||||
}
|
||||
}`),
|
||||
edits: [{
|
||||
subScenario: "incremental-declaration-changes",
|
||||
modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", `"incremental": true,`, `"incremental": true, "declaration": true,`),
|
||||
caption: "incremental-declaration-changes",
|
||||
edit: fs => replaceText(fs, "/src/core/tsconfig.json", `"incremental": true,`, `"incremental": true, "declaration": true,`),
|
||||
}],
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
subScenario: "when target option changes",
|
||||
fs: () => projFs,
|
||||
scenario: "sample1",
|
||||
@@ -540,12 +539,12 @@ class someClass2 { }`),
|
||||
}`);
|
||||
},
|
||||
edits: [{
|
||||
subScenario: "incremental-declaration-changes",
|
||||
modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", "esnext", "es5"),
|
||||
caption: "incremental-declaration-changes",
|
||||
edit: fs => replaceText(fs, "/src/core/tsconfig.json", "esnext", "es5"),
|
||||
}],
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
subScenario: "when module option changes",
|
||||
fs: () => projFs,
|
||||
scenario: "sample1",
|
||||
@@ -557,12 +556,12 @@ class someClass2 { }`),
|
||||
}
|
||||
}`),
|
||||
edits: [{
|
||||
subScenario: "incremental-declaration-changes",
|
||||
modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", `"module": "commonjs"`, `"module": "amd"`),
|
||||
caption: "incremental-declaration-changes",
|
||||
edit: fs => replaceText(fs, "/src/core/tsconfig.json", `"module": "commonjs"`, `"module": "amd"`),
|
||||
}],
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
subScenario: "when esModuleInterop option changes",
|
||||
fs: () => projFs,
|
||||
scenario: "sample1",
|
||||
@@ -582,8 +581,8 @@ class someClass2 { }`),
|
||||
}
|
||||
}`),
|
||||
edits: [{
|
||||
subScenario: "incremental-declaration-changes",
|
||||
modifyFs: fs => replaceText(fs, "/src/tests/tsconfig.json", `"esModuleInterop": false`, `"esModuleInterop": true`),
|
||||
caption: "incremental-declaration-changes",
|
||||
edit: fs => replaceText(fs, "/src/tests/tsconfig.json", `"esModuleInterop": false`, `"esModuleInterop": true`),
|
||||
}],
|
||||
});
|
||||
|
||||
|
||||
@@ -36,26 +36,26 @@ describe("unittests:: tsbuildWatch:: watchMode:: configFileErrors:: reports synt
|
||||
{ currentDirectory: "/user/username/projects/myproject" }
|
||||
),
|
||||
commandLineArgs: ["--b", "-w"],
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "reports syntax errors after change to config file",
|
||||
change: sys => sys.replaceFileText(`/user/username/projects/myproject/tsconfig.json`, ",", `,
|
||||
edit: sys => sys.replaceFileText(`/user/username/projects/myproject/tsconfig.json`, ",", `,
|
||||
"declaration": true,`),
|
||||
timeouts: build,
|
||||
},
|
||||
{
|
||||
caption: "reports syntax errors after change to ts file",
|
||||
change: sys => sys.replaceFileText(`/user/username/projects/myproject/a.ts`, "foo", "fooBar"),
|
||||
edit: sys => sys.replaceFileText(`/user/username/projects/myproject/a.ts`, "foo", "fooBar"),
|
||||
timeouts: build,
|
||||
},
|
||||
{
|
||||
caption: "reports error when there is no change to tsconfig file",
|
||||
change: sys => sys.replaceFileText(`/user/username/projects/myproject/tsconfig.json`, "", ""),
|
||||
edit: sys => sys.replaceFileText(`/user/username/projects/myproject/tsconfig.json`, "", ""),
|
||||
timeouts: build,
|
||||
},
|
||||
{
|
||||
caption: "builds after fixing config file errors",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({
|
||||
compilerOptions: { composite: true, declaration: true },
|
||||
files: ["a.ts", "b.ts"]
|
||||
})),
|
||||
|
||||
@@ -50,10 +50,10 @@ describe("unittests:: tsbuildWatch:: watchMode:: with demo project", () => {
|
||||
));
|
||||
return sys;
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Fix error",
|
||||
change: sys => sys.writeFile(coreFiles[0].path, coreFiles[0].content),
|
||||
edit: sys => sys.writeFile(coreFiles[0].path, coreFiles[0].content),
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // build core
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // build animals, zoo and solution
|
||||
@@ -73,10 +73,10 @@ describe("unittests:: tsbuildWatch:: watchMode:: with demo project", () => {
|
||||
${coreFiles[1].content}`);
|
||||
return sys;
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Prepend a line",
|
||||
change: sys => sys.writeFile(coreFiles[1].path, `
|
||||
edit: sys => sys.writeFile(coreFiles[1].path, `
|
||||
import * as A from '../animals';
|
||||
${coreFiles[1].content}`),
|
||||
// build core
|
||||
|
||||
@@ -46,10 +46,10 @@ describe("unittests:: tsbuildWatch:: watchMode:: moduleResolution", () => {
|
||||
{ currentDirectory: "/user/username/projects/myproject" }
|
||||
),
|
||||
commandLineArgs: ["--b", "-w", "-v"],
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Append text",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/project1/index.ts`, "const bar = 10;"),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/project1/index.ts`, "const bar = 10;"),
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // build project1 and solution
|
||||
sys.checkTimeoutQueueLength(0);
|
||||
@@ -121,25 +121,25 @@ describe("unittests:: tsbuildWatch:: watchMode:: moduleResolution", () => {
|
||||
{ ...libFile, path: `/a/lib/lib.es2022.full.d.ts` }
|
||||
], { currentDirectory: "/user/username/projects/myproject" }),
|
||||
commandLineArgs: ["-b", "packages/pkg1", "-w", "--verbose", "--traceResolution"],
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "reports import errors after change to package file",
|
||||
change: sys => sys.replaceFileText(`/user/username/projects/myproject/packages/pkg1/package.json`, `"module"`, `"commonjs"`),
|
||||
edit: sys => sys.replaceFileText(`/user/username/projects/myproject/packages/pkg1/package.json`, `"module"`, `"commonjs"`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "removes those errors when a package file is changed back",
|
||||
change: sys => sys.replaceFileText(`/user/username/projects/myproject/packages/pkg1/package.json`, `"commonjs"`, `"module"`),
|
||||
edit: sys => sys.replaceFileText(`/user/username/projects/myproject/packages/pkg1/package.json`, `"commonjs"`, `"module"`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "reports import errors after change to package file",
|
||||
change: sys => sys.replaceFileText(`/user/username/projects/myproject/packages/pkg1/package.json`, `"module"`, `"commonjs"`),
|
||||
edit: sys => sys.replaceFileText(`/user/username/projects/myproject/packages/pkg1/package.json`, `"module"`, `"commonjs"`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks()
|
||||
},
|
||||
{
|
||||
caption: "removes those errors when a package file is changed to cjs extensions",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.replaceFileText(`/user/username/projects/myproject/packages/pkg2/package.json`, `"build/index.js"`, `"build/index.cjs"`);
|
||||
sys.renameFile(`/user/username/projects/myproject/packages/pkg2/index.ts`, `/user/username/projects/myproject/packages/pkg2/index.cts`);
|
||||
},
|
||||
@@ -215,15 +215,15 @@ describe("unittests:: tsbuildWatch:: watchMode:: moduleResolution", () => {
|
||||
libFile
|
||||
], { currentDirectory: "/user/username/projects/myproject" }),
|
||||
commandLineArgs: ["-b", "packages/pkg1", "--verbose", "-w", "--traceResolution"],
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "reports import errors after change to package file",
|
||||
change: sys => sys.replaceFileText(`/user/username/projects/myproject/packages/pkg2/package.json`, `index.js`, `other.js`),
|
||||
edit: sys => sys.replaceFileText(`/user/username/projects/myproject/packages/pkg2/package.json`, `index.js`, `other.js`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "removes those errors when a package file is changed back",
|
||||
change: sys => sys.replaceFileText(`/user/username/projects/myproject/packages/pkg2/package.json`, `other.js`, `index.js`),
|
||||
edit: sys => sys.replaceFileText(`/user/username/projects/myproject/packages/pkg2/package.json`, `other.js`, `index.js`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
]
|
||||
|
||||
@@ -19,10 +19,10 @@ describe("unittests:: tsbuildWatch:: watchMode:: with noEmit", () => {
|
||||
],
|
||||
{ currentDirectory: "/user/username/projects/myproject" }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "No change",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/a.js`, sys.readFile(`/user/username/projects/myproject/a.js`)!),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/a.js`, sys.readFile(`/user/username/projects/myproject/a.js`)!),
|
||||
// build project
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1);
|
||||
@@ -31,7 +31,7 @@ describe("unittests:: tsbuildWatch:: watchMode:: with noEmit", () => {
|
||||
},
|
||||
{
|
||||
caption: "change",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/a.js`, "const x = 10;"),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/a.js`, "const x = 10;"),
|
||||
// build project
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1);
|
||||
|
||||
@@ -13,7 +13,7 @@ describe("unittests:: tsbuildWatch:: watchMode:: with noEmitOnError", () => {
|
||||
function change(caption: string, content: string): TscWatchCompileChange {
|
||||
return {
|
||||
caption,
|
||||
change: sys => sys.writeFile(`/user/username/projects/noEmitOnError/src/main.ts`, content),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/noEmitOnError/src/main.ts`, content),
|
||||
// build project
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1);
|
||||
@@ -24,7 +24,7 @@ describe("unittests:: tsbuildWatch:: watchMode:: with noEmitOnError", () => {
|
||||
|
||||
const noChange: TscWatchCompileChange = {
|
||||
caption: "No change",
|
||||
change: sys => sys.writeFile(`/user/username/projects/noEmitOnError/src/main.ts`, sys.readFile(`/user/username/projects/noEmitOnError/src/main.ts`)!),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/noEmitOnError/src/main.ts`, sys.readFile(`/user/username/projects/noEmitOnError/src/main.ts`)!),
|
||||
// build project
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1);
|
||||
@@ -43,7 +43,7 @@ describe("unittests:: tsbuildWatch:: watchMode:: with noEmitOnError", () => {
|
||||
],
|
||||
{ currentDirectory: `/user/username/projects/noEmitOnError` }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
noChange,
|
||||
change("Fix Syntax error", `import { A } from "../shared/types/db";
|
||||
const a = {
|
||||
|
||||
@@ -50,7 +50,7 @@ describe("unittests:: tsbuildWatch:: watchMode:: program updates", () => {
|
||||
function changeFile(fileName: string | (() => string), content: string | (() => string), caption: string): TscWatchCompileChange {
|
||||
return {
|
||||
caption,
|
||||
change: sys => sys.writeFile(ts.isString(fileName) ? fileName : fileName(), ts.isString(content) ? content : content()),
|
||||
edit: sys => sys.writeFile(ts.isString(fileName) ? fileName : fileName(), ts.isString(content) ? content : content()),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1), // Builds core
|
||||
};
|
||||
}
|
||||
@@ -86,7 +86,6 @@ describe("unittests:: tsbuildWatch:: watchMode:: program updates", () => {
|
||||
subScenario: "creates solution in watch mode",
|
||||
commandLineArgs: ["-b", "-w", `sample1/${SubProject.tests}`],
|
||||
sys: () => createWatchedSystem(allFiles, { currentDirectory: "/user/username/projects" }),
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
it("verify building references watches only those projects", () => {
|
||||
@@ -102,7 +101,6 @@ describe("unittests:: tsbuildWatch:: watchMode:: program updates", () => {
|
||||
baseline,
|
||||
oldSnap,
|
||||
getPrograms,
|
||||
changes: ts.emptyArray,
|
||||
watchOrSolution: solutionBuilder
|
||||
});
|
||||
});
|
||||
@@ -117,7 +115,7 @@ describe("unittests:: tsbuildWatch:: watchMode:: program updates", () => {
|
||||
function verifyProjectChanges(subScenario: string, allFilesGetter: () => readonly File[]) {
|
||||
const buildLogicAndTests: TscWatchCompileChange = {
|
||||
caption: "Build logic and tests",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1);
|
||||
sys.checkTimeoutQueueLength(0);
|
||||
@@ -132,7 +130,7 @@ describe("unittests:: tsbuildWatch:: watchMode:: program updates", () => {
|
||||
allFilesGetter(),
|
||||
{ currentDirectory: "/user/username/projects" }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
changeCore(() => `${core[1].content}
|
||||
export class someClass { }`, "Make change to core"),
|
||||
buildLogicAndTests,
|
||||
@@ -141,7 +139,7 @@ export class someClass { }`, "Make change to core"),
|
||||
buildLogicAndTests,
|
||||
{
|
||||
caption: "Make two changes",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
const change1 = `${core[1].content}
|
||||
export class someClass { }`;
|
||||
sys.writeFile(core[1].path, change1);
|
||||
@@ -164,7 +162,7 @@ export class someClass2 { }`);
|
||||
allFilesGetter(),
|
||||
{ currentDirectory: "/user/username/projects" }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
changeCore(() => `${core[1].content}
|
||||
function foo() { }`, "Make local change to core"),
|
||||
]
|
||||
@@ -181,7 +179,7 @@ function foo() { }`, "Make local change to core"),
|
||||
allFilesGetter(),
|
||||
{ currentDirectory: "/user/username/projects" }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
changeNewFile(newFile.content),
|
||||
buildLogicAndTests,
|
||||
changeNewFile(`${newFile.content}
|
||||
@@ -224,15 +222,15 @@ export class someClass2 { }`),
|
||||
[libFile, ...core, logic[1], ...tests],
|
||||
{ currentDirectory: "/user/username/projects" }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Write logic tsconfig and build logic",
|
||||
change: sys => sys.writeFile(logic[0].path, logic[0].content),
|
||||
edit: sys => sys.writeFile(logic[0].path, logic[0].content),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1), // Builds logic
|
||||
},
|
||||
{
|
||||
caption: "Build Tests",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
// Build tests
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1);
|
||||
@@ -255,7 +253,7 @@ export class someClass2 { }`),
|
||||
});
|
||||
const buildLogic: TscWatchCompileChange = {
|
||||
caption: "Build logic",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
// Builds logic
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1);
|
||||
@@ -286,7 +284,7 @@ export class someClass2 { }`),
|
||||
};
|
||||
return createWatchedSystem([libFile, coreTsConfig, coreIndex, logicTsConfig, logicIndex], { currentDirectory: "/user/username/projects" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
changeCore(() => `${coreIndex.content}
|
||||
function myFunc() { return 10; }`, "Make non local change and build core"),
|
||||
buildLogic,
|
||||
@@ -337,11 +335,11 @@ createSomeObject().message;`
|
||||
const files = [libFile, libraryTs, libraryTsconfig, appTs, appTsconfig];
|
||||
return createWatchedSystem(files, { currentDirectory: `${"/user/username/projects"}/sample1` });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Introduce error",
|
||||
// Change message in library to message2
|
||||
change: sys => sys.writeFile(libraryTs.path, libraryTs.content.replace(/message/g, "message2")),
|
||||
edit: sys => sys.writeFile(libraryTs.path, libraryTs.content.replace(/message/g, "message2")),
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // Build library
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // Build App
|
||||
@@ -350,7 +348,7 @@ createSomeObject().message;`
|
||||
{
|
||||
caption: "Fix error",
|
||||
// Revert library changes
|
||||
change: sys => sys.writeFile(libraryTs.path, libraryTs.content),
|
||||
edit: sys => sys.writeFile(libraryTs.path, libraryTs.content),
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // Build library
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // Build App
|
||||
@@ -368,10 +366,10 @@ createSomeObject().message;`
|
||||
subScenario: `reportErrors/${subScenario}`,
|
||||
commandLineArgs: ["-b", "-w", `sample1/${SubProject.tests}`, ...buildOptions],
|
||||
sys: () => createWatchedSystem(allFiles, { currentDirectory: "/user/username/projects" }),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "change logic",
|
||||
change: sys => sys.writeFile(logic[1].path, `${logic[1].content}
|
||||
edit: sys => sys.writeFile(logic[1].path, `${logic[1].content}
|
||||
let y: string = 10;`),
|
||||
// Builds logic
|
||||
timeouts: sys => {
|
||||
@@ -381,7 +379,7 @@ let y: string = 10;`),
|
||||
},
|
||||
{
|
||||
caption: "change core",
|
||||
change: sys => sys.writeFile(core[1].path, `${core[1].content}
|
||||
edit: sys => sys.writeFile(core[1].path, `${core[1].content}
|
||||
let x: string = 10;`),
|
||||
// Builds core
|
||||
timeouts: sys => {
|
||||
@@ -427,13 +425,13 @@ let x: string = 10;`),
|
||||
const fixError: TscWatchCompileChange = {
|
||||
caption: "Fix error in fileWithError",
|
||||
// Fix error
|
||||
change: sys => sys.writeFile(fileWithError.path, fileWithFixedError.content),
|
||||
edit: sys => sys.writeFile(fileWithError.path, fileWithFixedError.content),
|
||||
timeouts: incrementalBuild
|
||||
};
|
||||
|
||||
const changeFileWithoutError: TscWatchCompileChange = {
|
||||
caption: "Change fileWithoutError",
|
||||
change: sys => sys.writeFile(fileWithoutError.path, fileWithoutError.content.replace(/myClass/g, "myClass2")),
|
||||
edit: sys => sys.writeFile(fileWithoutError.path, fileWithoutError.content.replace(/myClass/g, "myClass2")),
|
||||
timeouts: incrementalBuild
|
||||
};
|
||||
|
||||
@@ -445,7 +443,7 @@ let x: string = 10;`),
|
||||
[libFile, fileWithError, fileWithoutError, tsconfig],
|
||||
{ currentDirectory: `${"/user/username/projects"}/${solution}` }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
fixError
|
||||
]
|
||||
});
|
||||
@@ -458,7 +456,7 @@ let x: string = 10;`),
|
||||
[libFile, fileWithError, fileWithoutError, tsconfig],
|
||||
{ currentDirectory: `${"/user/username/projects"}/${solution}` }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
changeFileWithoutError
|
||||
]
|
||||
});
|
||||
@@ -466,7 +464,7 @@ let x: string = 10;`),
|
||||
describe("when reporting errors on introducing error", () => {
|
||||
const introduceError: TscWatchCompileChange = {
|
||||
caption: "Introduce error",
|
||||
change: sys => sys.writeFile(fileWithError.path, fileWithError.content),
|
||||
edit: sys => sys.writeFile(fileWithError.path, fileWithError.content),
|
||||
timeouts: incrementalBuild,
|
||||
};
|
||||
|
||||
@@ -478,7 +476,7 @@ let x: string = 10;`),
|
||||
[libFile, fileWithFixedError, fileWithoutError, tsconfig],
|
||||
{ currentDirectory: `${"/user/username/projects"}/${solution}` }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
introduceError,
|
||||
fixError
|
||||
]
|
||||
@@ -492,7 +490,7 @@ let x: string = 10;`),
|
||||
[libFile, fileWithFixedError, fileWithoutError, tsconfig],
|
||||
{ currentDirectory: `${"/user/username/projects"}/${solution}` }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
introduceError,
|
||||
changeFileWithoutError
|
||||
]
|
||||
@@ -506,10 +504,10 @@ let x: string = 10;`),
|
||||
subScenario: "incremental updates in verbose mode",
|
||||
commandLineArgs: ["-b", "-w", `sample1/${SubProject.tests}`, "-verbose"],
|
||||
sys: () => createWatchedSystem(allFiles, { currentDirectory: "/user/username/projects" }),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Make non dts change",
|
||||
change: sys => sys.writeFile(logic[1].path, `${logic[1].content}
|
||||
edit: sys => sys.writeFile(logic[1].path, `${logic[1].content}
|
||||
function someFn() { }`),
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // build logic and updates tests
|
||||
@@ -518,7 +516,7 @@ function someFn() { }`),
|
||||
},
|
||||
{
|
||||
caption: "Make dts change",
|
||||
change: sys => sys.writeFile(logic[1].path, `${logic[1].content}
|
||||
edit: sys => sys.writeFile(logic[1].path, `${logic[1].content}
|
||||
export function someFn() { }`),
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // build logic
|
||||
@@ -547,10 +545,10 @@ export function someFn() { }`),
|
||||
};
|
||||
return createWatchedSystem([index, configFile, libFile], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Change tsconfig to set noUnusedParameters to false",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({
|
||||
compilerOptions: {
|
||||
noUnusedParameters: false
|
||||
}
|
||||
@@ -565,11 +563,11 @@ export function someFn() { }`),
|
||||
subScenario: "should not trigger recompilation because of program emit",
|
||||
commandLineArgs: ["-b", "-w", `sample1/${SubProject.core}`, "-verbose"],
|
||||
sys: () => createWatchedSystem([libFile, ...core], { currentDirectory: "/user/username/projects" }),
|
||||
changes: [
|
||||
edits: [
|
||||
noopChange,
|
||||
{
|
||||
caption: "Add new file",
|
||||
change: sys => sys.writeFile(`sample1/${SubProject.core}/file3.ts`, `export const y = 10;`),
|
||||
edit: sys => sys.writeFile(`sample1/${SubProject.core}/file3.ts`, `export const y = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
noopChange,
|
||||
@@ -585,11 +583,11 @@ export function someFn() { }`),
|
||||
const newCoreConfig: File = { path: coreConfig.path, content: JSON.stringify({ compilerOptions: { composite: true, outDir: "outDir" } }) };
|
||||
return createWatchedSystem([libFile, newCoreConfig, ...rest], { currentDirectory: "/user/username/projects" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
noopChange,
|
||||
{
|
||||
caption: "Add new file",
|
||||
change: sys => sys.writeFile(`sample1/${SubProject.core}/file3.ts`, `export const y = 10;`),
|
||||
edit: sys => sys.writeFile(`sample1/${SubProject.core}/file3.ts`, `export const y = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
noopChange
|
||||
@@ -641,17 +639,17 @@ export function someFn() { }`),
|
||||
bravoExtendedConfigFile, project2Config, otherFile
|
||||
], { currentDirectory: "/a/b" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Modify alpha config",
|
||||
change: sys => sys.writeFile("/a/b/alpha.tsconfig.json", JSON.stringify({
|
||||
edit: sys => sys.writeFile("/a/b/alpha.tsconfig.json", JSON.stringify({
|
||||
compilerOptions: { strict: true }
|
||||
})),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1) // Build project1
|
||||
},
|
||||
{
|
||||
caption: "Build project 2",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: sys => { // Build project2
|
||||
sys.checkTimeoutQueueLengthAndRun(1);
|
||||
sys.checkTimeoutQueueLength(0);
|
||||
@@ -659,7 +657,7 @@ export function someFn() { }`),
|
||||
},
|
||||
{
|
||||
caption: "change bravo config",
|
||||
change: sys => sys.writeFile("/a/b/bravo.tsconfig.json", JSON.stringify({
|
||||
edit: sys => sys.writeFile("/a/b/bravo.tsconfig.json", JSON.stringify({
|
||||
extends: "./alpha.tsconfig.json",
|
||||
compilerOptions: { strict: false }
|
||||
})),
|
||||
@@ -670,7 +668,7 @@ export function someFn() { }`),
|
||||
},
|
||||
{
|
||||
caption: "project 2 extends alpha",
|
||||
change: sys => sys.writeFile("/a/b/project2.tsconfig.json", JSON.stringify({
|
||||
edit: sys => sys.writeFile("/a/b/project2.tsconfig.json", JSON.stringify({
|
||||
extends: "./alpha.tsconfig.json",
|
||||
})),
|
||||
timeouts: sys => { // Build project2
|
||||
@@ -680,12 +678,12 @@ export function someFn() { }`),
|
||||
},
|
||||
{
|
||||
caption: "update aplha config",
|
||||
change: sys => sys.writeFile("/a/b/alpha.tsconfig.json", "{}"),
|
||||
edit: sys => sys.writeFile("/a/b/alpha.tsconfig.json", "{}"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1), // build project1
|
||||
},
|
||||
{
|
||||
caption: "Build project 2",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: sys => { // Build project2
|
||||
sys.checkTimeoutQueueLengthAndRun(1);
|
||||
sys.checkTimeoutQueueLength(0);
|
||||
@@ -759,10 +757,10 @@ export function someFn() { }`),
|
||||
bravoExtendedConfigFile, project2Config, otherFile
|
||||
], { currentDirectory: "/a/b" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Remove project2 from base config",
|
||||
change: sys => sys.modifyFile("/a/b/tsconfig.json", JSON.stringify({
|
||||
edit: sys => sys.modifyFile("/a/b/tsconfig.json", JSON.stringify({
|
||||
references: [
|
||||
{
|
||||
path: "./project1.tsconfig.json",
|
||||
@@ -788,6 +786,5 @@ export function someFn() { }`),
|
||||
[libFile.path]: libFile.content,
|
||||
}),
|
||||
commandLineArgs: ["--b", "src/project", "-i", "-w"],
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
});
|
||||
@@ -50,7 +50,7 @@ describe("unittests:: tsbuildWatch:: watchMode:: projectsBuilding", () => {
|
||||
function checkBuildPkg(startIndex: number, count: number): TscWatchCompileChange {
|
||||
return {
|
||||
caption: `build ${pkgs(index => `pkg${index}`, count, startIndex).join(",")}`,
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
};
|
||||
}
|
||||
@@ -62,16 +62,16 @@ describe("unittests:: tsbuildWatch:: watchMode:: projectsBuilding", () => {
|
||||
[libFile, ...ts.flatMap(pkgs(pkgFiles, 3), ts.identity), solution(3)],
|
||||
{ currentDirectory: "/user/username/projects/myproject" }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "dts doesn't change",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `const someConst2 = 10;`),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `const someConst2 = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1), // Build pkg0 and update timestamps
|
||||
},
|
||||
noopChange,
|
||||
{
|
||||
caption: "dts change",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `export const someConst = 10;`),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `export const someConst = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1) // Build pkg0
|
||||
},
|
||||
checkBuildPkg(1, 2),
|
||||
@@ -86,16 +86,16 @@ describe("unittests:: tsbuildWatch:: watchMode:: projectsBuilding", () => {
|
||||
[libFile, ...ts.flatMap(pkgs(pkgFiles, 5), ts.identity), solution(5)],
|
||||
{ currentDirectory: "/user/username/projects/myproject" }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "dts doesn't change",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `const someConst2 = 10;`),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `const someConst2 = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1), // Build pkg0 and update timestamps
|
||||
},
|
||||
noopChange,
|
||||
{
|
||||
caption: "dts change",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `export const someConst = 10;`),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `export const someConst = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1) // Build pkg0
|
||||
},
|
||||
checkBuildPkg(1, 4),
|
||||
@@ -110,16 +110,16 @@ describe("unittests:: tsbuildWatch:: watchMode:: projectsBuilding", () => {
|
||||
[libFile, ...ts.flatMap(pkgs(pkgFiles, 8), ts.identity), solution(8)],
|
||||
{ currentDirectory: "/user/username/projects/myproject" }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "dts doesn't change",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `const someConst2 = 10;`),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `const someConst2 = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1), // Build pkg0 and update timestamps
|
||||
},
|
||||
noopChange,
|
||||
{
|
||||
caption: "dts change",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `export const someConst = 10;`),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `export const someConst = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1) // Build pkg0
|
||||
},
|
||||
checkBuildPkg(1, 5),
|
||||
@@ -127,13 +127,13 @@ describe("unittests:: tsbuildWatch:: watchMode:: projectsBuilding", () => {
|
||||
noopChange,
|
||||
{
|
||||
caption: "dts change2",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `export const someConst3 = 10;`),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `export const someConst3 = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1) // Build pkg0
|
||||
},
|
||||
checkBuildPkg(1, 5),
|
||||
{
|
||||
caption: "change while building",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `const someConst4 = 10;`),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `const someConst4 = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1) // Build pkg0
|
||||
},
|
||||
checkBuildPkg(6, 2),
|
||||
@@ -148,16 +148,16 @@ describe("unittests:: tsbuildWatch:: watchMode:: projectsBuilding", () => {
|
||||
[libFile, ...ts.flatMap(pkgs(pkgFiles, 23), ts.identity), solution(23)],
|
||||
{ currentDirectory: "/user/username/projects/myproject" }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "dts doesn't change",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `const someConst2 = 10;`),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `const someConst2 = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1), // Build pkg0 and update timestamps
|
||||
},
|
||||
noopChange,
|
||||
{
|
||||
caption: "dts change",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `export const someConst = 10;`),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `export const someConst = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1) // Build pkg0
|
||||
},
|
||||
checkBuildPkg(1, 5),
|
||||
@@ -168,20 +168,20 @@ describe("unittests:: tsbuildWatch:: watchMode:: projectsBuilding", () => {
|
||||
noopChange,
|
||||
{
|
||||
caption: "dts change2",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `export const someConst3 = 10;`),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `export const someConst3 = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1) // Build pkg0
|
||||
},
|
||||
checkBuildPkg(1, 5),
|
||||
checkBuildPkg(6, 5),
|
||||
{
|
||||
caption: "change while building",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `const someConst4 = 10;`),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `const someConst4 = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1) // Build pkg0
|
||||
},
|
||||
checkBuildPkg(11, 5),
|
||||
{
|
||||
caption: "change while building: dts changes",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `export const someConst5 = 10;`),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/pkg0/index.ts`, `export const someConst5 = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1) // Build pkg0
|
||||
},
|
||||
checkBuildPkg(1, 5),
|
||||
|
||||
@@ -64,10 +64,10 @@ export function f22() { } // trailing`
|
||||
baseline,
|
||||
oldSnap,
|
||||
getPrograms,
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "change to shared",
|
||||
change: sys => sys.prependFile(sharedIndex.path, "export function fooBar() {}"),
|
||||
edit: sys => sys.prependFile(sharedIndex.path, "export function fooBar() {}"),
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // Shared
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // webpack and solution
|
||||
|
||||
@@ -23,10 +23,10 @@ describe("unittests:: tsbuildWatch:: watchMode:: with reexport when referenced p
|
||||
],
|
||||
{ currentDirectory: `/user/username/projects/reexport` }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Introduce error",
|
||||
change: sys => sys.replaceFileText(`/user/username/projects/reexport/src/pure/session.ts`, "// ", ""),
|
||||
edit: sys => sys.replaceFileText(`/user/username/projects/reexport/src/pure/session.ts`, "// ", ""),
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // build src/pure
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // build src/main and src
|
||||
@@ -35,7 +35,7 @@ describe("unittests:: tsbuildWatch:: watchMode:: with reexport when referenced p
|
||||
},
|
||||
{
|
||||
caption: "Fix error",
|
||||
change: sys => sys.replaceFileText(`/user/username/projects/reexport/src/pure/session.ts`, "bar: ", "// bar: "),
|
||||
edit: sys => sys.replaceFileText(`/user/username/projects/reexport/src/pure/session.ts`, "bar: ", "// bar: "),
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // build src/pure
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // build src/main and src
|
||||
|
||||
@@ -36,10 +36,10 @@ describe("unittests:: tsbuildWatch:: watchEnvironment:: tsbuild:: watchMode:: wi
|
||||
baseline,
|
||||
oldSnap,
|
||||
getPrograms,
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "modify typing file",
|
||||
change: sys => sys.writeFile(typing.path, `${typing.content}export const typing1 = 10;`),
|
||||
edit: sys => sys.writeFile(typing.path, `${typing.content}export const typing1 = 10;`),
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1);
|
||||
sys.checkTimeoutQueueLengthAndRun(1);
|
||||
@@ -49,7 +49,7 @@ describe("unittests:: tsbuildWatch:: watchEnvironment:: tsbuild:: watchMode:: wi
|
||||
{
|
||||
// Make change
|
||||
caption: "change pkg references",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
maxPkgs--;
|
||||
writePkgReferences(sys);
|
||||
},
|
||||
@@ -57,7 +57,7 @@ describe("unittests:: tsbuildWatch:: watchEnvironment:: tsbuild:: watchMode:: wi
|
||||
},
|
||||
{
|
||||
caption: "modify typing file",
|
||||
change: sys => sys.writeFile(typing.path, typing.content),
|
||||
edit: sys => sys.writeFile(typing.path, typing.content),
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1);
|
||||
sys.checkTimeoutQueueLengthAndRun(1);
|
||||
@@ -67,7 +67,7 @@ describe("unittests:: tsbuildWatch:: watchEnvironment:: tsbuild:: watchMode:: wi
|
||||
{
|
||||
// Make change to remove all watches
|
||||
caption: "change pkg references to remove all watches",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
maxPkgs = 0;
|
||||
writePkgReferences(sys);
|
||||
},
|
||||
@@ -75,7 +75,7 @@ describe("unittests:: tsbuildWatch:: watchEnvironment:: tsbuild:: watchMode:: wi
|
||||
},
|
||||
{
|
||||
caption: "modify typing file",
|
||||
change: sys => sys.writeFile(typing.path, `${typing.content}export const typing1 = 10;`),
|
||||
edit: sys => sys.writeFile(typing.path, `${typing.content}export const typing1 = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(0),
|
||||
},
|
||||
],
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
CommandLineProgram,
|
||||
} from "../tsc/helpers";
|
||||
import {
|
||||
applyChange,
|
||||
applyEdit,
|
||||
createBaseline,
|
||||
watchBaseline,
|
||||
} from "../tscWatch/helpers";
|
||||
@@ -87,7 +87,7 @@ describe("unittests:: tsc:: builder cancellationToken", () => {
|
||||
|
||||
// Cancel on first semantic operation
|
||||
// Change
|
||||
oldSnap = applyChange(
|
||||
oldSnap = applyEdit(
|
||||
sys,
|
||||
baseline,
|
||||
sys => sys.appendFile(cFile.path, "export function foo() {}"),
|
||||
@@ -125,7 +125,7 @@ describe("unittests:: tsc:: builder cancellationToken", () => {
|
||||
Harness.Baseline.runBaseline(`tsc/cancellationToken/${scenario.split(" ").join("-")}.js`, baseline.join("\r\n"));
|
||||
|
||||
function noChange(caption: string) {
|
||||
oldSnap = applyChange(sys, baseline, ts.noop, caption);
|
||||
oldSnap = applyEdit(sys, baseline, ts.noop, caption);
|
||||
}
|
||||
|
||||
function updatePrograms() {
|
||||
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
loadProjectFromFiles,
|
||||
replaceText,
|
||||
verifyTsc,
|
||||
verifyTscWithEdits,
|
||||
} from "./helpers";
|
||||
|
||||
describe("unittests:: tsc:: composite::", () => {
|
||||
@@ -89,7 +88,7 @@ describe("unittests:: tsc:: composite::", () => {
|
||||
commandLineArgs: ["--composite", "false", "--p", "src/project", "--tsBuildInfoFile", "null"],
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "composite",
|
||||
subScenario: "converting to modules",
|
||||
fs: () => loadProjectFromFiles({
|
||||
@@ -104,8 +103,8 @@ describe("unittests:: tsc:: composite::", () => {
|
||||
commandLineArgs: ["-p", "/src/project"],
|
||||
edits: [
|
||||
{
|
||||
subScenario: "convert to modules",
|
||||
modifyFs: fs => replaceText(fs, "/src/project/tsconfig.json", "none", "es2015"),
|
||||
caption: "convert to modules",
|
||||
edit: fs => replaceText(fs, "/src/project/tsconfig.json", "none", "es2015"),
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -29,7 +29,6 @@ describe("unittests:: tsc:: declarationEmit::", () => {
|
||||
subScenario,
|
||||
sys: () => createWatchedSystem(files, { currentDirectory: "/user/username/projects/myproject" }),
|
||||
commandLineArgs: ["-p", rootProject, "--explainFiles"],
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
});
|
||||
|
||||
@@ -43,7 +42,6 @@ describe("unittests:: tsc:: declarationEmit::", () => {
|
||||
{ currentDirectory: "/user/username/projects/myproject" }
|
||||
),
|
||||
commandLineArgs: ["-p", rootProject, "--explainFiles"],
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ export function compilerOptionsToConfigJson(options: ts.CompilerOptions) {
|
||||
}
|
||||
|
||||
export const noChangeRun: TestTscEdit = {
|
||||
subScenario: "no-change-run",
|
||||
modifyFs: ts.noop
|
||||
caption: "no-change-run",
|
||||
edit: ts.noop
|
||||
};
|
||||
export const noChangeOnlyRuns = [noChangeRun];
|
||||
|
||||
@@ -354,13 +354,6 @@ export function verifyTscCompileLike<T extends VerifyTscCompileLike>(verifier: (
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify by baselining after initializing FS and command line compile
|
||||
*/
|
||||
export function verifyTsc(input: TestTscCompile) {
|
||||
verifyTscCompileLike(testTscCompile, input);
|
||||
}
|
||||
|
||||
export function replaceText(fs: vfs.FileSystem, path: string, oldText: string, newText: string) {
|
||||
if (!fs.statSync(path).isFile()) {
|
||||
throw new Error(`File ${path} does not exist`);
|
||||
@@ -684,30 +677,33 @@ export function baselineBuildInfo(
|
||||
}
|
||||
interface VerifyTscEditDiscrepanciesInput {
|
||||
index: number;
|
||||
edits: readonly TestTscEdit[];
|
||||
scenario: TestTscCompile["scenario"];
|
||||
subScenario: TestTscCompile["subScenario"];
|
||||
baselines: string[] | undefined;
|
||||
commandLineArgs: TestTscCompile["commandLineArgs"];
|
||||
modifyFs: TestTscCompile["modifyFs"];
|
||||
editFs: TestTscEdit["modifyFs"];
|
||||
baseFs: vfs.FileSystem;
|
||||
newSys: TscCompileSystem;
|
||||
discrepancyExplanation: TestTscEdit["discrepancyExplanation"];
|
||||
environmentVariables: TestTscCompile["environmentVariables"];
|
||||
}
|
||||
function verifyTscEditDiscrepancies({
|
||||
index, scenario, subScenario, commandLineArgs,
|
||||
discrepancyExplanation, baselines,
|
||||
modifyFs, editFs, baseFs, newSys
|
||||
index, edits, scenario, commandLineArgs, environmentVariables,
|
||||
baselines,
|
||||
modifyFs, baseFs, newSys
|
||||
}: VerifyTscEditDiscrepanciesInput): string[] | undefined {
|
||||
const { caption, discrepancyExplanation } = edits[index];
|
||||
const sys = testTscCompile({
|
||||
scenario,
|
||||
subScenario,
|
||||
subScenario: caption,
|
||||
fs: () => baseFs.makeReadonly(),
|
||||
commandLineArgs,
|
||||
commandLineArgs: edits[index].commandLineArgs || commandLineArgs,
|
||||
modifyFs: fs => {
|
||||
if (modifyFs) modifyFs(fs);
|
||||
editFs(fs);
|
||||
for (let i = 0; i <= index; i++) {
|
||||
edits[i].edit(fs);
|
||||
}
|
||||
},
|
||||
environmentVariables,
|
||||
computeDtsSignatures: true,
|
||||
});
|
||||
let headerAdded = false;
|
||||
@@ -847,7 +843,7 @@ function verifyTscEditDiscrepancies({
|
||||
|
||||
function addBaseline(...text: string[]) {
|
||||
if (!baselines || !headerAdded) {
|
||||
(baselines ||= []).push(`${index}:: ${subScenario}`, ...(discrepancyExplanation?.()|| ["*** Needs explanation"]));
|
||||
(baselines ||= []).push(`${index}:: ${caption}`, ...(discrepancyExplanation?.()|| ["*** Needs explanation"]));
|
||||
headerAdded = true;
|
||||
}
|
||||
baselines.push(...text);
|
||||
@@ -891,31 +887,30 @@ function getBuildInfoForIncrementalCorrectnessCheck(text: string | undefined): {
|
||||
}
|
||||
|
||||
export interface TestTscEdit {
|
||||
modifyFs: (fs: vfs.FileSystem) => void;
|
||||
subScenario: string;
|
||||
edit: (fs: vfs.FileSystem) => void;
|
||||
caption: string;
|
||||
commandLineArgs?: readonly string[];
|
||||
/** An array of lines to be printed in order when a discrepancy is detected */
|
||||
discrepancyExplanation?: () => readonly string[];
|
||||
}
|
||||
|
||||
export interface VerifyTscWithEditsInput extends TestTscCompile {
|
||||
edits: TestTscEdit[];
|
||||
edits?: readonly TestTscEdit[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify non watch tsc invokcation after each edit
|
||||
*/
|
||||
export function verifyTscWithEdits({
|
||||
subScenario, fs, scenario, commandLineArgs,
|
||||
export function verifyTsc({
|
||||
subScenario, fs, scenario, commandLineArgs, environmentVariables,
|
||||
baselineSourceMap, modifyFs, baselineReadFileCalls, baselinePrograms,
|
||||
edits
|
||||
}: VerifyTscWithEditsInput) {
|
||||
describe(`tsc ${commandLineArgs.join(" ")} ${scenario}:: ${subScenario} serializedEdits`, () => {
|
||||
describe(`tsc ${commandLineArgs.join(" ")} ${scenario}:: ${subScenario}`, () => {
|
||||
let sys: TscCompileSystem;
|
||||
let baseFs: vfs.FileSystem;
|
||||
let editsSys: TscCompileSystem[];
|
||||
let editsSys: TscCompileSystem[] | undefined;
|
||||
before(() => {
|
||||
ts.Debug.assert(!!edits.length, `${scenario}/${subScenario}:: No incremental scenarios, you probably want to use verifyTsc instead.`);
|
||||
baseFs = fs().makeReadonly();
|
||||
sys = testTscCompile({
|
||||
scenario,
|
||||
@@ -925,22 +920,24 @@ export function verifyTscWithEdits({
|
||||
modifyFs,
|
||||
baselineSourceMap,
|
||||
baselineReadFileCalls,
|
||||
baselinePrograms
|
||||
baselinePrograms,
|
||||
environmentVariables,
|
||||
});
|
||||
edits.forEach((
|
||||
{ modifyFs, subScenario: editScenario, commandLineArgs: editCommandLineArgs },
|
||||
edits?.forEach((
|
||||
{ edit, caption, commandLineArgs: editCommandLineArgs },
|
||||
index
|
||||
) => {
|
||||
(editsSys || (editsSys = [])).push(testTscCompile({
|
||||
scenario,
|
||||
subScenario: editScenario || subScenario,
|
||||
subScenario: caption,
|
||||
diffWithInitial: true,
|
||||
fs: () => index === 0 ? sys.vfs : editsSys[index - 1].vfs,
|
||||
fs: () => index === 0 ? sys.vfs : editsSys![index - 1].vfs,
|
||||
commandLineArgs: editCommandLineArgs || commandLineArgs,
|
||||
modifyFs,
|
||||
modifyFs: edit,
|
||||
baselineSourceMap,
|
||||
baselineReadFileCalls,
|
||||
baselinePrograms
|
||||
baselinePrograms,
|
||||
environmentVariables,
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -953,40 +950,37 @@ export function verifyTscWithEdits({
|
||||
baseLine: () => {
|
||||
const { file, text } = sys.baseLine();
|
||||
const texts: string[] = [text];
|
||||
editsSys.forEach((sys, index) => {
|
||||
const incrementalScenario = edits[index];
|
||||
editsSys?.forEach((sys, index) => {
|
||||
const incrementalScenario = edits![index];
|
||||
texts.push("");
|
||||
texts.push(`Change:: ${incrementalScenario.subScenario}`);
|
||||
texts.push(`Change:: ${incrementalScenario.caption}`);
|
||||
texts.push(sys.baseLine().text);
|
||||
});
|
||||
return { file, text: texts.join("\r\n") };
|
||||
}
|
||||
}));
|
||||
it("tsc invocation after edit and clean build correctness", () => {
|
||||
let baselines: string[] | undefined;
|
||||
for (let index = 0; index < edits.length; index++) {
|
||||
baselines = verifyTscEditDiscrepancies({
|
||||
index,
|
||||
scenario,
|
||||
subScenario: edits[index].subScenario,
|
||||
baselines,
|
||||
baseFs,
|
||||
newSys: editsSys[index],
|
||||
commandLineArgs: edits[index].commandLineArgs || commandLineArgs,
|
||||
discrepancyExplanation: edits[index].discrepancyExplanation,
|
||||
editFs: fs => {
|
||||
for (let i = 0; i <= index; i++) {
|
||||
edits[i].modifyFs(fs);
|
||||
}
|
||||
},
|
||||
modifyFs
|
||||
});
|
||||
}
|
||||
Harness.Baseline.runBaseline(
|
||||
`${ts.isBuild(commandLineArgs) ? "tsbuild" : "tsc"}/${scenario}/${subScenario.split(" ").join("-")}-discrepancies.js`,
|
||||
baselines ? baselines.join("\r\n") : null // eslint-disable-line no-null/no-null
|
||||
);
|
||||
});
|
||||
if (edits?.length) {
|
||||
it("tsc invocation after edit and clean build correctness", () => {
|
||||
let baselines: string[] | undefined;
|
||||
for (let index = 0; index < edits.length; index++) {
|
||||
baselines = verifyTscEditDiscrepancies({
|
||||
index,
|
||||
edits,
|
||||
scenario,
|
||||
baselines,
|
||||
baseFs,
|
||||
newSys: editsSys![index],
|
||||
commandLineArgs,
|
||||
modifyFs,
|
||||
environmentVariables,
|
||||
});
|
||||
}
|
||||
Harness.Baseline.runBaseline(
|
||||
`${ts.isBuild(commandLineArgs) ? "tsbuild" : "tsc"}/${scenario}/${subScenario.split(" ").join("-")}-discrepancies.js`,
|
||||
baselines ? baselines.join("\r\n") : null // eslint-disable-line no-null/no-null
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,10 @@ import {
|
||||
replaceText,
|
||||
TestTscEdit,
|
||||
verifyTsc,
|
||||
verifyTscWithEdits,
|
||||
} from "./helpers";
|
||||
|
||||
describe("unittests:: tsc:: incremental::", () => {
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "when passing filename for buildinfo on commandline",
|
||||
fs: () => loadProjectFromFiles({
|
||||
@@ -37,7 +36,7 @@ describe("unittests:: tsc:: incremental::", () => {
|
||||
edits: noChangeOnlyRuns
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "when passing rootDir from commandline",
|
||||
fs: () => loadProjectFromFiles({
|
||||
@@ -54,7 +53,7 @@ describe("unittests:: tsc:: incremental::", () => {
|
||||
edits: noChangeOnlyRuns
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "with only dts files",
|
||||
fs: () => loadProjectFromFiles({
|
||||
@@ -66,13 +65,13 @@ describe("unittests:: tsc:: incremental::", () => {
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "incremental-declaration-doesnt-change",
|
||||
modifyFs: fs => appendText(fs, "/src/project/src/main.d.ts", "export const xy = 100;")
|
||||
caption: "incremental-declaration-doesnt-change",
|
||||
edit: fs => appendText(fs, "/src/project/src/main.d.ts", "export const xy = 100;")
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "when passing rootDir is in the tsconfig",
|
||||
fs: () => loadProjectFromFiles({
|
||||
@@ -90,7 +89,7 @@ describe("unittests:: tsc:: incremental::", () => {
|
||||
edits: noChangeOnlyRuns
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "tsbuildinfo has error",
|
||||
fs: () => loadProjectFromFiles({
|
||||
@@ -100,8 +99,8 @@ describe("unittests:: tsc:: incremental::", () => {
|
||||
}),
|
||||
commandLineArgs: ["--p", "src/project", "-i"],
|
||||
edits: [{
|
||||
subScenario: "tsbuildinfo written has error",
|
||||
modifyFs: fs => prependText(fs, "/src/project/tsconfig.tsbuildinfo", "Some random string"),
|
||||
caption: "tsbuildinfo written has error",
|
||||
edit: fs => prependText(fs, "/src/project/tsconfig.tsbuildinfo", "Some random string"),
|
||||
}]
|
||||
});
|
||||
|
||||
@@ -114,8 +113,8 @@ describe("unittests:: tsc:: incremental::", () => {
|
||||
projFs = undefined!;
|
||||
});
|
||||
|
||||
function verifyNoEmitOnError(subScenario: string, fixModifyFs: TestTscEdit["modifyFs"], modifyFs?: TestTscEdit["modifyFs"]) {
|
||||
verifyTscWithEdits({
|
||||
function verifyNoEmitOnError(subScenario: string, fixModifyFs: TestTscEdit["edit"], modifyFs?: TestTscEdit["edit"]) {
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario,
|
||||
fs: () => projFs,
|
||||
@@ -124,8 +123,8 @@ describe("unittests:: tsc:: incremental::", () => {
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "incremental-declaration-doesnt-change",
|
||||
modifyFs: fixModifyFs
|
||||
caption: "incremental-declaration-doesnt-change",
|
||||
edit: fixModifyFs
|
||||
},
|
||||
noChangeRun,
|
||||
],
|
||||
@@ -161,7 +160,7 @@ const a: string = 10;`, "utf-8"),
|
||||
];
|
||||
const noChangeRunWithNoEmit: TestTscEdit = {
|
||||
...noChangeRun,
|
||||
subScenario: "No Change run with noEmit",
|
||||
caption: "No Change run with noEmit",
|
||||
commandLineArgs: ["--p", "src/project", "--noEmit"],
|
||||
discrepancyExplanation: compilerOptions.composite ?
|
||||
discrepancyExplanation :
|
||||
@@ -169,7 +168,7 @@ const a: string = 10;`, "utf-8"),
|
||||
};
|
||||
const noChangeRunWithEmit: TestTscEdit = {
|
||||
...noChangeRun,
|
||||
subScenario: "No Change run with emit",
|
||||
caption: "No Change run with emit",
|
||||
commandLineArgs: ["--p", "src/project"],
|
||||
};
|
||||
let optionsString = "";
|
||||
@@ -179,7 +178,7 @@ const a: string = 10;`, "utf-8"),
|
||||
}
|
||||
}
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: `noEmit changes${optionsString}`,
|
||||
commandLineArgs: ["--p", "src/project"],
|
||||
@@ -188,33 +187,33 @@ const a: string = 10;`, "utf-8"),
|
||||
noChangeRunWithNoEmit,
|
||||
noChangeRunWithNoEmit,
|
||||
{
|
||||
subScenario: "Introduce error but still noEmit",
|
||||
caption: "Introduce error but still noEmit",
|
||||
commandLineArgs: ["--p", "src/project", "--noEmit"],
|
||||
modifyFs: fs => replaceText(fs, "/src/project/src/class.ts", "prop", "prop1"),
|
||||
edit: fs => replaceText(fs, "/src/project/src/class.ts", "prop", "prop1"),
|
||||
discrepancyExplanation: compilerOptions.composite ?
|
||||
discrepancyExplanation :
|
||||
undefined,
|
||||
},
|
||||
{
|
||||
subScenario: "Fix error and emit",
|
||||
modifyFs: fs => replaceText(fs, "/src/project/src/class.ts", "prop1", "prop"),
|
||||
caption: "Fix error and emit",
|
||||
edit: fs => replaceText(fs, "/src/project/src/class.ts", "prop1", "prop"),
|
||||
},
|
||||
noChangeRunWithEmit,
|
||||
noChangeRunWithNoEmit,
|
||||
noChangeRunWithNoEmit,
|
||||
noChangeRunWithEmit,
|
||||
{
|
||||
subScenario: "Introduce error and emit",
|
||||
modifyFs: fs => replaceText(fs, "/src/project/src/class.ts", "prop", "prop1"),
|
||||
caption: "Introduce error and emit",
|
||||
edit: fs => replaceText(fs, "/src/project/src/class.ts", "prop", "prop1"),
|
||||
},
|
||||
noChangeRunWithEmit,
|
||||
noChangeRunWithNoEmit,
|
||||
noChangeRunWithNoEmit,
|
||||
noChangeRunWithEmit,
|
||||
{
|
||||
subScenario: "Fix error and no emit",
|
||||
caption: "Fix error and no emit",
|
||||
commandLineArgs: ["--p", "src/project", "--noEmit"],
|
||||
modifyFs: fs => replaceText(fs, "/src/project/src/class.ts", "prop1", "prop"),
|
||||
edit: fs => replaceText(fs, "/src/project/src/class.ts", "prop1", "prop"),
|
||||
discrepancyExplanation: compilerOptions.composite ?
|
||||
discrepancyExplanation :
|
||||
undefined,
|
||||
@@ -226,7 +225,7 @@ const a: string = 10;`, "utf-8"),
|
||||
],
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: `noEmit changes with initial noEmit${optionsString}`,
|
||||
commandLineArgs: ["--p", "src/project", "--noEmit"],
|
||||
@@ -234,13 +233,13 @@ const a: string = 10;`, "utf-8"),
|
||||
edits: [
|
||||
noChangeRunWithEmit,
|
||||
{
|
||||
subScenario: "Introduce error with emit",
|
||||
caption: "Introduce error with emit",
|
||||
commandLineArgs: ["--p", "src/project"],
|
||||
modifyFs: fs => replaceText(fs, "/src/project/src/class.ts", "prop", "prop1"),
|
||||
edit: fs => replaceText(fs, "/src/project/src/class.ts", "prop", "prop1"),
|
||||
},
|
||||
{
|
||||
subScenario: "Fix error and no emit",
|
||||
modifyFs: fs => replaceText(fs, "/src/project/src/class.ts", "prop1", "prop"),
|
||||
caption: "Fix error and no emit",
|
||||
edit: fs => replaceText(fs, "/src/project/src/class.ts", "prop1", "prop"),
|
||||
discrepancyExplanation: compilerOptions.composite ?
|
||||
discrepancyExplanation :
|
||||
undefined,
|
||||
@@ -278,7 +277,7 @@ const a: string = 10;`, "utf-8"),
|
||||
}
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: `when global file is added, the signatures are updated`,
|
||||
fs: () => loadProjectFromFiles({
|
||||
@@ -302,16 +301,16 @@ const a: string = 10;`, "utf-8"),
|
||||
edits: [
|
||||
noChangeRun,
|
||||
{
|
||||
subScenario: "Modify main file",
|
||||
modifyFs: fs => appendText(fs, `/src/project/src/main.ts`, `something();`),
|
||||
caption: "Modify main file",
|
||||
edit: fs => appendText(fs, `/src/project/src/main.ts`, `something();`),
|
||||
},
|
||||
{
|
||||
subScenario: "Modify main file again",
|
||||
modifyFs: fs => appendText(fs, `/src/project/src/main.ts`, `something();`),
|
||||
caption: "Modify main file again",
|
||||
edit: fs => appendText(fs, `/src/project/src/main.ts`, `something();`),
|
||||
},
|
||||
{
|
||||
subScenario: "Add new file and update main file",
|
||||
modifyFs: fs => {
|
||||
caption: "Add new file and update main file",
|
||||
edit: fs => {
|
||||
fs.writeFileSync(`/src/project/src/newFile.ts`, "function foo() { return 20; }");
|
||||
prependText(fs, `/src/project/src/main.ts`, `/// <reference path="./newFile.ts"/>
|
||||
`);
|
||||
@@ -319,12 +318,12 @@ const a: string = 10;`, "utf-8"),
|
||||
},
|
||||
},
|
||||
{
|
||||
subScenario: "Write file that could not be resolved",
|
||||
modifyFs: fs => fs.writeFileSync(`/src/project/src/fileNotFound.ts`, "function something2() { return 20; }"),
|
||||
caption: "Write file that could not be resolved",
|
||||
edit: fs => fs.writeFileSync(`/src/project/src/fileNotFound.ts`, "function something2() { return 20; }"),
|
||||
},
|
||||
{
|
||||
subScenario: "Modify main file",
|
||||
modifyFs: fs => appendText(fs, `/src/project/src/main.ts`, `something();`),
|
||||
caption: "Modify main file",
|
||||
edit: fs => appendText(fs, `/src/project/src/main.ts`, `something();`),
|
||||
},
|
||||
],
|
||||
baselinePrograms: true,
|
||||
@@ -371,7 +370,7 @@ declare global {
|
||||
});
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "when new file is added to the referenced project",
|
||||
commandLineArgs: ["-i", "-p", `src/projects/project2`],
|
||||
@@ -398,40 +397,40 @@ declare global {
|
||||
}),
|
||||
edits: [
|
||||
{
|
||||
subScenario: "Add class3 to project1 and build it",
|
||||
modifyFs: fs => fs.writeFileSync("/src/projects/project1/class3.ts", `class class3 {}`, "utf-8"),
|
||||
caption: "Add class3 to project1 and build it",
|
||||
edit: fs => fs.writeFileSync("/src/projects/project1/class3.ts", `class class3 {}`, "utf-8"),
|
||||
discrepancyExplanation: () => [
|
||||
"Ts buildinfo will not be updated in incremental build so it will have semantic diagnostics cached from previous build",
|
||||
"But in clean build because of global diagnostics, semantic diagnostics are not queried so not cached in tsbuildinfo",
|
||||
],
|
||||
},
|
||||
{
|
||||
subScenario: "Add output of class3",
|
||||
modifyFs: fs => fs.writeFileSync("/src/projects/project1/class3.d.ts", `declare class class3 {}`, "utf-8"),
|
||||
caption: "Add output of class3",
|
||||
edit: fs => fs.writeFileSync("/src/projects/project1/class3.d.ts", `declare class class3 {}`, "utf-8"),
|
||||
},
|
||||
{
|
||||
subScenario: "Add excluded file to project1",
|
||||
modifyFs: fs => {
|
||||
caption: "Add excluded file to project1",
|
||||
edit: fs => {
|
||||
fs.mkdirSync("/src/projects/project1/temp");
|
||||
fs.writeFileSync("/src/projects/project1/temp/file.d.ts", `declare class file {}`, "utf-8");
|
||||
},
|
||||
},
|
||||
{
|
||||
subScenario: "Delete output for class3",
|
||||
modifyFs: fs => fs.unlinkSync("/src/projects/project1/class3.d.ts"),
|
||||
caption: "Delete output for class3",
|
||||
edit: fs => fs.unlinkSync("/src/projects/project1/class3.d.ts"),
|
||||
discrepancyExplanation: () => [
|
||||
"Ts buildinfo will be updated but will retain lib file errors from previous build and not others because they are emitted because of change which results in clearing their semantic diagnostics cache",
|
||||
"But in clean build because of global diagnostics, semantic diagnostics are not queried so not cached in tsbuildinfo",
|
||||
],
|
||||
},
|
||||
{
|
||||
subScenario: "Create output for class3",
|
||||
modifyFs: fs => fs.writeFileSync("/src/projects/project1/class3.d.ts", `declare class class3 {}`, "utf-8"),
|
||||
caption: "Create output for class3",
|
||||
edit: fs => fs.writeFileSync("/src/projects/project1/class3.d.ts", `declare class class3 {}`, "utf-8"),
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "when project has strict true",
|
||||
commandLineArgs: ["-noEmit", "-p", `src/project`],
|
||||
@@ -448,7 +447,7 @@ declare global {
|
||||
baselinePrograms: true
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "serializing error chains",
|
||||
commandLineArgs: ["-p", `src/project`],
|
||||
@@ -510,7 +509,7 @@ declare global {
|
||||
}
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "change to type that gets used as global through export in another file",
|
||||
commandLineArgs: ["-p", `src/project`],
|
||||
@@ -522,12 +521,12 @@ console.log(a);`,
|
||||
"/src/project/types.d.ts": `type MagicNumber = typeof import('./constants').default`,
|
||||
}),
|
||||
edits: [{
|
||||
subScenario: "Modify imports used in global file",
|
||||
modifyFs: fs => fs.writeFileSync("/src/project/constants.ts", "export default 2;"),
|
||||
caption: "Modify imports used in global file",
|
||||
edit: fs => fs.writeFileSync("/src/project/constants.ts", "export default 2;"),
|
||||
}],
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "change to type that gets used as global through export in another file through indirect import",
|
||||
commandLineArgs: ["-p", `src/project`],
|
||||
@@ -540,13 +539,13 @@ console.log(a);`,
|
||||
"/src/project/types.d.ts": `type MagicNumber = typeof import('./reexport').ConstantNumber`,
|
||||
}),
|
||||
edits: [{
|
||||
subScenario: "Modify imports used in global file",
|
||||
modifyFs: fs => fs.writeFileSync("/src/project/constants.ts", "export default 2;"),
|
||||
caption: "Modify imports used in global file",
|
||||
edit: fs => fs.writeFileSync("/src/project/constants.ts", "export default 2;"),
|
||||
}],
|
||||
});
|
||||
|
||||
function verifyModifierChange(declaration: boolean) {
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: `change to modifier of class expression field${declaration ? " with declaration emit enabled" : ""}`,
|
||||
commandLineArgs: ["-p", "src/project", "--incremental"],
|
||||
@@ -573,12 +572,12 @@ console.log(a);`,
|
||||
),
|
||||
edits: [
|
||||
{
|
||||
subScenario: "modify public to protected",
|
||||
modifyFs: fs => replaceText(fs, "/src/project/MessageablePerson.ts", "public", "protected"),
|
||||
caption: "modify public to protected",
|
||||
edit: fs => replaceText(fs, "/src/project/MessageablePerson.ts", "public", "protected"),
|
||||
},
|
||||
{
|
||||
subScenario: "modify protected to public",
|
||||
modifyFs: fs => replaceText(fs, "/src/project/MessageablePerson.ts", "protected", "public"),
|
||||
caption: "modify protected to public",
|
||||
edit: fs => replaceText(fs, "/src/project/MessageablePerson.ts", "protected", "public"),
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -586,7 +585,7 @@ console.log(a);`,
|
||||
verifyModifierChange(/*declaration*/ false);
|
||||
verifyModifierChange(/*declaration*/ true);
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: `when declarationMap changes`,
|
||||
fs: () => loadProjectFromFiles({
|
||||
@@ -603,8 +602,8 @@ console.log(a);`,
|
||||
commandLineArgs: ["--p", "/src/project"],
|
||||
edits: [
|
||||
{
|
||||
subScenario: "error and enable declarationMap",
|
||||
modifyFs: fs => replaceText(fs, "/src/project/a.ts", "x", "x: 20"),
|
||||
caption: "error and enable declarationMap",
|
||||
edit: fs => replaceText(fs, "/src/project/a.ts", "x", "x: 20"),
|
||||
commandLineArgs: ["--p", "/src/project", "--declarationMap"],
|
||||
discrepancyExplanation: () => [
|
||||
`Clean build does not emit any file so will have emitSignatures with all files since they are not emitted`,
|
||||
@@ -613,14 +612,14 @@ console.log(a);`,
|
||||
]
|
||||
},
|
||||
{
|
||||
subScenario: "fix error declarationMap",
|
||||
modifyFs: fs => replaceText(fs, "/src/project/a.ts", "x: 20", "x"),
|
||||
caption: "fix error declarationMap",
|
||||
edit: fs => replaceText(fs, "/src/project/a.ts", "x: 20", "x"),
|
||||
commandLineArgs: ["--p", "/src/project", "--declarationMap"],
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: `when declarationMap changes with outFile`,
|
||||
fs: () => loadProjectFromFiles({
|
||||
@@ -638,40 +637,40 @@ console.log(a);`,
|
||||
commandLineArgs: ["--p", "/src/project"],
|
||||
edits: [
|
||||
{
|
||||
subScenario: "error and enable declarationMap",
|
||||
modifyFs: fs => replaceText(fs, "/src/project/a.ts", "x", "x: 20"),
|
||||
caption: "error and enable declarationMap",
|
||||
edit: fs => replaceText(fs, "/src/project/a.ts", "x", "x: 20"),
|
||||
commandLineArgs: ["--p", "/src/project", "--declarationMap"],
|
||||
},
|
||||
{
|
||||
subScenario: "fix error declarationMap",
|
||||
modifyFs: fs => replaceText(fs, "/src/project/a.ts", "x: 20", "x"),
|
||||
caption: "fix error declarationMap",
|
||||
edit: fs => replaceText(fs, "/src/project/a.ts", "x: 20", "x"),
|
||||
commandLineArgs: ["--p", "/src/project", "--declarationMap"],
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
describe("different options::", () => {
|
||||
function withOptionChange(subScenario: string, ...options: readonly string[]): TestTscEdit {
|
||||
function withOptionChange(caption: string, ...options: readonly string[]): TestTscEdit {
|
||||
return {
|
||||
subScenario,
|
||||
modifyFs: ts.noop,
|
||||
caption,
|
||||
edit: ts.noop,
|
||||
commandLineArgs: ["--p", "/src/project", ...options],
|
||||
};
|
||||
}
|
||||
function noChangeWithSubscenario(subScenario: string): TestTscEdit {
|
||||
return { ...noChangeRun, subScenario };
|
||||
function noChangeWithSubscenario(caption: string): TestTscEdit {
|
||||
return { ...noChangeRun, caption };
|
||||
}
|
||||
function withOptionChangeAndDiscrepancyExplanation(subScenario: string, option: string): TestTscEdit {
|
||||
function withOptionChangeAndDiscrepancyExplanation(caption: string, option: string): TestTscEdit {
|
||||
return {
|
||||
...withOptionChange(subScenario, option),
|
||||
...withOptionChange(caption, option),
|
||||
discrepancyExplanation: () => [
|
||||
`Clean build tsbuildinfo will have compilerOptions with composite and ${option.replace(/\-/g, "")}`,
|
||||
`Incremental build will detect that it doesnt need to rebuild so tsbuild info is from before which has option composite only`,
|
||||
]
|
||||
};
|
||||
}
|
||||
function withEmitDeclarationOnlyChangeAndDiscrepancyExplanation(subScenario: string): TestTscEdit {
|
||||
const edit = withOptionChangeAndDiscrepancyExplanation(subScenario, "--emitDeclarationOnly");
|
||||
function withEmitDeclarationOnlyChangeAndDiscrepancyExplanation(caption: string): TestTscEdit {
|
||||
const edit = withOptionChangeAndDiscrepancyExplanation(caption, "--emitDeclarationOnly");
|
||||
const discrepancyExplanation = edit.discrepancyExplanation!;
|
||||
edit.discrepancyExplanation = () => [
|
||||
...discrepancyExplanation(),
|
||||
@@ -701,8 +700,8 @@ console.log(a);`,
|
||||
}
|
||||
function localChange(): TestTscEdit {
|
||||
return {
|
||||
subScenario: "local change",
|
||||
modifyFs: fs => replaceText(fs, "/src/project/a.ts", "Local = 1", "Local = 10"),
|
||||
caption: "local change",
|
||||
edit: fs => replaceText(fs, "/src/project/a.ts", "Local = 1", "Local = 10"),
|
||||
};
|
||||
}
|
||||
function fs(options: ts.CompilerOptions) {
|
||||
@@ -716,15 +715,15 @@ console.log(a);`,
|
||||
}
|
||||
function enableDeclarationMap(): TestTscEdit {
|
||||
return {
|
||||
subScenario: "declarationMap enabling",
|
||||
modifyFs: fs => {
|
||||
caption: "declarationMap enabling",
|
||||
edit: fs => {
|
||||
const config = JSON.parse(fs.readFileSync("/src/project/tsconfig.json", "utf-8"));
|
||||
config.compilerOptions.declarationMap = true;
|
||||
fs.writeFileSync("/src/project/tsconfig.json", JSON.stringify(config));
|
||||
},
|
||||
};
|
||||
}
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "different options",
|
||||
fs: () => fs({ composite: true }),
|
||||
@@ -747,7 +746,7 @@ console.log(a);`,
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "different options with outFile",
|
||||
fs: () => fs({ composite: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD }),
|
||||
@@ -770,7 +769,7 @@ console.log(a);`,
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "different options with incremental",
|
||||
fs: () => fs({ incremental: true }),
|
||||
@@ -792,7 +791,7 @@ console.log(a);`,
|
||||
],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "different options with incremental with outFile",
|
||||
fs: () => fs({ incremental: true, outFile: "../outFile.js", module: ts.ModuleKind.AMD }),
|
||||
@@ -816,7 +815,7 @@ console.log(a);`,
|
||||
});
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "when file is deleted",
|
||||
commandLineArgs: ["-p", `/src/project`],
|
||||
@@ -832,13 +831,13 @@ console.log(a);`,
|
||||
}),
|
||||
edits: [
|
||||
{
|
||||
subScenario: "delete file with imports",
|
||||
modifyFs: fs => fs.unlinkSync("/src/project/file2.ts"),
|
||||
caption: "delete file with imports",
|
||||
edit: fs => fs.unlinkSync("/src/project/file2.ts"),
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "incremental",
|
||||
subScenario: "file deleted before fixing error with noEmitOnError",
|
||||
fs: () => loadProjectFromFiles({
|
||||
@@ -853,8 +852,8 @@ console.log(a);`,
|
||||
}),
|
||||
commandLineArgs: ["--p", "/src/project", "-i"],
|
||||
edits: [{
|
||||
subScenario: "delete file without error",
|
||||
modifyFs: fs => fs.unlinkSync("/src/project/file2.ts"),
|
||||
caption: "delete file without error",
|
||||
edit: fs => fs.unlinkSync("/src/project/file2.ts"),
|
||||
}],
|
||||
baselinePrograms: true,
|
||||
});
|
||||
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
loadProjectFromFiles,
|
||||
noChangeRun,
|
||||
verifyTsc,
|
||||
verifyTscWithEdits,
|
||||
} from "./helpers";
|
||||
|
||||
describe("unittests:: tsc:: listFilesOnly::", () => {
|
||||
@@ -27,7 +26,7 @@ describe("unittests:: tsc:: listFilesOnly::", () => {
|
||||
commandLineArgs: ["/src/test.ts", "--listFilesOnly"]
|
||||
});
|
||||
|
||||
verifyTscWithEdits({
|
||||
verifyTsc({
|
||||
scenario: "listFilesOnly",
|
||||
subScenario: "combined with incremental",
|
||||
fs: () => loadProjectFromFiles({
|
||||
|
||||
@@ -21,7 +21,7 @@ describe("unittests:: tsc-watch:: console clearing", () => {
|
||||
|
||||
const makeChangeToFile: TscWatchCompileChange[] = [{
|
||||
caption: "Comment added to file f",
|
||||
change: sys => sys.modifyFile(file.path, "//"),
|
||||
edit: sys => sys.modifyFile(file.path, "//"),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}];
|
||||
|
||||
@@ -31,7 +31,7 @@ describe("unittests:: tsc-watch:: console clearing", () => {
|
||||
subScenario,
|
||||
commandLineArgs: ["--w", file.path, ...commandLineOptions || ts.emptyArray],
|
||||
sys: () => createWatchedSystem([file, libFile]),
|
||||
changes: makeChangeToFile,
|
||||
edits: makeChangeToFile,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ describe("unittests:: tsc-watch:: console clearing", () => {
|
||||
commandLineArgs: ["--w", "-p", configFile.path],
|
||||
...baseline,
|
||||
getPrograms: () => [[watch.getCurrentProgram().getProgram(), watch.getCurrentProgram()]],
|
||||
changes: makeChangeToFile,
|
||||
edits: makeChangeToFile,
|
||||
watchOrSolution: watch
|
||||
});
|
||||
});
|
||||
@@ -72,7 +72,7 @@ describe("unittests:: tsc-watch:: console clearing", () => {
|
||||
subScenario: "when preserveWatchOutput is true in config file/when createWatchProgram is invoked with configFileParseResult on WatchCompilerHostOfConfigFile",
|
||||
commandLineArgs: ["--w", "-p", configFile.path],
|
||||
sys: () => createWatchedSystem(files),
|
||||
changes: makeChangeToFile,
|
||||
edits: makeChangeToFile,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,15 +23,15 @@ describe("unittests:: tsc-watch:: emit with outFile or out setting", () => {
|
||||
"/a/tsconfig.json": JSON.stringify({ compilerOptions: { out, outFile } }),
|
||||
[libFile.path]: libFile.content,
|
||||
}),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Make change in the file",
|
||||
change: sys => sys.writeFile("/a/a.ts", "let x = 11"),
|
||||
edit: sys => sys.writeFile("/a/a.ts", "let x = 11"),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks()
|
||||
},
|
||||
{
|
||||
caption: "Make change in the file again",
|
||||
change: sys => sys.writeFile("/a/a.ts", "let xy = 11"),
|
||||
edit: sys => sys.writeFile("/a/a.ts", "let xy = 11"),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks()
|
||||
}
|
||||
]
|
||||
@@ -74,7 +74,6 @@ describe("unittests:: tsc-watch:: emit with outFile or out setting", () => {
|
||||
};
|
||||
return createWatchedSystem([file1, file2, file3, file4, libFile, configFile]);
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
}
|
||||
verifyFilesEmittedOnce("with --outFile and multiple declaration files in the program", /*useOutFile*/ true);
|
||||
@@ -145,7 +144,7 @@ describe("unittests:: tsc-watch:: emit for configured projects", () => {
|
||||
files
|
||||
);
|
||||
},
|
||||
changes
|
||||
edits: changes
|
||||
});
|
||||
}
|
||||
|
||||
@@ -154,7 +153,7 @@ describe("unittests:: tsc-watch:: emit for configured projects", () => {
|
||||
}
|
||||
const changeModuleFile1Shape: TscWatchCompileChange = {
|
||||
caption: "Change the content of moduleFile1 to `export var T: number;export function Foo() { };`",
|
||||
change: modifyModuleFile1Shape,
|
||||
edit: modifyModuleFile1Shape,
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
};
|
||||
|
||||
@@ -164,7 +163,7 @@ describe("unittests:: tsc-watch:: emit for configured projects", () => {
|
||||
changeModuleFile1Shape,
|
||||
{
|
||||
caption: "Change the content of moduleFile1 to `export var T: number;export function Foo() { console.log('hi'); };`",
|
||||
change: sys => sys.writeFile(moduleFile1Path, `export var T: number;export function Foo() { console.log('hi'); };`),
|
||||
edit: sys => sys.writeFile(moduleFile1Path, `export var T: number;export function Foo() { console.log('hi'); };`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -175,25 +174,25 @@ describe("unittests:: tsc-watch:: emit for configured projects", () => {
|
||||
changes: [
|
||||
{
|
||||
caption: "Change file1Consumer1 content to `export let y = Foo();`",
|
||||
change: sys => sys.writeFile(file1Consumer1Path, `export let y = Foo();`),
|
||||
edit: sys => sys.writeFile(file1Consumer1Path, `export let y = Foo();`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
changeModuleFile1Shape,
|
||||
{
|
||||
caption: "Add the import statements back to file1Consumer1",
|
||||
change: sys => sys.writeFile(file1Consumer1Path, `import {Foo} from "./moduleFile1";let y = Foo();`),
|
||||
edit: sys => sys.writeFile(file1Consumer1Path, `import {Foo} from "./moduleFile1";let y = Foo();`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "Change the content of moduleFile1 to `export var T: number;export var T2: string;export function Foo() { };`",
|
||||
change: sys => sys.writeFile(moduleFile1Path, `export let y = Foo();`),
|
||||
edit: sys => sys.writeFile(moduleFile1Path, `export let y = Foo();`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "Multiple file edits in one go",
|
||||
// Change file1Consumer1 content to `export let y = Foo();`
|
||||
// Change the content of moduleFile1 to `export var T: number;export function Foo() { };`
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.writeFile(file1Consumer1Path, `import {Foo} from "./moduleFile1";let y = Foo();`);
|
||||
modifyModuleFile1Shape(sys);
|
||||
},
|
||||
@@ -207,7 +206,7 @@ describe("unittests:: tsc-watch:: emit for configured projects", () => {
|
||||
changes: [
|
||||
{
|
||||
caption: "change moduleFile1 shape and delete file1Consumer2",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
modifyModuleFile1Shape(sys);
|
||||
sys.deleteFile(file1Consumer2Path);
|
||||
},
|
||||
@@ -221,7 +220,7 @@ describe("unittests:: tsc-watch:: emit for configured projects", () => {
|
||||
changes: [
|
||||
{
|
||||
caption: "change moduleFile1 shape and create file1Consumer3",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.writeFile("/a/b/file1Consumer3.ts", `import {Foo} from "./moduleFile1"; let y = Foo();`);
|
||||
modifyModuleFile1Shape(sys);
|
||||
},
|
||||
@@ -237,7 +236,7 @@ describe("unittests:: tsc-watch:: emit for configured projects", () => {
|
||||
changeModuleFile1Shape,
|
||||
{
|
||||
caption: "change file1 internal, and verify only file1 is affected",
|
||||
change: sys => sys.appendFile(moduleFile1Path, "var T1: number;"),
|
||||
edit: sys => sys.appendFile(moduleFile1Path, "var T1: number;"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -248,7 +247,7 @@ describe("unittests:: tsc-watch:: emit for configured projects", () => {
|
||||
changes: [
|
||||
{
|
||||
caption: "change shape of global file",
|
||||
change: sys => sys.appendFile(globalFilePath, "var T2: string;"),
|
||||
edit: sys => sys.appendFile(globalFilePath, "var T2: string;"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -279,13 +278,13 @@ describe("unittests:: tsc-watch:: emit for configured projects", () => {
|
||||
changes: [
|
||||
{
|
||||
caption: "change file1Consumer1",
|
||||
change: sys => sys.appendFile(file1Consumer1Path, "export var T: number;"),
|
||||
edit: sys => sys.appendFile(file1Consumer1Path, "export var T: number;"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
changeModuleFile1Shape,
|
||||
{
|
||||
caption: "change file1Consumer1 and moduleFile1",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.appendFile(file1Consumer1Path, "export var T2: number;");
|
||||
sys.writeFile(moduleFile1Path, `export var T2: number;export function Foo() { };`);
|
||||
},
|
||||
@@ -312,7 +311,7 @@ export var t2 = 10;`
|
||||
changes: [
|
||||
{
|
||||
caption: "change file1",
|
||||
change: sys => sys.appendFile("/a/b/file1.ts", "export var t3 = 10;"),
|
||||
edit: sys => sys.appendFile("/a/b/file1.ts", "export var t3 = 10;"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -329,7 +328,7 @@ export var x = Foo();`
|
||||
changes: [
|
||||
{
|
||||
caption: "delete moduleFile1",
|
||||
change: sys => sys.deleteFile(moduleFile1Path),
|
||||
edit: sys => sys.deleteFile(moduleFile1Path),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -346,12 +345,12 @@ export var x = Foo();`
|
||||
changes: [
|
||||
{
|
||||
caption: "edit refereceFile1",
|
||||
change: sys => sys.appendFile("/a/b/referenceFile1.ts", "export var yy = Foo();"),
|
||||
edit: sys => sys.appendFile("/a/b/referenceFile1.ts", "export var yy = Foo();"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "create moduleFile2",
|
||||
change: sys => sys.writeFile(moduleFile2Path, "export var Foo4 = 10;"),
|
||||
edit: sys => sys.writeFile(moduleFile2Path, "export var Foo4 = 10;"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -374,10 +373,10 @@ describe("unittests:: tsc-watch:: emit file content", () => {
|
||||
],
|
||||
{ newLine }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Append a line",
|
||||
change: sys => sys.appendFile("/a/app.ts", newLine + "var z = 3;"),
|
||||
edit: sys => sys.appendFile("/a/app.ts", newLine + "var z = 3;"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
],
|
||||
@@ -412,15 +411,15 @@ describe("unittests:: tsc-watch:: emit file content", () => {
|
||||
};
|
||||
return createWatchedSystem([file1, file2, file3, configFile, libFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Append content to f1",
|
||||
change: sys => sys.appendFile("/a/b/f1.ts", "export function foo2() { return 2; }"),
|
||||
edit: sys => sys.appendFile("/a/b/f1.ts", "export function foo2() { return 2; }"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "Again Append content to f1",
|
||||
change: sys => sys.appendFile("/a/b/f1.ts", "export function fooN() { return 2; }"),
|
||||
edit: sys => sys.appendFile("/a/b/f1.ts", "export function fooN() { return 2; }"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
],
|
||||
@@ -446,10 +445,10 @@ describe("unittests:: tsc-watch:: emit file content", () => {
|
||||
};
|
||||
return createWatchedSystem([file1, file2, file3, libFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Append content to file3",
|
||||
change: sys => sys.appendFile("/user/someone/projects/myproject/file3.ts", "function foo2() { return 2; }"),
|
||||
edit: sys => sys.appendFile("/user/someone/projects/myproject/file3.ts", "function foo2() { return 2; }"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
],
|
||||
@@ -476,10 +475,10 @@ describe("unittests:: tsc-watch:: emit file content", () => {
|
||||
const files = [file, configFile, libFile];
|
||||
return createWatchedSystem(files, { currentDirectory: projectLocation, useCaseSensitiveFileNames: true });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "file is deleted and then created to modify content",
|
||||
change: sys => sys.appendFile("/home/username/project/app/file.ts", "\nvar b = 10;", { invokeFileDeleteCreateAsPartInsteadOfChange: true }),
|
||||
edit: sys => sys.appendFile("/home/username/project/app/file.ts", "\nvar b = 10;", { invokeFileDeleteCreateAsPartInsteadOfChange: true }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -515,10 +514,10 @@ describe("unittests:: tsc-watch:: emit with when module emit is specified as nod
|
||||
};
|
||||
return createWatchedSystem([configFile, file1, file2, libFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Modify typescript file",
|
||||
change: sys => sys.modifyFile(
|
||||
edit: sys => sys.modifyFile(
|
||||
"/a/rootFolder/project/Scripts/TypeScript.ts",
|
||||
"var zz30 = 100;",
|
||||
{ invokeDirectoryWatcherInsteadOfFileChanged: true },
|
||||
|
||||
@@ -35,7 +35,7 @@ describe("unittests:: tsc-watch:: Emit times and Error updates in builder after
|
||||
files(),
|
||||
{ currentDirectory: currentDirectory || "/user/username/projects/myproject" }
|
||||
),
|
||||
changes,
|
||||
edits: changes,
|
||||
baselineIncremental: true
|
||||
});
|
||||
|
||||
@@ -47,7 +47,7 @@ describe("unittests:: tsc-watch:: Emit times and Error updates in builder after
|
||||
files(),
|
||||
{ currentDirectory: currentDirectory || "/user/username/projects/myproject" }
|
||||
),
|
||||
changes,
|
||||
edits: changes,
|
||||
baselineIncremental: true
|
||||
});
|
||||
|
||||
@@ -59,7 +59,7 @@ describe("unittests:: tsc-watch:: Emit times and Error updates in builder after
|
||||
files(),
|
||||
{ currentDirectory: currentDirectory || "/user/username/projects/myproject" }
|
||||
),
|
||||
changes,
|
||||
edits: changes,
|
||||
baselineIncremental: true
|
||||
});
|
||||
|
||||
@@ -71,7 +71,7 @@ describe("unittests:: tsc-watch:: Emit times and Error updates in builder after
|
||||
files(),
|
||||
{ currentDirectory: currentDirectory || "/user/username/projects/myproject" }
|
||||
),
|
||||
changes,
|
||||
edits: changes,
|
||||
baselineIncremental: true
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@ describe("unittests:: tsc-watch:: Emit times and Error updates in builder after
|
||||
files(),
|
||||
{ currentDirectory: currentDirectory || "/user/username/projects/myproject" }
|
||||
),
|
||||
changes,
|
||||
edits: changes,
|
||||
baselineIncremental: true
|
||||
});
|
||||
|
||||
@@ -95,7 +95,7 @@ describe("unittests:: tsc-watch:: Emit times and Error updates in builder after
|
||||
files(),
|
||||
{ currentDirectory: currentDirectory || "/user/username/projects/myproject" }
|
||||
),
|
||||
changes,
|
||||
edits: changes,
|
||||
baselineIncremental: true
|
||||
});
|
||||
}
|
||||
@@ -116,17 +116,17 @@ console.log(b.c.d);`
|
||||
changes: [
|
||||
{
|
||||
caption: "Rename property d to d2 of class C to initialize signatures",
|
||||
change: sys => sys.writeFile(cFile.path, cFile.content.replace("d", "d2")),
|
||||
edit: sys => sys.writeFile(cFile.path, cFile.content.replace("d", "d2")),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "Rename property d2 to d of class C to revert back to original text",
|
||||
change: sys => sys.writeFile(cFile.path, cFile.content.replace("d2", "d")),
|
||||
edit: sys => sys.writeFile(cFile.path, cFile.content.replace("d2", "d")),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "Rename property d to d2 of class C",
|
||||
change: sys => sys.writeFile(cFile.path, cFile.content.replace("d", "d2")),
|
||||
edit: sys => sys.writeFile(cFile.path, cFile.content.replace("d", "d2")),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}
|
||||
],
|
||||
@@ -224,17 +224,17 @@ getPoint().c.x;`
|
||||
changes: [
|
||||
{
|
||||
caption: "Rename property x2 to x of interface Coords to initialize signatures",
|
||||
change: sys => sys.writeFile(aFile.path, aFile.content.replace("x2", "x")),
|
||||
edit: sys => sys.writeFile(aFile.path, aFile.content.replace("x2", "x")),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "Rename property x to x2 of interface Coords to revert back to original text",
|
||||
change: sys => sys.writeFile(aFile.path, aFile.content.replace("x: number", "x2: number")),
|
||||
edit: sys => sys.writeFile(aFile.path, aFile.content.replace("x: number", "x2: number")),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "Rename property x2 to x of interface Coords",
|
||||
change: sys => sys.writeFile(aFile.path, aFile.content.replace("x2", "x")),
|
||||
edit: sys => sys.writeFile(aFile.path, aFile.content.replace("x2", "x")),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
]
|
||||
@@ -295,17 +295,17 @@ export class Data {
|
||||
changes: [
|
||||
{
|
||||
caption: "Rename property title to title2 of interface ITest to initialize signatures",
|
||||
change: sys => sys.writeFile(lib1ToolsInterface.path, lib1ToolsInterface.content.replace("title", "title2")),
|
||||
edit: sys => sys.writeFile(lib1ToolsInterface.path, lib1ToolsInterface.content.replace("title", "title2")),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "Rename property title2 to title of interface ITest to revert back to original text",
|
||||
change: sys => sys.writeFile(lib1ToolsInterface.path, lib1ToolsInterface.content.replace("title2", "title")),
|
||||
edit: sys => sys.writeFile(lib1ToolsInterface.path, lib1ToolsInterface.content.replace("title2", "title")),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "Rename property title to title2 of interface ITest",
|
||||
change: sys => sys.writeFile(lib1ToolsInterface.path, lib1ToolsInterface.content.replace("title", "title2")),
|
||||
edit: sys => sys.writeFile(lib1ToolsInterface.path, lib1ToolsInterface.content.replace("title", "title2")),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}
|
||||
]
|
||||
@@ -348,14 +348,14 @@ export class Data2 {
|
||||
function change(caption: string, content: string): TscWatchCompileChange {
|
||||
return {
|
||||
caption,
|
||||
change: sys => sys.writeFile(`/user/username/projects/noEmitOnError/src/main.ts`, content),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/noEmitOnError/src/main.ts`, content),
|
||||
// build project
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
};
|
||||
}
|
||||
const noChange: TscWatchCompileChange = {
|
||||
caption: "No change",
|
||||
change: sys => sys.writeFile(`/user/username/projects/noEmitOnError/src/main.ts`, sys.readFile(`/user/username/projects/noEmitOnError/src/main.ts`)!),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/noEmitOnError/src/main.ts`, sys.readFile(`/user/username/projects/noEmitOnError/src/main.ts`)!),
|
||||
// build project
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
};
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import * as ts from "../../_namespaces/ts";
|
||||
import * as Utils from "../../_namespaces/Utils";
|
||||
import {
|
||||
createWatchedSystem,
|
||||
@@ -33,7 +32,7 @@ describe("unittests:: tsc-watch:: forceConsistentCasingInFileNames", () => {
|
||||
subScenario,
|
||||
commandLineArgs: ["--w", "--p", tsconfig.path],
|
||||
sys: () => createWatchedSystem([loggerFile, anotherFile, tsconfig, libFile]),
|
||||
changes
|
||||
edits: changes
|
||||
});
|
||||
}
|
||||
|
||||
@@ -42,7 +41,7 @@ describe("unittests:: tsc-watch:: forceConsistentCasingInFileNames", () => {
|
||||
changes: [
|
||||
{
|
||||
caption: "Change module name from logger to Logger",
|
||||
change: sys => sys.writeFile(anotherFile.path, anotherFile.content.replace("./logger", "./Logger")),
|
||||
edit: sys => sys.writeFile(anotherFile.path, anotherFile.content.replace("./logger", "./Logger")),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}
|
||||
]
|
||||
@@ -53,7 +52,7 @@ describe("unittests:: tsc-watch:: forceConsistentCasingInFileNames", () => {
|
||||
changes: [
|
||||
{
|
||||
caption: "Change name of file from logger to Logger",
|
||||
change: sys => sys.renameFile(loggerFile.path, `/user/username/projects/myproject/Logger.ts`),
|
||||
edit: sys => sys.renameFile(loggerFile.path, `/user/username/projects/myproject/Logger.ts`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}
|
||||
]
|
||||
@@ -82,10 +81,10 @@ describe("unittests:: tsc-watch:: forceConsistentCasingInFileNames", () => {
|
||||
};
|
||||
return createWatchedSystem([moduleA, moduleB, moduleC, libFile, tsconfig], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Prepend a line to moduleA",
|
||||
change: sys => sys.prependFile(`/user/username/projects/myproject/moduleA.ts`, `// some comment
|
||||
edit: sys => sys.prependFile(`/user/username/projects/myproject/moduleA.ts`, `// some comment
|
||||
`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}
|
||||
@@ -129,7 +128,6 @@ export const Fragment: unique symbol;
|
||||
})
|
||||
}
|
||||
], { currentDirectory: "/user/username/projects/myproject" }),
|
||||
changes: ts.emptyArray,
|
||||
});
|
||||
|
||||
function verifyWindowsStyleRoot(subScenario: string, windowsStyleRoot: string, projectRootRelative: string) {
|
||||
@@ -160,10 +158,10 @@ a;b;
|
||||
};
|
||||
return createWatchedSystem([moduleA, moduleB, libFile, tsconfig], { windowsStyleRoot, useCaseSensitiveFileNames: false });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Prepend a line to moduleA",
|
||||
change: sys => sys.prependFile(`${windowsStyleRoot}/${projectRootRelative}/a.ts`, `// some comment
|
||||
edit: sys => sys.prependFile(`${windowsStyleRoot}/${projectRootRelative}/a.ts`, `// some comment
|
||||
`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}
|
||||
@@ -207,10 +205,10 @@ a;b;
|
||||
};
|
||||
return createWatchedSystem([moduleA, symlinkA, moduleB, libFile, tsconfig], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Prepend a line to moduleA",
|
||||
change: sys => sys.prependFile(diskPath, `// some comment
|
||||
edit: sys => sys.prependFile(diskPath, `// some comment
|
||||
`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}
|
||||
@@ -258,10 +256,10 @@ a;b;
|
||||
};
|
||||
return createWatchedSystem([moduleA, symlinkA, moduleB, libFile, tsconfig], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Prepend a line to moduleA",
|
||||
change: sys => sys.prependFile(`${diskPath}/a.ts`, `// some comment
|
||||
edit: sys => sys.prependFile(`${diskPath}/a.ts`, `// some comment
|
||||
`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}
|
||||
@@ -304,7 +302,6 @@ a;b;
|
||||
}),
|
||||
[libFile.path]: libFile.content,
|
||||
}, { currentDirectory: "/Users/name/projects/web" }),
|
||||
changes: ts.emptyArray,
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -336,7 +333,6 @@ a;b;
|
||||
}),
|
||||
"/a/lib/lib.esnext.full.d.ts": libFile.content,
|
||||
}, { currentDirectory: "/Users/name/projects/web" }),
|
||||
changes: ts.emptyArray,
|
||||
});
|
||||
|
||||
|
||||
@@ -367,6 +363,5 @@ a;b;
|
||||
}),
|
||||
"/a/lib/lib.es2021.full.d.ts": libFile.content,
|
||||
}, { currentDirectory: "/Users/name/projects/lib-boilerplate" }),
|
||||
changes: ts.emptyArray,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ export const commonFile2: File = {
|
||||
export type WatchOrSolution<T extends ts.BuilderProgram> = void | ts.SolutionBuilder<T> | ts.WatchOfConfigFile<T> | ts.WatchOfFilesAndCompilerOptions<T>;
|
||||
export interface TscWatchCompileChange<T extends ts.BuilderProgram = ts.EmitAndSemanticDiagnosticsBuilderProgram> {
|
||||
caption: string;
|
||||
change: (sys: TestServerHostTrackingWrittenFiles) => void;
|
||||
edit: (sys: TestServerHostTrackingWrittenFiles) => void;
|
||||
timeouts: (
|
||||
sys: TestServerHostTrackingWrittenFiles,
|
||||
programs: readonly CommandLineProgram[],
|
||||
@@ -47,7 +47,7 @@ export interface TscWatchCompileBase<T extends ts.BuilderProgram = ts.EmitAndSem
|
||||
scenario: string;
|
||||
subScenario: string;
|
||||
commandLineArgs: readonly string[];
|
||||
changes: readonly TscWatchCompileChange<T>[];
|
||||
edits?: readonly TscWatchCompileChange<T>[];
|
||||
}
|
||||
export interface TscWatchCompile extends TscWatchCompileBase {
|
||||
sys: () => TestServerHost;
|
||||
@@ -55,7 +55,7 @@ export interface TscWatchCompile extends TscWatchCompileBase {
|
||||
|
||||
export const noopChange: TscWatchCompileChange = {
|
||||
caption: "No change",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(0),
|
||||
};
|
||||
|
||||
@@ -65,7 +65,7 @@ function tscWatchCompile(input: TscWatchCompile) {
|
||||
const { sys, baseline, oldSnap } = createBaseline(input.sys());
|
||||
const {
|
||||
scenario, subScenario,
|
||||
commandLineArgs, changes,
|
||||
commandLineArgs, edits,
|
||||
baselineSourceMap, baselineDependencies
|
||||
} = input;
|
||||
|
||||
@@ -86,7 +86,7 @@ function tscWatchCompile(input: TscWatchCompile) {
|
||||
getPrograms,
|
||||
baselineSourceMap,
|
||||
baselineDependencies,
|
||||
changes,
|
||||
edits,
|
||||
watchOrSolution
|
||||
});
|
||||
});
|
||||
@@ -167,10 +167,10 @@ function updateWatchHostForBaseline<T extends ts.BuilderProgram>(host: ts.WatchC
|
||||
return host;
|
||||
}
|
||||
|
||||
export function applyChange(sys: BaselineBase["sys"], baseline: BaselineBase["baseline"], change: TscWatchCompileChange["change"], caption?: TscWatchCompileChange["caption"]) {
|
||||
export function applyEdit(sys: BaselineBase["sys"], baseline: BaselineBase["baseline"], edit: TscWatchCompileChange["edit"], caption?: TscWatchCompileChange["caption"]) {
|
||||
const oldSnap = sys.snap();
|
||||
baseline.push(`Change::${caption ? " " + caption : ""}`, "");
|
||||
change(sys);
|
||||
edit(sys);
|
||||
baseline.push("Input::");
|
||||
sys.diff(baseline, oldSnap);
|
||||
return sys.snap();
|
||||
@@ -185,7 +185,7 @@ export function runWatchBaseline<T extends ts.BuilderProgram = ts.EmitAndSemanti
|
||||
scenario, subScenario, commandLineArgs,
|
||||
getPrograms, sys, baseline, oldSnap,
|
||||
baselineSourceMap, baselineDependencies,
|
||||
changes, watchOrSolution
|
||||
edits, watchOrSolution
|
||||
}: RunWatchBaseline<T>) {
|
||||
baseline.push(`${sys.getExecutingFilePath()} ${commandLineArgs.join(" ")}`);
|
||||
let programs = watchBaseline({
|
||||
@@ -198,18 +198,20 @@ export function runWatchBaseline<T extends ts.BuilderProgram = ts.EmitAndSemanti
|
||||
baselineDependencies,
|
||||
});
|
||||
|
||||
for (const { caption, change, timeouts } of changes) {
|
||||
oldSnap = applyChange(sys, baseline, change, caption);
|
||||
timeouts(sys, programs, watchOrSolution);
|
||||
programs = watchBaseline({
|
||||
baseline,
|
||||
getPrograms,
|
||||
oldPrograms: programs,
|
||||
sys,
|
||||
oldSnap,
|
||||
baselineSourceMap,
|
||||
baselineDependencies,
|
||||
});
|
||||
if (edits) {
|
||||
for (const { caption, edit, timeouts } of edits) {
|
||||
oldSnap = applyEdit(sys, baseline, edit, caption);
|
||||
timeouts(sys, programs, watchOrSolution);
|
||||
programs = watchBaseline({
|
||||
baseline,
|
||||
getPrograms,
|
||||
oldPrograms: programs,
|
||||
sys,
|
||||
oldSnap,
|
||||
baselineSourceMap,
|
||||
baselineDependencies,
|
||||
});
|
||||
}
|
||||
}
|
||||
Baseline.runBaseline(`${ts.isBuild(commandLineArgs) ? "tsbuild" : "tsc"}${isWatch(commandLineArgs) ? "Watch" : ""}/${scenario}/${subScenario.split(" ").join("-")}.js`, baseline.join("\r\n"));
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
libContent,
|
||||
} from "../tsc/helpers";
|
||||
import {
|
||||
applyChange,
|
||||
applyEdit,
|
||||
createBaseline,
|
||||
SystemSnap,
|
||||
verifyTscWatch,
|
||||
@@ -55,7 +55,7 @@ describe("unittests:: tsc-watch:: emit file --incremental", () => {
|
||||
build(oldSnap);
|
||||
|
||||
if (modifyFs) {
|
||||
const oldSnap = applyChange(sys, baseline, modifyFs);
|
||||
const oldSnap = applyEdit(sys, baseline, modifyFs);
|
||||
build(oldSnap);
|
||||
}
|
||||
|
||||
@@ -404,6 +404,5 @@ export const Fragment: unique symbol;
|
||||
[libFile.path]: libFile.content,
|
||||
}),
|
||||
commandLineArgs: ["--p", "src/project", "-i", "-w"],
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
});
|
||||
|
||||
@@ -60,10 +60,10 @@ describe("unittests:: tsc-watch:: moduleResolution", () => {
|
||||
libFile
|
||||
], { currentDirectory: "/user/username/projects/myproject" }),
|
||||
commandLineArgs: ["--project", "./packages/pkg1/tsconfig.json", "-w", "--traceResolution"],
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "reports import errors after change to package file",
|
||||
change: sys => sys.replaceFileText(`/user/username/projects/myproject/packages/pkg2/package.json`, `index.js`, `other.js`),
|
||||
edit: sys => sys.replaceFileText(`/user/username/projects/myproject/packages/pkg2/package.json`, `index.js`, `other.js`),
|
||||
timeouts: sys => {
|
||||
sys.runQueuedTimeoutCallbacks(); // invalidates failed lookups
|
||||
sys.runQueuedTimeoutCallbacks(); // actual update
|
||||
@@ -71,7 +71,7 @@ describe("unittests:: tsc-watch:: moduleResolution", () => {
|
||||
},
|
||||
{
|
||||
caption: "removes those errors when a package file is changed back",
|
||||
change: sys => sys.replaceFileText(`/user/username/projects/myproject/packages/pkg2/package.json`, `other.js`, `index.js`),
|
||||
edit: sys => sys.replaceFileText(`/user/username/projects/myproject/packages/pkg2/package.json`, `other.js`, `index.js`),
|
||||
timeouts: sys => {
|
||||
sys.runQueuedTimeoutCallbacks(); // invalidates failed lookups
|
||||
sys.runQueuedTimeoutCallbacks(); // actual update
|
||||
@@ -125,9 +125,9 @@ describe("unittests:: tsc-watch:: moduleResolution", () => {
|
||||
libFile
|
||||
], { currentDirectory: "/user/username/projects/myproject" }),
|
||||
commandLineArgs: ["-w", "--traceResolution"],
|
||||
changes: [{
|
||||
edits: [{
|
||||
caption: "Add import to index2",
|
||||
change: sys => sys.prependFile(`/user/username/projects/myproject/index2.ts`, `import * as me from "./index.js";`),
|
||||
edit: sys => sys.prependFile(`/user/username/projects/myproject/index2.ts`, `import * as me from "./index.js";`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}]
|
||||
});
|
||||
@@ -172,10 +172,10 @@ describe("unittests:: tsc-watch:: moduleResolution", () => {
|
||||
subScenario: "package json file is edited",
|
||||
commandLineArgs: ["--w", "--p", "src", "--extendedDiagnostics", "-traceResolution", "--explainFiles"],
|
||||
sys: () => getSys(JSON.stringify({ name: "app", version: "1.0.0" })),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Modify package json file to add type module",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/package.json`, JSON.stringify({
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/package.json`, JSON.stringify({
|
||||
name: "app", version: "1.0.0", type: "module",
|
||||
})),
|
||||
timeouts: host => {
|
||||
@@ -185,7 +185,7 @@ describe("unittests:: tsc-watch:: moduleResolution", () => {
|
||||
},
|
||||
{
|
||||
caption: "Modify package.json file to remove type module",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/package.json`, JSON.stringify({ name: "app", version: "1.0.0" })),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/package.json`, JSON.stringify({ name: "app", version: "1.0.0" })),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
@@ -193,7 +193,7 @@ describe("unittests:: tsc-watch:: moduleResolution", () => {
|
||||
},
|
||||
{
|
||||
caption: "Delete package.json",
|
||||
change: sys => sys.deleteFile(`/user/username/projects/myproject/package.json`),
|
||||
edit: sys => sys.deleteFile(`/user/username/projects/myproject/package.json`),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
@@ -201,7 +201,7 @@ describe("unittests:: tsc-watch:: moduleResolution", () => {
|
||||
},
|
||||
{
|
||||
caption: "Modify package json file to add type module",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/package.json`, JSON.stringify({
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/package.json`, JSON.stringify({
|
||||
name: "app", version: "1.0.0", type: "module",
|
||||
})),
|
||||
timeouts: host => {
|
||||
@@ -211,7 +211,7 @@ describe("unittests:: tsc-watch:: moduleResolution", () => {
|
||||
},
|
||||
{
|
||||
caption: "Delete package.json",
|
||||
change: sys => sys.deleteFile(`/user/username/projects/myproject/package.json`),
|
||||
edit: sys => sys.deleteFile(`/user/username/projects/myproject/package.json`),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
@@ -227,10 +227,10 @@ describe("unittests:: tsc-watch:: moduleResolution", () => {
|
||||
sys: () => getSys(JSON.stringify({
|
||||
name: "app", version: "1.0.0", type: "module",
|
||||
})),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Modify package.json file to remove type module",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/package.json`, JSON.stringify({ name: "app", version: "1.0.0" })),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/package.json`, JSON.stringify({ name: "app", version: "1.0.0" })),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
@@ -238,7 +238,7 @@ describe("unittests:: tsc-watch:: moduleResolution", () => {
|
||||
},
|
||||
{
|
||||
caption: "Modify package json file to add type module",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/package.json`, JSON.stringify({
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/package.json`, JSON.stringify({
|
||||
name: "app", version: "1.0.0", type: "module",
|
||||
})),
|
||||
timeouts: host => {
|
||||
@@ -248,7 +248,7 @@ describe("unittests:: tsc-watch:: moduleResolution", () => {
|
||||
},
|
||||
{
|
||||
caption: "Delete package.json",
|
||||
change: sys => sys.deleteFile(`/user/username/projects/myproject/package.json`),
|
||||
edit: sys => sys.deleteFile(`/user/username/projects/myproject/package.json`),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
@@ -256,7 +256,7 @@ describe("unittests:: tsc-watch:: moduleResolution", () => {
|
||||
},
|
||||
{
|
||||
caption: "Modify package json file to without type module",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/package.json`, JSON.stringify({ name: "app", version: "1.0.0" })),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/package.json`, JSON.stringify({ name: "app", version: "1.0.0" })),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
@@ -264,7 +264,7 @@ describe("unittests:: tsc-watch:: moduleResolution", () => {
|
||||
},
|
||||
{
|
||||
caption: "Delete package.json",
|
||||
change: sys => sys.deleteFile(`/user/username/projects/myproject/package.json`),
|
||||
edit: sys => sys.deleteFile(`/user/username/projects/myproject/package.json`),
|
||||
timeouts: host => {
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
@@ -335,10 +335,10 @@ describe("unittests:: tsc-watch:: moduleResolution", () => {
|
||||
libFile
|
||||
], { currentDirectory: "/user/username/projects/myproject" }),
|
||||
commandLineArgs: ["-w", "--traceResolution"],
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "modify aFile by adding import",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/a.ts`, `import type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }`),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/a.ts`, `import type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}
|
||||
]
|
||||
@@ -424,10 +424,10 @@ describe("unittests:: tsc-watch:: moduleResolution", () => {
|
||||
libFile
|
||||
], { currentDirectory: "/user/username/projects/myproject" }),
|
||||
commandLineArgs: ["-w", "--traceResolution"],
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "modify aFile by adding import",
|
||||
change: sys => sys.prependFile(`/user/username/projects/myproject/a.ts`, `/// <reference types="pkg" resolution-mode="import"/>\n`),
|
||||
edit: sys => sys.prependFile(`/user/username/projects/myproject/a.ts`, `/// <reference types="pkg" resolution-mode="import"/>\n`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}
|
||||
]
|
||||
|
||||
@@ -47,10 +47,10 @@ describe("unittests:: tsc-watch:: nodeNextWatch:: emit when module emit is speci
|
||||
};
|
||||
return createWatchedSystem([configFile, file1, declFile, packageFile, { ...libFile, path: "/a/lib/lib.es2020.full.d.ts" }]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Modify typescript file",
|
||||
change: sys => sys.modifyFile(
|
||||
edit: sys => sys.modifyFile(
|
||||
"/project/src/index.ts",
|
||||
Utils.dedent`
|
||||
import * as Thing from "thing";
|
||||
|
||||
@@ -49,7 +49,6 @@ describe("unittests:: tsc-watch:: program updates", () => {
|
||||
};
|
||||
return createWatchedSystem([appFile, moduleFile, libFile]);
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -69,7 +68,6 @@ describe("unittests:: tsc-watch:: program updates", () => {
|
||||
};
|
||||
return createWatchedSystem([f1, libFile, config], { useCaseSensitiveFileNames: false });
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -101,7 +99,6 @@ describe("unittests:: tsc-watch:: program updates", () => {
|
||||
};
|
||||
return createWatchedSystem([configFile, libFile, file1, file2, file3]);
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -109,10 +106,10 @@ describe("unittests:: tsc-watch:: program updates", () => {
|
||||
subScenario: "add new files to a configured program without file list",
|
||||
commandLineArgs: ["-w", "-p", configFilePath],
|
||||
sys: () => createWatchedSystem([commonFile1, libFile, configFile]),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Create commonFile2",
|
||||
change: sys => sys.writeFile(commonFile2.path, commonFile2.content),
|
||||
edit: sys => sys.writeFile(commonFile2.path, commonFile2.content),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -135,7 +132,6 @@ describe("unittests:: tsc-watch:: program updates", () => {
|
||||
};
|
||||
return createWatchedSystem([commonFile1, commonFile2, libFile, configFile]);
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -145,20 +141,20 @@ describe("unittests:: tsc-watch:: program updates", () => {
|
||||
sys: () => {
|
||||
return createWatchedSystem([libFile, commonFile1, commonFile2, configFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "change file to ensure signatures are updated",
|
||||
change: sys => sys.appendFile(commonFile2.path, ";let xy = 10;"),
|
||||
edit: sys => sys.appendFile(commonFile2.path, ";let xy = 10;"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "delete file2",
|
||||
change: sys => sys.deleteFile(commonFile2.path),
|
||||
edit: sys => sys.deleteFile(commonFile2.path),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "recreate file2",
|
||||
change: sys => sys.writeFile(commonFile2.path, commonFile2.content),
|
||||
edit: sys => sys.writeFile(commonFile2.path, commonFile2.content),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -176,10 +172,10 @@ describe("unittests:: tsc-watch:: program updates", () => {
|
||||
};
|
||||
return createWatchedSystem([file1, libFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "create file2",
|
||||
change: sys => sys.writeFile(commonFile2.path, commonFile2.content),
|
||||
edit: sys => sys.writeFile(commonFile2.path, commonFile2.content),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -199,15 +195,15 @@ describe("unittests:: tsc-watch:: program updates", () => {
|
||||
};
|
||||
return createWatchedSystem([libFile, commonFile1, commonFile2, configFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "change file to ensure signatures are updated",
|
||||
change: sys => sys.appendFile(commonFile2.path, ";let xy = 10;"),
|
||||
edit: sys => sys.appendFile(commonFile2.path, ";let xy = 10;"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "Change config",
|
||||
change: sys => sys.writeFile(configFilePath, `{
|
||||
edit: sys => sys.writeFile(configFilePath, `{
|
||||
"compilerOptions": {},
|
||||
"files": ["${commonFile1.path}"]
|
||||
}`),
|
||||
@@ -230,10 +226,10 @@ describe("unittests:: tsc-watch:: program updates", () => {
|
||||
};
|
||||
return createWatchedSystem([libFile, commonFile1, commonFile2, configFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Modify config without changing content",
|
||||
change: sys => sys.modifyFile(configFilePath, `{
|
||||
edit: sys => sys.modifyFile(configFilePath, `{
|
||||
"compilerOptions": {},
|
||||
"files": ["${commonFile1.path}", "${commonFile2.path}"]
|
||||
}`),
|
||||
@@ -259,17 +255,17 @@ describe("unittests:: tsc-watch:: program updates", () => {
|
||||
};
|
||||
return createWatchedSystem([libFile, aTs, tsconfig]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Disable allowUnsusedLabels",
|
||||
change: sys => sys.modifyFile("/tsconfig.json", JSON.stringify({
|
||||
edit: sys => sys.modifyFile("/tsconfig.json", JSON.stringify({
|
||||
compilerOptions: { allowUnusedLabels: false }
|
||||
})),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
{
|
||||
caption: "Enable allowUnsusedLabels",
|
||||
change: sys => sys.modifyFile("/tsconfig.json", JSON.stringify({
|
||||
edit: sys => sys.modifyFile("/tsconfig.json", JSON.stringify({
|
||||
compilerOptions: { allowUnusedLabels: true }
|
||||
})),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
@@ -302,10 +298,10 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([libFile, aTs, bTs, tsconfig]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Enable experimentalDecorators",
|
||||
change: sys => sys.modifyFile("/tsconfig.json", JSON.stringify({
|
||||
edit: sys => sys.modifyFile("/tsconfig.json", JSON.stringify({
|
||||
compilerOptions: { target: "es6", importsNotUsedAsValues: "error", experimentalDecorators: true }
|
||||
})),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
@@ -313,7 +309,7 @@ export class A {
|
||||
},
|
||||
{
|
||||
caption: "Enable emitDecoratorMetadata",
|
||||
change: sys => sys.modifyFile("/tsconfig.json", JSON.stringify({
|
||||
edit: sys => sys.modifyFile("/tsconfig.json", JSON.stringify({
|
||||
compilerOptions: { target: "es6", importsNotUsedAsValues: "error", experimentalDecorators: true, emitDecoratorMetadata: true }
|
||||
})),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
@@ -339,7 +335,6 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([libFile, commonFile1, commonFile2, excludedFile1, configFile]);
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -370,10 +365,10 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([libFile, file1, nodeModuleFile, classicModuleFile, configFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Change module resolution to classic",
|
||||
change: sys => sys.writeFile(configFile.path, `{
|
||||
edit: sys => sys.writeFile(configFile.path, `{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "classic"
|
||||
},
|
||||
@@ -401,7 +396,6 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([commonFile1, commonFile2, libFile, configFile]);
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -423,11 +417,11 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([file1, file2, file3, libFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Modify f2 to include f3",
|
||||
// now inferred project should inclule file3
|
||||
change: sys => sys.modifyFile("/a/b/f2.ts", `export * from "../c/f3"`),
|
||||
edit: sys => sys.modifyFile("/a/b/f2.ts", `export * from "../c/f3"`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -452,10 +446,10 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([file1, file2, file3, libFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Delete f2",
|
||||
change: sys => sys.deleteFile("/a/b/f2.ts"),
|
||||
edit: sys => sys.deleteFile("/a/b/f2.ts"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -480,10 +474,10 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([file1, file2, file3, libFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Delete f2",
|
||||
change: sys => sys.deleteFile("/a/b/f2.ts"),
|
||||
edit: sys => sys.deleteFile("/a/b/f2.ts"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -512,7 +506,6 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([file1, file2, file3, libFile, configFile]);
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -526,10 +519,10 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([file1, libFile, configFile]);
|
||||
},
|
||||
changes: [{
|
||||
edits: [{
|
||||
caption: "change `module` to 'none'",
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.writeFile(configFilePath, JSON.stringify({ compilerOptions: { module: "none" } }));
|
||||
}
|
||||
}]
|
||||
@@ -603,10 +596,10 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([file1, libFile, configFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Write f2",
|
||||
change: sys => sys.writeFile("/a/b/f2.ts", "let y = 1"),
|
||||
edit: sys => sys.writeFile("/a/b/f2.ts", "let y = 1"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -631,10 +624,10 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([file1, file2, libFile, configFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Modify config to make f2 as root too",
|
||||
change: sys => sys.writeFile(configFilePath, JSON.stringify({ compilerOptions: {}, files: ["f1.ts", "f2.ts"] })),
|
||||
edit: sys => sys.writeFile(configFilePath, JSON.stringify({ compilerOptions: {}, files: ["f1.ts", "f2.ts"] })),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -659,15 +652,15 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([file1, file2, libFile, configFile], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Add new file",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/new-file.ts`, "export const z = 1;"),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/new-file.ts`, "export const z = 1;"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "Import new file",
|
||||
change: sys => sys.prependFile(`/user/username/projects/myproject/f1.ts`, `import { z } from "./new-file";`),
|
||||
edit: sys => sys.prependFile(`/user/username/projects/myproject/f1.ts`, `import { z } from "./new-file";`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -688,10 +681,10 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([file1, libFile, configFile], { currentDirectory: `/user/username/projects/myproject/Project` });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Write file2",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/Project/file2.ts`, "export const y = 10;"),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/Project/file2.ts`, "export const y = 10;"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
}
|
||||
]
|
||||
@@ -716,10 +709,10 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([file1, file2, libFile, configFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Modify config to set outFile option",
|
||||
change: sys => sys.writeFile(configFilePath, JSON.stringify({ compilerOptions: { outFile: "out.js" }, files: ["f1.ts", "f2.ts"] })),
|
||||
edit: sys => sys.writeFile(configFilePath, JSON.stringify({ compilerOptions: { outFile: "out.js" }, files: ["f1.ts", "f2.ts"] })),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -744,10 +737,10 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([file1, file2, libFile, configFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Delete f2",
|
||||
change: sys => sys.deleteFile("/a/b/f2.ts"),
|
||||
edit: sys => sys.deleteFile("/a/b/f2.ts"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -768,10 +761,10 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([file1, file2, libFile, configFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Delete config file",
|
||||
change: sys => sys.deleteFile(configFilePath),
|
||||
edit: sys => sys.deleteFile(configFilePath),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
@@ -792,7 +785,6 @@ export class A {
|
||||
};
|
||||
return createWatchedSystem([file1, libFile, corruptedConfig]);
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -830,10 +822,10 @@ declare const eval: any`
|
||||
};
|
||||
return createWatchedSystem([libES5, libES2015Promise, app, config1], { executingFilePath: "/compiler/tsc.js" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Change the lib in config",
|
||||
change: sys => sys.writeFile("/src/tsconfig.json", JSON.stringify(
|
||||
edit: sys => sys.writeFile("/src/tsconfig.json", JSON.stringify(
|
||||
{
|
||||
compilerOptions: {
|
||||
module: "commonjs",
|
||||
@@ -873,7 +865,6 @@ declare const eval: any`
|
||||
};
|
||||
return createWatchedSystem([f, config, libFile]);
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
function runQueuedTimeoutCallbacksTwice(sys: TestServerHost) {
|
||||
@@ -883,7 +874,7 @@ declare const eval: any`
|
||||
|
||||
const changeModuleFileToModuleFile1: TscWatchCompileChange = {
|
||||
caption: "Rename moduleFile to moduleFile1",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.renameFile("/a/b/moduleFile.ts", "/a/b/moduleFile1.ts");
|
||||
sys.deleteFile("/a/b/moduleFile.js");
|
||||
},
|
||||
@@ -891,7 +882,7 @@ declare const eval: any`
|
||||
};
|
||||
const changeModuleFile1ToModuleFile: TscWatchCompileChange = {
|
||||
caption: "Rename moduleFile1 back to moduleFile",
|
||||
change: sys => sys.renameFile("/a/b/moduleFile1.ts", "/a/b/moduleFile.ts"),
|
||||
edit: sys => sys.renameFile("/a/b/moduleFile1.ts", "/a/b/moduleFile.ts"),
|
||||
timeouts: runQueuedTimeoutCallbacksTwice,
|
||||
};
|
||||
|
||||
@@ -910,7 +901,7 @@ declare const eval: any`
|
||||
};
|
||||
return createWatchedSystem([moduleFile, file1, libFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
changeModuleFileToModuleFile1,
|
||||
changeModuleFile1ToModuleFile
|
||||
]
|
||||
@@ -931,7 +922,7 @@ declare const eval: any`
|
||||
};
|
||||
return createWatchedSystem([moduleFile, file1, configFile, libFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
changeModuleFileToModuleFile1,
|
||||
changeModuleFile1ToModuleFile
|
||||
]
|
||||
@@ -959,7 +950,6 @@ declare const eval: any`
|
||||
};
|
||||
return createWatchedSystem([f1, config, node, cwd, libFile], { currentDirectory: cwd.path });
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -973,10 +963,10 @@ declare const eval: any`
|
||||
};
|
||||
return createWatchedSystem([file1, libFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Create module file",
|
||||
change: sys => sys.writeFile("/a/b/moduleFile.ts", "export function bar() { }"),
|
||||
edit: sys => sys.writeFile("/a/b/moduleFile.ts", "export function bar() { }"),
|
||||
timeouts: runQueuedTimeoutCallbacksTwice,
|
||||
}
|
||||
]
|
||||
@@ -1002,7 +992,6 @@ declare const eval: any`
|
||||
};
|
||||
return createWatchedSystem([file, configFile, libFile]);
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -1022,7 +1011,6 @@ declare const eval: any`
|
||||
};
|
||||
return createWatchedSystem([file, configFile, libFile]);
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -1036,10 +1024,10 @@ declare const eval: any`
|
||||
};
|
||||
return createWatchedSystem([file, configFile, libFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "change config file to add error",
|
||||
change: sys => sys.writeFile(configFilePath, `{
|
||||
edit: sys => sys.writeFile(configFilePath, `{
|
||||
"compilerOptions": {
|
||||
"haha": 123
|
||||
}
|
||||
@@ -1048,7 +1036,7 @@ declare const eval: any`
|
||||
},
|
||||
{
|
||||
caption: "change config file to remove error",
|
||||
change: sys => sys.writeFile(configFilePath, `{
|
||||
edit: sys => sys.writeFile(configFilePath, `{
|
||||
"compilerOptions": {
|
||||
}
|
||||
}`),
|
||||
@@ -1075,7 +1063,6 @@ declare const eval: any`
|
||||
};
|
||||
return createWatchedSystem([file1, configFile, libFile]);
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -1104,7 +1091,6 @@ declare const eval: any`
|
||||
};
|
||||
return createWatchedSystem([f, config, t1, t2, libFile], { currentDirectory: ts.getDirectoryPath(f.path) });
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
it("should support files without extensions", () => {
|
||||
@@ -1128,7 +1114,6 @@ declare const eval: any`
|
||||
baseline,
|
||||
oldSnap,
|
||||
getPrograms,
|
||||
changes: ts.emptyArray,
|
||||
watchOrSolution: watch
|
||||
});
|
||||
});
|
||||
@@ -1156,10 +1141,10 @@ declare const eval: any`
|
||||
};
|
||||
return createWatchedSystem([file, libFile, configFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Remove the comment from config file",
|
||||
change: sys => sys.writeFile(configFilePath, `
|
||||
edit: sys => sys.writeFile(configFilePath, `
|
||||
{
|
||||
"compilerOptions": {
|
||||
"inlineSourceMap": true,
|
||||
@@ -1194,11 +1179,11 @@ declare const eval: any`
|
||||
};
|
||||
return createWatchedSystem([file1, file2, libFile, tsconfig], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
noopChange,
|
||||
{
|
||||
caption: "Add new file",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/src/file3.ts`, `export const y = 10;`),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/src/file3.ts`, `export const y = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2), // To update program and failed lookups
|
||||
},
|
||||
noopChange,
|
||||
@@ -1253,10 +1238,10 @@ function two() {
|
||||
};
|
||||
return createWatchedSystem([file, libFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Change file to module",
|
||||
change: sys => sys.writeFile("/a/b/file.ts", `function one() {}
|
||||
edit: sys => sys.writeFile("/a/b/file.ts", `function one() {}
|
||||
export function two() {
|
||||
return function three() {
|
||||
one();
|
||||
@@ -1284,10 +1269,10 @@ export function two() {
|
||||
};
|
||||
return createWatchedSystem([file, libFile, configFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Rename file1 to file2",
|
||||
change: sys => sys.renameFile("/home/username/project/src/file1.ts", "/home/username/project/src/file2.ts"),
|
||||
edit: sys => sys.renameFile("/home/username/project/src/file1.ts", "/home/username/project/src/file2.ts"),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}
|
||||
]
|
||||
@@ -1296,7 +1281,7 @@ export function two() {
|
||||
function changeParameterTypeOfBFile(parameterName: string, toType: string): TscWatchCompileChange {
|
||||
return {
|
||||
caption: `Changed ${parameterName} type to ${toType}`,
|
||||
change: sys => sys.replaceFileText(`/user/username/projects/myproject/b.ts`, new RegExp(`${parameterName}\: [a-z]*`), `${parameterName}: ${toType}`),
|
||||
edit: sys => sys.replaceFileText(`/user/username/projects/myproject/b.ts`, new RegExp(`${parameterName}\: [a-z]*`), `${parameterName}: ${toType}`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
};
|
||||
}
|
||||
@@ -1330,7 +1315,7 @@ export default test;`
|
||||
};
|
||||
return createWatchedSystem([aFile, bFile, libFile, tsconfigFile], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
changeParameterTypeOfBFile("x", "string"),
|
||||
changeParameterTypeOfBFile("x", "number"),
|
||||
changeParameterTypeOfBFile("y", "string"),
|
||||
@@ -1354,20 +1339,20 @@ foo().hello`
|
||||
};
|
||||
return createWatchedSystem([aFile, config, libFile], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Enable strict null checks",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: { strictNullChecks: true } })),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: { strictNullChecks: true } })),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "Set always strict false",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: { strict: true, alwaysStrict: false } })), // Avoid changing 'alwaysStrict' or must re-bind
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: { strict: true, alwaysStrict: false } })), // Avoid changing 'alwaysStrict' or must re-bind
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "Disable strict",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: {} })),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: {} })),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
]
|
||||
@@ -1397,10 +1382,10 @@ v === 'foo';`
|
||||
};
|
||||
return createWatchedSystem([aFile, config, libFile], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Enable noErrorTruncation",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: { noErrorTruncation: true } })),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: { noErrorTruncation: true } })),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
]
|
||||
@@ -1422,10 +1407,10 @@ class D extends C { prop = 1; }`
|
||||
};
|
||||
return createWatchedSystem([aFile, config, libFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Enable useDefineForClassFields",
|
||||
change: sys => sys.writeFile(`/tsconfig.json`, JSON.stringify({ compilerOptions: { target: "es6", useDefineForClassFields: true } })),
|
||||
edit: sys => sys.writeFile(`/tsconfig.json`, JSON.stringify({ compilerOptions: { target: "es6", useDefineForClassFields: true } })),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
]
|
||||
@@ -1451,20 +1436,20 @@ export function f(p: C) { return p; }`
|
||||
};
|
||||
return createWatchedSystem([aFile, bFile, config, libFile], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: 'Set to "remove"',
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: { importsNotUsedAsValues: "remove" } })),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: { importsNotUsedAsValues: "remove" } })),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: 'Set to "error"',
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: { importsNotUsedAsValues: "error" } })),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: { importsNotUsedAsValues: "error" } })),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: 'Set to "preserve"',
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: { importsNotUsedAsValues: "preserve" } })),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: { importsNotUsedAsValues: "preserve" } })),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
]
|
||||
@@ -1490,10 +1475,10 @@ export function f(p: C) { return p; }`
|
||||
};
|
||||
return createWatchedSystem([aFile, bFile, config, libFile], { useCaseSensitiveFileNames: false });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Enable forceConsistentCasingInFileNames",
|
||||
change: sys => sys.writeFile(`/tsconfig.json`, JSON.stringify({ compilerOptions: { forceConsistentCasingInFileNames: true } })),
|
||||
edit: sys => sys.writeFile(`/tsconfig.json`, JSON.stringify({ compilerOptions: { forceConsistentCasingInFileNames: true } })),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
]
|
||||
@@ -1518,10 +1503,10 @@ export function f(p: C) { return p; }`
|
||||
};
|
||||
return createWatchedSystem([aFile, jsonFile, config, libFile], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Enable resolveJsonModule",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: { moduleResolution: "node", resolveJsonModule: true } })),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({ compilerOptions: { moduleResolution: "node", resolveJsonModule: true } })),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
]
|
||||
@@ -1544,18 +1529,18 @@ export function f(p: C) { return p; }`
|
||||
};
|
||||
return createWatchedSystem([aFile, config, libFile], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Create b.ts with same content",
|
||||
// Create bts with same file contents
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/b.ts`, `declare module 'a' {
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/b.ts`, `declare module 'a' {
|
||||
type foo = number;
|
||||
}`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "Delete b.ts",
|
||||
change: sys => sys.deleteFile(`/user/username/projects/myproject/b.ts`),
|
||||
edit: sys => sys.deleteFile(`/user/username/projects/myproject/b.ts`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
]
|
||||
@@ -1582,15 +1567,15 @@ interface Document {
|
||||
subScenario: `updates errors in lib file/${subScenario}`,
|
||||
commandLineArgs: ["-w", aFile.path, ...commandLineOptions],
|
||||
sys: () => createWatchedSystem([aFile, libFileWithDocument], { currentDirectory: "/user/username/projects/myproject" }),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Remove document declaration from file",
|
||||
change: sys => sys.writeFile(aFile.path, aFile.content.replace(fieldWithoutReadonly, "var x: string;")),
|
||||
edit: sys => sys.writeFile(aFile.path, aFile.content.replace(fieldWithoutReadonly, "var x: string;")),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "Rever the file to contain document declaration",
|
||||
change: sys => sys.writeFile(aFile.path, aFile.content),
|
||||
edit: sys => sys.writeFile(aFile.path, aFile.content),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
]
|
||||
@@ -1628,7 +1613,7 @@ var y: number;
|
||||
const configFileContent = JSON.stringify({ compilerOptions });
|
||||
return {
|
||||
caption: `Changing config to ${configFileContent}`,
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, configFileContent),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, configFileContent),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
};
|
||||
}
|
||||
@@ -1664,7 +1649,7 @@ interface Document {
|
||||
};
|
||||
return createWatchedSystem([aFile, bFile, configFile, libFileWithDocument], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
changeWhenLibCheckChanges({ skipLibCheck: true }),
|
||||
changeWhenLibCheckChanges({ skipDefaultLibCheck: true }),
|
||||
changeWhenLibCheckChanges({}),
|
||||
@@ -1698,10 +1683,10 @@ const b: string = a;`
|
||||
};
|
||||
return createWatchedSystem([aFile, bFile, configFile, libFile], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Change shape of a",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/a.ts`, `export const a: number = 1`),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/a.ts`, `export const a: number = 1`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
]
|
||||
@@ -1731,10 +1716,10 @@ const b: string = a;`
|
||||
};
|
||||
return createWatchedSystem([aFile, bFile, configFile, libFile], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Make changes to file a",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/a.ts`, `
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/a.ts`, `
|
||||
|
||||
import { x } from "../b";`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
@@ -1761,10 +1746,10 @@ import { x } from "../b";`),
|
||||
};
|
||||
return createWatchedSystem([index, configFile, libFile], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Update 'jsx' to 'react'",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, '{ "compilerOptions": { "jsx": "react" } }'),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, '{ "compilerOptions": { "jsx": "react" } }'),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
]
|
||||
@@ -1800,10 +1785,10 @@ import { x } from "../b";`),
|
||||
libFile, commonFile1, commonFile2, configFile, firstExtendedConfigFile, secondExtendedConfigFile
|
||||
]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Change config to extend another config",
|
||||
change: sys => sys.modifyFile(configFilePath, JSON.stringify({
|
||||
edit: sys => sys.modifyFile(configFilePath, JSON.stringify({
|
||||
extends: "./second.tsconfig.json",
|
||||
compilerOptions: {},
|
||||
files: [commonFile1.path, commonFile2.path]
|
||||
@@ -1812,7 +1797,7 @@ import { x } from "../b";`),
|
||||
},
|
||||
{
|
||||
caption: "Change first extended config",
|
||||
change: sys => sys.modifyFile("/a/b/first.tsconfig.json", JSON.stringify({
|
||||
edit: sys => sys.modifyFile("/a/b/first.tsconfig.json", JSON.stringify({
|
||||
compilerOptions: {
|
||||
strict: false,
|
||||
}
|
||||
@@ -1821,7 +1806,7 @@ import { x } from "../b";`),
|
||||
},
|
||||
{
|
||||
caption: "Change second extended config",
|
||||
change: sys => sys.modifyFile("/a/b/second.tsconfig.json", JSON.stringify({
|
||||
edit: sys => sys.modifyFile("/a/b/second.tsconfig.json", JSON.stringify({
|
||||
extends: "./first.tsconfig.json",
|
||||
compilerOptions: {
|
||||
strictNullChecks: true,
|
||||
@@ -1831,7 +1816,7 @@ import { x } from "../b";`),
|
||||
},
|
||||
{
|
||||
caption: "Change config to stop extending another config",
|
||||
change: sys => sys.modifyFile(configFilePath, JSON.stringify({
|
||||
edit: sys => sys.modifyFile(configFilePath, JSON.stringify({
|
||||
compilerOptions: {},
|
||||
files: [commonFile1.path, commonFile2.path]
|
||||
})),
|
||||
@@ -1869,10 +1854,10 @@ import { x } from "../b";`),
|
||||
};
|
||||
return createWatchedSystem([module1, module2, symlink, config, libFile], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Add module3 to folder2",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/client/linktofolder2/module3.ts`, `import * as M from "folder1/module1";`),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/client/linktofolder2/module3.ts`, `import * as M from "folder1/module1";`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
]
|
||||
@@ -1920,30 +1905,30 @@ import { x } from "../b";`),
|
||||
};
|
||||
return createWatchedSystem([config1, class1, config2, class2, libFile, class1Dt]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Add class3 to project1",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/projects/project1/class3.ts`, `class class3 {}`),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/projects/project1/class3.ts`, `class class3 {}`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "Add output of class3",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/projects/project1/class3.d.ts`, `declare class class3 {}`),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/projects/project1/class3.d.ts`, `declare class class3 {}`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "Add excluded file to project1",
|
||||
change: sys => sys.ensureFileOrFolder({ path: `/user/username/projects/myproject/projects/project1/temp/file.d.ts`, content: `declare class file {}` }),
|
||||
edit: sys => sys.ensureFileOrFolder({ path: `/user/username/projects/myproject/projects/project1/temp/file.d.ts`, content: `declare class file {}` }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(0),
|
||||
},
|
||||
{
|
||||
caption: "Delete output of class3",
|
||||
change: sys => sys.deleteFile(`/user/username/projects/myproject/projects/project1/class3.d.ts`),
|
||||
edit: sys => sys.deleteFile(`/user/username/projects/myproject/projects/project1/class3.d.ts`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "Add output of class3",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/projects/project1/class3.d.ts`, `declare class class3 {}`),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/projects/project1/class3.d.ts`, `declare class class3 {}`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
]
|
||||
@@ -1964,10 +1949,10 @@ import { x } from "../b";`),
|
||||
};
|
||||
return createWatchedSystem([module1, config, libFile], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Create foo in project root",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/foo`, ``),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/foo`, ``),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
]
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import * as ts from "../../_namespaces/ts";
|
||||
import {
|
||||
getTsBuildProjectFile,
|
||||
getTsBuildProjectFilePath,
|
||||
@@ -31,10 +30,10 @@ describe("unittests:: tsc-watch:: projects with references: invoking when refere
|
||||
{ currentDirectory: `/user/username/projects/sample1` }
|
||||
),
|
||||
commandLineArgs: ["-w", "-p", "tests", "--traceResolution", "--explainFiles"],
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "local edit in logic ts, and build logic",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.appendFile(getTsBuildProjectFilePath("sample1", "logic/index.ts"), `function foo() { }`);
|
||||
const solutionBuilder = createSolutionBuilder(sys, ["logic"]);
|
||||
solutionBuilder.build();
|
||||
@@ -45,7 +44,7 @@ describe("unittests:: tsc-watch:: projects with references: invoking when refere
|
||||
},
|
||||
{
|
||||
caption: "non local edit in logic ts, and build logic",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.appendFile(getTsBuildProjectFilePath("sample1", "logic/index.ts"), `export function gfoo() { }`);
|
||||
const solutionBuilder = createSolutionBuilder(sys, ["logic"]);
|
||||
solutionBuilder.build();
|
||||
@@ -54,7 +53,7 @@ describe("unittests:: tsc-watch:: projects with references: invoking when refere
|
||||
},
|
||||
{
|
||||
caption: "change in project reference config file builds correctly",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.writeFile(getTsBuildProjectFilePath("sample1", "logic/tsconfig.json"), JSON.stringify({
|
||||
compilerOptions: { composite: true, declaration: true, declarationDir: "decls" },
|
||||
references: [{ path: "../core" }]
|
||||
@@ -92,10 +91,10 @@ describe("unittests:: tsc-watch:: projects with references: invoking when refere
|
||||
{ currentDirectory: `/user/username/projects/transitiveReferences` }
|
||||
),
|
||||
commandLineArgs: ["-w", "-p", "tsconfig.c.json", "--traceResolution", "--explainFiles"],
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "non local edit b ts, and build b",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.appendFile(getTsBuildProjectFilePath("transitiveReferences", "b.ts"), `export function gfoo() { }`);
|
||||
const solutionBuilder = createSolutionBuilder(sys, ["tsconfig.b.json"]);
|
||||
solutionBuilder.build();
|
||||
@@ -104,7 +103,7 @@ describe("unittests:: tsc-watch:: projects with references: invoking when refere
|
||||
},
|
||||
{
|
||||
caption: "edit on config file",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.ensureFileOrFolder({
|
||||
path: getTsBuildProjectFilePath("transitiveReferences", "nrefs/a.d.ts"),
|
||||
content: sys.readFile(getTsBuildProjectFilePath("transitiveReferences", "refs/a.d.ts"))!
|
||||
@@ -115,37 +114,37 @@ describe("unittests:: tsc-watch:: projects with references: invoking when refere
|
||||
},
|
||||
{
|
||||
caption: "Revert config file edit",
|
||||
change: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "tsconfig.c.json"), { "@ref/*": ["./refs/*"] }),
|
||||
edit: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "tsconfig.c.json"), { "@ref/*": ["./refs/*"] }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
{
|
||||
caption: "edit in referenced config file",
|
||||
change: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "tsconfig.b.json"), { "@ref/*": ["./nrefs/*"] }),
|
||||
edit: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "tsconfig.b.json"), { "@ref/*": ["./nrefs/*"] }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
{
|
||||
caption: "Revert referenced config file edit",
|
||||
change: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "tsconfig.b.json"), { "@ref/*": ["./refs/*"] }),
|
||||
edit: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "tsconfig.b.json"), { "@ref/*": ["./refs/*"] }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
{
|
||||
caption: "deleting referenced config file",
|
||||
change: sys => sys.deleteFile(getTsBuildProjectFilePath("transitiveReferences", "tsconfig.b.json")),
|
||||
edit: sys => sys.deleteFile(getTsBuildProjectFilePath("transitiveReferences", "tsconfig.b.json")),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
{
|
||||
caption: "Revert deleting referenced config file",
|
||||
change: sys => sys.ensureFileOrFolder(getTsBuildProjectFile("transitiveReferences", "tsconfig.b.json")),
|
||||
edit: sys => sys.ensureFileOrFolder(getTsBuildProjectFile("transitiveReferences", "tsconfig.b.json")),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
{
|
||||
caption: "deleting transitively referenced config file",
|
||||
change: sys => sys.deleteFile(getTsBuildProjectFilePath("transitiveReferences", "tsconfig.a.json")),
|
||||
edit: sys => sys.deleteFile(getTsBuildProjectFilePath("transitiveReferences", "tsconfig.a.json")),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
{
|
||||
caption: "Revert deleting transitively referenced config file",
|
||||
change: sys => sys.ensureFileOrFolder(getTsBuildProjectFile("transitiveReferences", "tsconfig.a.json")),
|
||||
edit: sys => sys.ensureFileOrFolder(getTsBuildProjectFile("transitiveReferences", "tsconfig.a.json")),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
],
|
||||
@@ -180,7 +179,6 @@ describe("unittests:: tsc-watch:: projects with references: invoking when refere
|
||||
{ currentDirectory: `/user/username/projects/transitiveReferences` }
|
||||
),
|
||||
commandLineArgs: ["-w", "-p", "tsconfig.c.json", "--traceResolution", "--explainFiles"],
|
||||
changes: ts.emptyArray,
|
||||
baselineDependencies: true,
|
||||
});
|
||||
|
||||
@@ -235,10 +233,10 @@ X;`,
|
||||
{ currentDirectory: `/user/username/projects/transitiveReferences` }
|
||||
),
|
||||
commandLineArgs: ["-w", "-p", "c", "--traceResolution", "--explainFiles"],
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "non local edit b ts, and build b",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.appendFile(getTsBuildProjectFilePath("transitiveReferences", "b/index.ts"), `export function gfoo() { }`);
|
||||
const solutionBuilder = createSolutionBuilder(sys, ["b"]);
|
||||
solutionBuilder.build();
|
||||
@@ -247,7 +245,7 @@ X;`,
|
||||
},
|
||||
{
|
||||
caption: "edit on config file",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.ensureFileOrFolder({
|
||||
path: getTsBuildProjectFilePath("transitiveReferences", "nrefs/a.d.ts"),
|
||||
content: sys.readFile(getTsBuildProjectFilePath("transitiveReferences", "refs/a.d.ts"))!
|
||||
@@ -258,27 +256,27 @@ X;`,
|
||||
},
|
||||
{
|
||||
caption: "Revert config file edit",
|
||||
change: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "c/tsconfig.json"), { "@ref/*": ["../refs/*"] }),
|
||||
edit: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "c/tsconfig.json"), { "@ref/*": ["../refs/*"] }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
{
|
||||
caption: "edit in referenced config file",
|
||||
change: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json"), { "@ref/*": ["../nrefs/*"] }),
|
||||
edit: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json"), { "@ref/*": ["../nrefs/*"] }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
{
|
||||
caption: "Revert referenced config file edit",
|
||||
change: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json"), { "@ref/*": ["../refs/*"] }),
|
||||
edit: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json"), { "@ref/*": ["../refs/*"] }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
{
|
||||
caption: "deleting referenced config file",
|
||||
change: sys => sys.deleteFile(getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json")),
|
||||
edit: sys => sys.deleteFile(getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json")),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2)
|
||||
},
|
||||
{
|
||||
caption: "Revert deleting referenced config file",
|
||||
change: sys => sys.writeFile(
|
||||
edit: sys => sys.writeFile(
|
||||
getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json"),
|
||||
JSON.stringify({
|
||||
compilerOptions: { composite: true, baseUrl: "./", paths: { "@ref/*": ["../*"] } },
|
||||
@@ -290,12 +288,12 @@ X;`,
|
||||
},
|
||||
{
|
||||
caption: "deleting transitively referenced config file",
|
||||
change: sys => sys.deleteFile(getTsBuildProjectFilePath("transitiveReferences", "a/tsconfig.json")),
|
||||
edit: sys => sys.deleteFile(getTsBuildProjectFilePath("transitiveReferences", "a/tsconfig.json")),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2)
|
||||
},
|
||||
{
|
||||
caption: "Revert deleting transitively referenced config file",
|
||||
change: sys => sys.writeFile(
|
||||
edit: sys => sys.writeFile(
|
||||
getTsBuildProjectFilePath("transitiveReferences", "a/tsconfig.json"),
|
||||
JSON.stringify({
|
||||
compilerOptions: { composite: true },
|
||||
@@ -354,10 +352,10 @@ X;`,
|
||||
{ currentDirectory: `/user/username/projects/transitiveReferences` }
|
||||
),
|
||||
commandLineArgs: ["-w", "-p", "c", "--traceResolution", "--explainFiles"],
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "non local edit b ts, and build b",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.appendFile(getTsBuildProjectFilePath("transitiveReferences", "b/index.ts"), `export function gfoo() { }`);
|
||||
const solutionBuilder = createSolutionBuilder(sys, ["b"]);
|
||||
solutionBuilder.build();
|
||||
@@ -366,7 +364,7 @@ X;`,
|
||||
},
|
||||
{
|
||||
caption: "edit on config file",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.ensureFileOrFolder({
|
||||
path: getTsBuildProjectFilePath("transitiveReferences", "nrefs/a.d.ts"),
|
||||
content: sys.readFile(getTsBuildProjectFilePath("transitiveReferences", "refs/a.d.ts"))!
|
||||
@@ -377,27 +375,27 @@ X;`,
|
||||
},
|
||||
{
|
||||
caption: "Revert config file edit",
|
||||
change: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "c/tsconfig.json"), { "@ref/*": ["../refs/*"] }),
|
||||
edit: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "c/tsconfig.json"), { "@ref/*": ["../refs/*"] }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
{
|
||||
caption: "edit in referenced config file",
|
||||
change: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json"), { "@ref/*": ["../nrefs/*"] }),
|
||||
edit: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json"), { "@ref/*": ["../nrefs/*"] }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
{
|
||||
caption: "Revert referenced config file edit",
|
||||
change: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json"), { "@ref/*": ["../refs/*"] }),
|
||||
edit: sys => changeCompilerOpitonsPaths(sys, getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json"), { "@ref/*": ["../refs/*"] }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
{
|
||||
caption: "deleting referenced config file",
|
||||
change: sys => sys.deleteFile(getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json")),
|
||||
edit: sys => sys.deleteFile(getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json")),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2)
|
||||
},
|
||||
{
|
||||
caption: "Revert deleting referenced config file",
|
||||
change: sys => sys.writeFile(
|
||||
edit: sys => sys.writeFile(
|
||||
getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json"),
|
||||
JSON.stringify({
|
||||
compilerOptions: { composite: true, baseUrl: "./", paths: { "@ref/*": ["../*"] } },
|
||||
@@ -408,12 +406,12 @@ X;`,
|
||||
},
|
||||
{
|
||||
caption: "deleting transitively referenced config file",
|
||||
change: sys => sys.deleteFile(getTsBuildProjectFilePath("transitiveReferences", "a/tsconfig.json")),
|
||||
edit: sys => sys.deleteFile(getTsBuildProjectFilePath("transitiveReferences", "a/tsconfig.json")),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2)
|
||||
},
|
||||
{
|
||||
caption: "Revert deleting transitively referenced config file",
|
||||
change: sys => sys.writeFile(
|
||||
edit: sys => sys.writeFile(
|
||||
getTsBuildProjectFilePath("transitiveReferences", "a/tsconfig.json"),
|
||||
JSON.stringify({ compilerOptions: { composite: true } }),
|
||||
),
|
||||
@@ -440,10 +438,10 @@ X;`,
|
||||
{ currentDirectory: `/user/username/projects/sample1` }
|
||||
),
|
||||
commandLineArgs: ["-w", "-p", "logic", "--traceResolution", "--explainFiles"],
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "change declration map in core",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.replaceFileText(getTsBuildProjectFilePath("sample1", "core/tsconfig.json"), `"declarationMap": true,`, `"declarationMap": false,`);
|
||||
const solutionBuilder = createSolutionBuilder(sys, ["core"]);
|
||||
solutionBuilder.build();
|
||||
|
||||
@@ -44,10 +44,10 @@ describe("unittests:: tsc-watch:: resolutionCache:: tsc-watch module resolution
|
||||
baseline,
|
||||
oldSnap,
|
||||
getPrograms,
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Adding text doesnt re-resole the imports",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
// patch fileExists to make sure that disk is not touched
|
||||
host.fileExists = ts.notImplemented;
|
||||
sys.writeFile(root.path, `import {x} from "f1"
|
||||
@@ -57,7 +57,7 @@ describe("unittests:: tsc-watch:: resolutionCache:: tsc-watch module resolution
|
||||
},
|
||||
{
|
||||
caption: "Resolves f2",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
host.fileExists = (fileName): boolean => {
|
||||
if (fileName === "lib.d.ts") {
|
||||
return false;
|
||||
@@ -75,7 +75,7 @@ describe("unittests:: tsc-watch:: resolutionCache:: tsc-watch module resolution
|
||||
},
|
||||
{
|
||||
caption: "Resolve f1",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
fileExistsIsCalled = false;
|
||||
host.fileExists = (fileName): boolean => {
|
||||
if (fileName === "lib.d.ts") {
|
||||
@@ -139,9 +139,9 @@ describe("unittests:: tsc-watch:: resolutionCache:: tsc-watch module resolution
|
||||
baseline,
|
||||
oldSnap,
|
||||
getPrograms,
|
||||
changes: [{
|
||||
edits: [{
|
||||
caption: "write imported file",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
fileExistsCalledForBar = false;
|
||||
sys.writeFile(root.path,`import {y} from "bar"`);
|
||||
sys.writeFile(imported.path, imported.content);
|
||||
@@ -195,10 +195,10 @@ describe("unittests:: tsc-watch:: resolutionCache:: tsc-watch module resolution
|
||||
baseline,
|
||||
oldSnap,
|
||||
getPrograms,
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Delete imported file",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
fileExistsCalledForBar = false;
|
||||
sys.deleteFile(imported.path);
|
||||
},
|
||||
@@ -209,7 +209,7 @@ describe("unittests:: tsc-watch:: resolutionCache:: tsc-watch module resolution
|
||||
},
|
||||
{
|
||||
caption: "Create imported file",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
fileExistsCalledForBar = false;
|
||||
sys.writeFile(imported.path, imported.content);
|
||||
},
|
||||
@@ -232,10 +232,10 @@ describe("unittests:: tsc-watch:: resolutionCache:: tsc-watch module resolution
|
||||
path: "/a/b/foo.ts",
|
||||
content: `import * as fs from "fs";`
|
||||
}, libFile], { currentDirectory: "/a/b" }),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "npm install node types",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.ensureFileOrFolder({
|
||||
path: "/a/b/node_modules/@types/node/package.json",
|
||||
content: `
|
||||
@@ -284,10 +284,10 @@ declare module "url" {
|
||||
};
|
||||
return createWatchedSystem([root, file, libFile], { currentDirectory: "/a/b" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Add fs definition",
|
||||
change: sys => sys.appendFile("/a/b/bar.d.ts", `
|
||||
edit: sys => sys.appendFile("/a/b/bar.d.ts", `
|
||||
declare module "fs" {
|
||||
export interface Stats {
|
||||
isFile(): boolean;
|
||||
@@ -331,10 +331,10 @@ declare module "fs" {
|
||||
};
|
||||
return createWatchedSystem([file1, file2, module1, libFile, configFile], { currentDirectory: "/a/b/projects/myProject/" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Add new line to file1",
|
||||
change: sys => sys.appendFile("/a/b/projects/myProject/src/file1.ts", "\n;"),
|
||||
edit: sys => sys.appendFile("/a/b/projects/myProject/src/file1.ts", "\n;"),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}
|
||||
]
|
||||
@@ -355,10 +355,10 @@ declare module "fs" {
|
||||
};
|
||||
return createWatchedSystem([file, libFile, module], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "npm install",
|
||||
change: sys => sys.renameFolder(`/user/username/projects/myproject/node_modules2`, `/user/username/projects/myproject/node_modules`),
|
||||
edit: sys => sys.renameFolder(`/user/username/projects/myproject/node_modules2`, `/user/username/projects/myproject/node_modules`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}
|
||||
]
|
||||
@@ -385,10 +385,10 @@ declare module "fs" {
|
||||
};
|
||||
return createWatchedSystem([libFile, file1, file2, config]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "npm install file and folder that start with '.'",
|
||||
change: sys => sys.ensureFileOrFolder({
|
||||
edit: sys => sys.ensureFileOrFolder({
|
||||
path: `/user/username/projects/myproject/node_modules/.cache/babel-loader/89c02171edab901b9926470ba6d5677e.ts`,
|
||||
content: JSON.stringify({ something: 10 })
|
||||
}),
|
||||
@@ -421,10 +421,10 @@ declare module "fs" {
|
||||
};
|
||||
return createWatchedSystem([app, tsconfig, libFile]);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "npm install ts-types",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.ensureFileOrFolder({
|
||||
path: `/user/username/projects/myproject/node_modules/@myapp/ts-types/package.json`,
|
||||
content: JSON.stringify({
|
||||
@@ -447,7 +447,7 @@ declare namespace myapp {
|
||||
},
|
||||
{
|
||||
caption: "No change, just check program",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: (sys, [[oldProgram, oldBuilderProgram]], watchorSolution) => {
|
||||
sys.checkTimeoutQueueLength(0);
|
||||
const newProgram = (watchorSolution as ts.WatchOfConfigFile<ts.EmitAndSemanticDiagnosticsBuilderProgram>).getProgram();
|
||||
@@ -495,7 +495,6 @@ declare namespace myapp {
|
||||
const files = [libFile, mainFile, config, linkedPackageInMain, linkedPackageJson, linkedPackageIndex, linkedPackageOther];
|
||||
return createWatchedSystem(files, { currentDirectory: mainPackageRoot });
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
describe("works when installing something in node_modules or @types when there is no notification from fs for index file", () => {
|
||||
@@ -540,15 +539,15 @@ declare namespace NodeJS {
|
||||
const { nodeAtTypesIndex, nodeAtTypesBase, nodeAtTypes36Base, nodeAtTypesGlobals } = getNodeAtTypes();
|
||||
return createWatchedSystem([file, libFile, tsconfig, nodeAtTypesIndex, nodeAtTypesBase, nodeAtTypes36Base, nodeAtTypesGlobals], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "npm ci step one: remove all node_modules files",
|
||||
change: sys => sys.deleteFolder(`/user/username/projects/myproject/node_modules/@types`, /*recursive*/ true),
|
||||
edit: sys => sys.deleteFolder(`/user/username/projects/myproject/node_modules/@types`, /*recursive*/ true),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: `npm ci step two: create atTypes but something else in the @types folder`,
|
||||
change: sys => sys.ensureFileOrFolder({
|
||||
edit: sys => sys.ensureFileOrFolder({
|
||||
path: `/user/username/projects/myproject/node_modules/@types/mocha/index.d.ts`,
|
||||
content: `export const foo = 10;`
|
||||
}),
|
||||
@@ -556,12 +555,12 @@ declare namespace NodeJS {
|
||||
},
|
||||
{
|
||||
caption: `npm ci step three: create atTypes node folder`,
|
||||
change: sys => sys.ensureFileOrFolder({ path: `/user/username/projects/myproject/node_modules/@types/node` }),
|
||||
edit: sys => sys.ensureFileOrFolder({ path: `/user/username/projects/myproject/node_modules/@types/node` }),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks()
|
||||
},
|
||||
{
|
||||
caption: `npm ci step four: create atTypes write all the files but dont invoke watcher for index.d.ts`,
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
const { nodeAtTypesIndex, nodeAtTypesBase, nodeAtTypes36Base, nodeAtTypesGlobals } = getNodeAtTypes();
|
||||
sys.ensureFileOrFolder(nodeAtTypesBase);
|
||||
sys.ensureFileOrFolder(nodeAtTypesIndex, /*ignoreWatchInvokedWithTriggerAsFileCreate*/ true);
|
||||
@@ -603,10 +602,10 @@ declare namespace NodeJS {
|
||||
[libFile.path]: libFile.content,
|
||||
}, { currentDirectory: "/src/project" }),
|
||||
commandLineArgs: ["-w", "--explainFiles", "--extendedDiagnostics"],
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "write file not resolved by import",
|
||||
change: sys => sys.ensureFileOrFolder({ path: "/src/project/node_modules/pkg1/index.d.ts", content: `export interface Import1 {}` }),
|
||||
edit: sys => sys.ensureFileOrFolder({ path: "/src/project/node_modules/pkg1/index.d.ts", content: `export interface Import1 {}` }),
|
||||
timeouts: sys => {
|
||||
sys.runQueuedTimeoutCallbacks(); // failed lookup
|
||||
sys.runQueuedTimeoutCallbacks(); // actual update
|
||||
@@ -614,7 +613,7 @@ declare namespace NodeJS {
|
||||
},
|
||||
{
|
||||
caption: "write file not resolved by typeRef",
|
||||
change: sys => sys.ensureFileOrFolder({ path: "/src/project/node_modules/pkg3/index.d.ts", content: `export interface Import3 {}` }),
|
||||
edit: sys => sys.ensureFileOrFolder({ path: "/src/project/node_modules/pkg3/index.d.ts", content: `export interface Import3 {}` }),
|
||||
timeouts: sys => {
|
||||
sys.runQueuedTimeoutCallbacks(); // failed lookup
|
||||
sys.runQueuedTimeoutCallbacks(); // actual update
|
||||
|
||||
@@ -45,7 +45,6 @@ describe("unittests:: tsc-watch:: watchAPI:: with sourceOfProjectReferenceRedire
|
||||
baseline,
|
||||
oldSnap,
|
||||
getPrograms,
|
||||
changes: ts.emptyArray,
|
||||
watchOrSolution: watch
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
TestServerHostTrackingWrittenFiles,
|
||||
} from "../virtualFileSystemWithWatch";
|
||||
import {
|
||||
applyChange,
|
||||
applyEdit,
|
||||
createBaseline,
|
||||
createWatchCompilerHostOfConfigFileForBaseline,
|
||||
runWatchBaseline,
|
||||
@@ -61,7 +61,6 @@ describe("unittests:: tsc-watch:: watchAPI:: tsc-watch with custom module resolu
|
||||
baseline,
|
||||
oldSnap,
|
||||
getPrograms,
|
||||
changes: ts.emptyArray,
|
||||
watchOrSolution: watch
|
||||
});
|
||||
});
|
||||
@@ -96,20 +95,20 @@ describe("unittests:: tsc-watch:: watchAPI:: tsc-watch with custom module resolu
|
||||
baseline,
|
||||
oldSnap,
|
||||
getPrograms,
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "write other with same contents",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/other.d.ts`, ""),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/other.d.ts`, ""),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "change other file",
|
||||
change: sys => sys.appendFile(`/user/username/projects/myproject/other.d.ts`, "export function bar(): void;"),
|
||||
edit: sys => sys.appendFile(`/user/username/projects/myproject/other.d.ts`, "export function bar(): void;"),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "write other with same contents but write ts file",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.appendFile(`/user/username/projects/myproject/other.d.ts`, "");
|
||||
sys.writeFile(`/user/username/projects/myproject/other.ts`, "export function foo() {}");
|
||||
},
|
||||
@@ -163,7 +162,6 @@ describe("unittests:: tsc-watch:: watchAPI:: tsc-watch expose error count to wat
|
||||
baseline,
|
||||
oldSnap,
|
||||
getPrograms,
|
||||
changes: ts.emptyArray,
|
||||
watchOrSolution: watch
|
||||
});
|
||||
});
|
||||
@@ -196,9 +194,9 @@ describe("unittests:: tsc-watch:: watchAPI:: when watchHost does not implement s
|
||||
baseline,
|
||||
oldSnap,
|
||||
getPrograms,
|
||||
changes: [{
|
||||
edits: [{
|
||||
caption: "Write a file",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/bar.ts`, "const y =10;"),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/bar.ts`, "const y =10;"),
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLength(0);
|
||||
watch.getProgram();
|
||||
@@ -242,9 +240,9 @@ describe("unittests:: tsc-watch:: watchAPI:: when watchHost can add extraFileExt
|
||||
baseline,
|
||||
oldSnap,
|
||||
getPrograms,
|
||||
changes: [{
|
||||
edits: [{
|
||||
caption: "Write a file",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/other2.vue`, otherFile.content),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/other2.vue`, otherFile.content),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}],
|
||||
watchOrSolution: watch
|
||||
@@ -325,8 +323,8 @@ describe("unittests:: tsc-watch:: watchAPI:: when watchHost uses createSemanticD
|
||||
caption: string
|
||||
) {
|
||||
// Change file
|
||||
applyChange(sys, baseline, change, caption);
|
||||
applyChange(emitSys, emitBaseline, change, caption);
|
||||
applyEdit(sys, baseline, change, caption);
|
||||
applyEdit(emitSys, emitBaseline, change, caption);
|
||||
}
|
||||
|
||||
function verifyBuilder<T extends ts.BuilderProgram>(
|
||||
@@ -360,9 +358,9 @@ describe("unittests:: tsc-watch:: watchAPI:: when watchHost uses createSemanticD
|
||||
baseline,
|
||||
oldSnap,
|
||||
getPrograms,
|
||||
changes: [{
|
||||
edits: [{
|
||||
caption: "Modify a file",
|
||||
change: sys => sys.appendFile(mainFile.path, "\n// SomeComment"),
|
||||
edit: sys => sys.appendFile(mainFile.path, "\n// SomeComment"),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}],
|
||||
watchOrSolution: watch
|
||||
@@ -455,7 +453,7 @@ describe("unittests:: tsc-watch:: watchAPI:: when watchHost uses createSemanticD
|
||||
createWatch(baseline, config, sys, ts.createSemanticDiagnosticsBuilderProgram);
|
||||
|
||||
// Fix error and emit
|
||||
applyChange(sys, baseline, sys => sys.writeFile(mainFile.path, "export const x = 10;"), "Fix error");
|
||||
applyEdit(sys, baseline, sys => sys.writeFile(mainFile.path, "export const x = 10;"), "Fix error");
|
||||
|
||||
const { cb, getPrograms } = commandLineCallbacks(sys);
|
||||
const oldSnap = sys.snap();
|
||||
@@ -562,10 +560,10 @@ describe("unittests:: tsc-watch:: watchAPI:: when getParsedCommandLine is implem
|
||||
subScenario: "when new file is added to the referenced project with host implementing getParsedCommandLine",
|
||||
commandLineArgs: ["--w", "-p", config2.path, "--extendedDiagnostics"],
|
||||
...baseline,
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Add class3 to project1",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
calledGetParsedCommandLine.clear();
|
||||
sys.writeFile(`/user/username/projects/myproject/projects/project1/class3.ts`, `class class3 {}`);
|
||||
},
|
||||
@@ -573,12 +571,12 @@ describe("unittests:: tsc-watch:: watchAPI:: when getParsedCommandLine is implem
|
||||
},
|
||||
{
|
||||
caption: "Add excluded file to project1",
|
||||
change: sys => sys.ensureFileOrFolder({ path: `/user/username/projects/myproject/projects/project1/temp/file.d.ts`, content: `declare class file {}` }),
|
||||
edit: sys => sys.ensureFileOrFolder({ path: `/user/username/projects/myproject/projects/project1/temp/file.d.ts`, content: `declare class file {}` }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(0),
|
||||
},
|
||||
{
|
||||
caption: "Add output of class3",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/projects/project1/class3.d.ts`, `declare class class3 {}`),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/projects/project1/class3.d.ts`, `declare class class3 {}`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(0),
|
||||
},
|
||||
],
|
||||
@@ -593,10 +591,10 @@ describe("unittests:: tsc-watch:: watchAPI:: when getParsedCommandLine is implem
|
||||
subScenario: "when new file is added to the referenced project with host implementing getParsedCommandLine without implementing useSourceOfProjectReferenceRedirect",
|
||||
commandLineArgs: ["--w", "-p", config2.path, "--extendedDiagnostics"],
|
||||
...baseline,
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Add class3 to project1",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
calledGetParsedCommandLine.clear();
|
||||
sys.writeFile(`/user/username/projects/myproject/projects/project1/class3.ts`, `class class3 {}`);
|
||||
},
|
||||
@@ -604,22 +602,22 @@ describe("unittests:: tsc-watch:: watchAPI:: when getParsedCommandLine is implem
|
||||
},
|
||||
{
|
||||
caption: "Add class3 output to project1",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/projects/project1/class3.d.ts`, `declare class class3 {}`),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/projects/project1/class3.d.ts`, `declare class class3 {}`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "Add excluded file to project1",
|
||||
change: sys => sys.ensureFileOrFolder({ path: `/user/username/projects/myproject/projects/project1/temp/file.d.ts`, content: `declare class file {}` }),
|
||||
edit: sys => sys.ensureFileOrFolder({ path: `/user/username/projects/myproject/projects/project1/temp/file.d.ts`, content: `declare class file {}` }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(0),
|
||||
},
|
||||
{
|
||||
caption: "Delete output of class3",
|
||||
change: sys => sys.deleteFile(`/user/username/projects/myproject/projects/project1/class3.d.ts`),
|
||||
edit: sys => sys.deleteFile(`/user/username/projects/myproject/projects/project1/class3.d.ts`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "Add output of class3",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/projects/project1/class3.d.ts`, `declare class class3 {}`),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/projects/project1/class3.d.ts`, `declare class class3 {}`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
],
|
||||
@@ -656,10 +654,10 @@ describe("unittests:: tsc-watch:: watchAPI:: when builder emit occurs with emitO
|
||||
subScenario,
|
||||
commandLineArgs: ["--w", "--extendedDiagnostics"],
|
||||
...baseline,
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Fix error but run emit with emitOnlyDts",
|
||||
change: sys => {
|
||||
edit: sys => {
|
||||
sys.writeFile(`/user/username/projects/myproject/b.ts`, `export const y = 10;`);
|
||||
callFullEmit = false;
|
||||
},
|
||||
@@ -667,7 +665,7 @@ describe("unittests:: tsc-watch:: watchAPI:: when builder emit occurs with emitO
|
||||
},
|
||||
{
|
||||
caption: "Emit with emitOnlyDts shouldnt emit anything",
|
||||
change: () => {
|
||||
edit: () => {
|
||||
const program = watch.getCurrentProgram();
|
||||
program.emit(/*targetSourceFile*/ undefined, /*writeFile*/ undefined, /*cancellationToken*/ undefined, /*emitOnlyDtsFiles*/ true);
|
||||
baseline.cb(program);
|
||||
@@ -676,7 +674,7 @@ describe("unittests:: tsc-watch:: watchAPI:: when builder emit occurs with emitO
|
||||
},
|
||||
{
|
||||
caption: "Emit all files",
|
||||
change: () => {
|
||||
edit: () => {
|
||||
const program = watch.getCurrentProgram();
|
||||
program.emit();
|
||||
baseline.cb(program);
|
||||
@@ -685,7 +683,7 @@ describe("unittests:: tsc-watch:: watchAPI:: when builder emit occurs with emitO
|
||||
},
|
||||
{
|
||||
caption: "Emit with emitOnlyDts shouldnt emit anything",
|
||||
change: () => {
|
||||
edit: () => {
|
||||
const program = watch.getCurrentProgram();
|
||||
program.emit(/*targetSourceFile*/ undefined, /*writeFile*/ undefined, /*cancellationToken*/ undefined, /*emitOnlyDtsFiles*/ true);
|
||||
baseline.cb(program);
|
||||
@@ -694,7 +692,7 @@ describe("unittests:: tsc-watch:: watchAPI:: when builder emit occurs with emitO
|
||||
},
|
||||
{
|
||||
caption: "Emit full should not emit anything",
|
||||
change: () => {
|
||||
edit: () => {
|
||||
const program = watch.getCurrentProgram();
|
||||
program.emit();
|
||||
baseline.cb(program);
|
||||
|
||||
@@ -31,10 +31,10 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
environmentVariables.set("TSC_WATCHFILE", Tsc_WatchFile.DynamicPolling);
|
||||
return createWatchedSystem([file1, libFile], { environmentVariables });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Time spent to Transition libFile and file1 to low priority queue",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: (sys, programs) => {
|
||||
const initialProgram = programs[0][0];
|
||||
const mediumPollingIntervalThreshold = ts.unchangedPollThresholds[ts.PollingInterval.Medium];
|
||||
@@ -49,20 +49,20 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
{
|
||||
caption: "Make change to file",
|
||||
// Make a change to file
|
||||
change: sys => sys.writeFile("/a/username/project/typescript.ts", "var zz30 = 100;"),
|
||||
edit: sys => sys.writeFile("/a/username/project/typescript.ts", "var zz30 = 100;"),
|
||||
// During this timeout the file would be detected as unchanged
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "Callbacks: medium priority + high priority queue and scheduled program update",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
// Callbacks: medium priority + high priority queue and scheduled program update
|
||||
// This should detect change in the file
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(3),
|
||||
},
|
||||
{
|
||||
caption: "Polling queues polled and everything is in the high polling queue",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: (sys, programs) => {
|
||||
const initialProgram = programs[0][0];
|
||||
const mediumPollingIntervalThreshold = ts.unchangedPollThresholds[ts.PollingInterval.Medium];
|
||||
@@ -97,10 +97,10 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
const files = [libFile, commonFile1, commonFile2, configFile];
|
||||
return createWatchedSystem(files);
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "The timeout is to check the status of all files",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: (sys, programs) => {
|
||||
// On each timeout file does not change
|
||||
const initialProgram = programs[0][0];
|
||||
@@ -113,18 +113,18 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
{
|
||||
caption: "Make change to file but should detect as changed and schedule program update",
|
||||
// Make a change to file
|
||||
change: sys => sys.writeFile(commonFile1.path, "var zz30 = 100;"),
|
||||
edit: sys => sys.writeFile(commonFile1.path, "var zz30 = 100;"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "Callbacks: queue and scheduled program update",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
// Callbacks: scheduled program update and queue for the polling
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2),
|
||||
},
|
||||
{
|
||||
caption: "The timeout is to check the status of all files",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: (sys, programs) => {
|
||||
// On each timeout file does not change
|
||||
const initialProgram = programs[0][0];
|
||||
@@ -161,11 +161,11 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
environmentVariables.set("TSC_WATCHDIRECTORY", tscWatchDirectory);
|
||||
return createWatchedSystem(files, { environmentVariables });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Rename file1 to file2",
|
||||
// Rename the file:
|
||||
change: sys => sys.renameFile(file.path, file.path.replace("file1.ts", "file2.ts")),
|
||||
edit: sys => sys.renameFile(file.path, file.path.replace("file1.ts", "file2.ts")),
|
||||
timeouts: sys => {
|
||||
if (tscWatchDirectory === Tsc_WatchDirectory.DynamicPolling) {
|
||||
// With dynamic polling the fs change would be detected only by running timeouts
|
||||
@@ -229,7 +229,6 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
environmentVariables.set("TSC_WATCHDIRECTORY", Tsc_WatchDirectory.NonRecursiveWatchDirectory);
|
||||
return createWatchedSystem(files, { environmentVariables, currentDirectory: cwd });
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -252,10 +251,10 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
const files = [libFile, file1, file2, configFile];
|
||||
return createWatchedSystem(files, { runWithoutRecursiveWatches: true });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Directory watch updates because of file1.js creation",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // To update directory callbacks for file1.js output
|
||||
sys.checkTimeoutQueueLength(0);
|
||||
@@ -264,7 +263,7 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
{
|
||||
caption: "Remove directory node_modules",
|
||||
// Remove directory node_modules
|
||||
change: sys => sys.deleteFolder(`/user/username/projects/myproject/node_modules`, /*recursive*/ true),
|
||||
edit: sys => sys.deleteFolder(`/user/username/projects/myproject/node_modules`, /*recursive*/ true),
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLength(3); // 1. Failed lookup invalidation 2. For updating program and 3. for updating child watches
|
||||
sys.runQueuedTimeoutCallbacks(sys.getNextTimeoutId() - 2); // Update program
|
||||
@@ -272,7 +271,7 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
},
|
||||
{
|
||||
caption: "Pending directory watchers and program update",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // To update directory watchers
|
||||
sys.checkTimeoutQueueLengthAndRun(2); // To Update program and failed lookup update
|
||||
@@ -283,22 +282,22 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
{
|
||||
caption: "Start npm install",
|
||||
// npm install
|
||||
change: sys => sys.createDirectory(`/user/username/projects/myproject/node_modules`),
|
||||
edit: sys => sys.createDirectory(`/user/username/projects/myproject/node_modules`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(1), // To update folder structure
|
||||
},
|
||||
{
|
||||
caption: "npm install folder creation of file2",
|
||||
change: sys => sys.createDirectory(`/user/username/projects/myproject/node_modules/file2`),
|
||||
edit: sys => sys.createDirectory(`/user/username/projects/myproject/node_modules/file2`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(1), // To update folder structure
|
||||
},
|
||||
{
|
||||
caption: "npm install index file in file2",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/node_modules/file2/index.d.ts`, `export const x = 10;`),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/node_modules/file2/index.d.ts`, `export const x = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(1), // To update folder structure
|
||||
},
|
||||
{
|
||||
caption: "Updates the program",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: sys => {
|
||||
sys.runQueuedTimeoutCallbacks();
|
||||
sys.checkTimeoutQueueLength(2); // To Update program and failed lookup update
|
||||
@@ -306,7 +305,7 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
},
|
||||
{
|
||||
caption: "Invalidates module resolution cache",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: sys => {
|
||||
sys.runQueuedTimeoutCallbacks();
|
||||
sys.checkTimeoutQueueLength(1); // To Update program
|
||||
@@ -314,7 +313,7 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
},
|
||||
{
|
||||
caption: "Pending updates",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: sys => {
|
||||
sys.runQueuedTimeoutCallbacks();
|
||||
sys.checkTimeoutQueueLength(0);
|
||||
@@ -343,21 +342,21 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
const files = [libFile, file1, file2, configFile];
|
||||
return createWatchedSystem(files, { runWithoutRecursiveWatches: true });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
noopChange,
|
||||
{
|
||||
caption: "Add new file, should schedule and run timeout to update directory watcher",
|
||||
change: sys => sys.writeFile(`/user/username/projects/myproject/src/file3.ts`, `export const y = 10;`),
|
||||
edit: sys => sys.writeFile(`/user/username/projects/myproject/src/file3.ts`, `export const y = 10;`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1), // Update the child watch
|
||||
},
|
||||
{
|
||||
caption: "Actual program update to include new file",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2), // Scheduling failed lookup update and program update
|
||||
},
|
||||
{
|
||||
caption: "After program emit with new file, should schedule and run timeout to update directory watcher",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1), // Update the child watch
|
||||
},
|
||||
noopChange,
|
||||
@@ -384,11 +383,11 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
const files = [libFile, file1, file2, configFile];
|
||||
return createWatchedSystem(files, { runWithoutRecursiveWatches: true });
|
||||
},
|
||||
changes: [
|
||||
edits: [
|
||||
noopChange,
|
||||
{
|
||||
caption: "rename the file",
|
||||
change: sys => sys.renameFile(`/user/username/projects/myproject/src/file2.ts`, `/user/username/projects/myproject/src/renamed.ts`),
|
||||
edit: sys => sys.renameFile(`/user/username/projects/myproject/src/file2.ts`, `/user/username/projects/myproject/src/renamed.ts`),
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLength(2); // 1. For updating program and 2. for updating child watches
|
||||
sys.runQueuedTimeoutCallbacks(1); // Update program
|
||||
@@ -396,7 +395,7 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
},
|
||||
{
|
||||
caption: "Pending directory watchers and program update",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // To update directory watchers
|
||||
sys.checkTimeoutQueueLengthAndRun(2); // To Update program and failed lookup update
|
||||
@@ -425,7 +424,6 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
const files = [libFile, commonFile1, commonFile2, configFile];
|
||||
return createWatchedSystem(files);
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -444,7 +442,6 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
const files = [libFile, commonFile1, commonFile2, configFile];
|
||||
return createWatchedSystem(files, { runWithoutRecursiveWatches: true });
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -463,7 +460,6 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
const files = [libFile, commonFile1, commonFile2, configFile];
|
||||
return createWatchedSystem(files, { runWithoutRecursiveWatches: true, runWithFallbackPolling: true });
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
@@ -478,7 +474,6 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
const files = [libFile, commonFile1, commonFile2, configFile];
|
||||
return createWatchedSystem(files);
|
||||
},
|
||||
changes: ts.emptyArray
|
||||
});
|
||||
|
||||
describe("exclude options", () => {
|
||||
@@ -517,10 +512,10 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
subScenario: `watchOptions/with excludeFiles option${additionalFlags.join("")}`,
|
||||
commandLineArgs: ["-w", ...additionalFlags],
|
||||
sys: () => sys({ excludeFiles: ["node_modules/*"] }),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Change foo",
|
||||
change: sys => sys.replaceFileText(`/user/username/projects/myproject/node_modules/bar/foo.d.ts`, "foo", "fooBar"),
|
||||
edit: sys => sys.replaceFileText(`/user/username/projects/myproject/node_modules/bar/foo.d.ts`, "foo", "fooBar"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(0),
|
||||
}
|
||||
]
|
||||
@@ -531,10 +526,10 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
subScenario: `watchOptions/with excludeDirectories option${additionalFlags.join("")}`,
|
||||
commandLineArgs: ["-w", ...additionalFlags],
|
||||
sys: () => sys({ excludeDirectories: ["node_modules"] }),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "delete fooBar",
|
||||
change: sys => sys.deleteFile(`/user/username/projects/myproject/node_modules/bar/fooBar.d.ts`),
|
||||
edit: sys => sys.deleteFile(`/user/username/projects/myproject/node_modules/bar/fooBar.d.ts`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(0), }
|
||||
]
|
||||
});
|
||||
@@ -544,10 +539,10 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
subScenario: `watchOptions/with excludeDirectories option with recursive directory watching${additionalFlags.join("")}`,
|
||||
commandLineArgs: ["-w", ...additionalFlags],
|
||||
sys: () => sys({ excludeDirectories: ["**/temp"] }, /*runWithoutRecursiveWatches*/ true),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Directory watch updates because of main.js creation",
|
||||
change: ts.noop,
|
||||
edit: ts.noop,
|
||||
timeouts: sys => {
|
||||
sys.checkTimeoutQueueLengthAndRun(1); // To update directory callbacks for main.js output
|
||||
sys.checkTimeoutQueueLength(0);
|
||||
@@ -555,7 +550,7 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
},
|
||||
{
|
||||
caption: "add new folder to temp",
|
||||
change: sys => sys.ensureFileOrFolder({ path: `/user/username/projects/myproject/node_modules/bar/temp/fooBar/index.d.ts`, content: "export function temp(): string;" }),
|
||||
edit: sys => sys.ensureFileOrFolder({ path: `/user/username/projects/myproject/node_modules/bar/temp/fooBar/index.d.ts`, content: "export function temp(): string;" }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(0),
|
||||
}
|
||||
]
|
||||
@@ -583,12 +578,12 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
},
|
||||
{ currentDirectory: "/user/username/projects/myproject", }
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Introduce error such that when callback happens file is already appeared",
|
||||
// vm's wq generates this kind of event
|
||||
// Skip delete event so inode changes but when the create's rename occurs file is on disk
|
||||
change: sys => sys.modifyFile(`/user/username/projects/myproject/foo.ts`, `export declare function foo2(): string;`, {
|
||||
edit: sys => sys.modifyFile(`/user/username/projects/myproject/foo.ts`, `export declare function foo2(): string;`, {
|
||||
invokeFileDeleteCreateAsPartInsteadOfChange: true,
|
||||
ignoreDelete: true,
|
||||
}),
|
||||
@@ -596,7 +591,7 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
},
|
||||
{
|
||||
caption: "Replace file with rename event that fixes error",
|
||||
change: sys => sys.modifyFile(`/user/username/projects/myproject/foo.ts`, `export declare function foo(): string;`, { invokeFileDeleteCreateAsPartInsteadOfChange: true, }),
|
||||
edit: sys => sys.modifyFile(`/user/username/projects/myproject/foo.ts`, `export declare function foo(): string;`, { invokeFileDeleteCreateAsPartInsteadOfChange: true, }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
]
|
||||
@@ -619,15 +614,15 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
inodeWatching: true
|
||||
}
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Replace file with rename event that introduces error",
|
||||
change: sys => sys.modifyFile(`/user/username/projects/myproject/foo.d.ts`, `export function foo2(): string;`, { invokeFileDeleteCreateAsPartInsteadOfChange: true }),
|
||||
edit: sys => sys.modifyFile(`/user/username/projects/myproject/foo.d.ts`, `export function foo2(): string;`, { invokeFileDeleteCreateAsPartInsteadOfChange: true }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2),
|
||||
},
|
||||
{
|
||||
caption: "Replace file with rename event that fixes error",
|
||||
change: sys => sys.modifyFile(`/user/username/projects/myproject/foo.d.ts`, `export function foo(): string;`, { invokeFileDeleteCreateAsPartInsteadOfChange: true }),
|
||||
edit: sys => sys.modifyFile(`/user/username/projects/myproject/foo.d.ts`, `export function foo(): string;`, { invokeFileDeleteCreateAsPartInsteadOfChange: true }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2),
|
||||
},
|
||||
]
|
||||
@@ -649,15 +644,15 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
inodeWatching: true
|
||||
}
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Replace file with rename event that introduces error",
|
||||
change: sys => sys.modifyFile(`/user/username/projects/myproject/foo.d.ts`, `export function foo2(): string;`, { invokeFileDeleteCreateAsPartInsteadOfChange: true, useTildeAsSuffixInRenameEventFileName: true }),
|
||||
edit: sys => sys.modifyFile(`/user/username/projects/myproject/foo.d.ts`, `export function foo2(): string;`, { invokeFileDeleteCreateAsPartInsteadOfChange: true, useTildeAsSuffixInRenameEventFileName: true }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2),
|
||||
},
|
||||
{
|
||||
caption: "Replace file with rename event that fixes error",
|
||||
change: sys => sys.modifyFile(`/user/username/projects/myproject/foo.d.ts`, `export function foo(): string;`, { invokeFileDeleteCreateAsPartInsteadOfChange: true, useTildeAsSuffixInRenameEventFileName: true }),
|
||||
edit: sys => sys.modifyFile(`/user/username/projects/myproject/foo.d.ts`, `export function foo(): string;`, { invokeFileDeleteCreateAsPartInsteadOfChange: true, useTildeAsSuffixInRenameEventFileName: true }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2),
|
||||
},
|
||||
]
|
||||
@@ -682,12 +677,12 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
inodeWatching: true,
|
||||
}
|
||||
),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "Introduce error such that when callback happens file is already appeared",
|
||||
// vm's wq generates this kind of event
|
||||
// Skip delete event so inode changes but when the create's rename occurs file is on disk
|
||||
change: sys => sys.modifyFile(`/user/username/projects/myproject/foo.ts`, `export declare function foo2(): string;`, {
|
||||
edit: sys => sys.modifyFile(`/user/username/projects/myproject/foo.ts`, `export declare function foo2(): string;`, {
|
||||
invokeFileDeleteCreateAsPartInsteadOfChange: true,
|
||||
ignoreDelete: true,
|
||||
skipInodeCheckOnCreate: true
|
||||
@@ -696,7 +691,7 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
},
|
||||
{
|
||||
caption: "Replace file with rename event that fixes error",
|
||||
change: sys => sys.modifyFile(`/user/username/projects/myproject/foo.ts`, `export declare function foo(): string;`, { invokeFileDeleteCreateAsPartInsteadOfChange: true, }),
|
||||
edit: sys => sys.modifyFile(`/user/username/projects/myproject/foo.ts`, `export declare function foo(): string;`, { invokeFileDeleteCreateAsPartInsteadOfChange: true, }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
]
|
||||
@@ -711,25 +706,25 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
|
||||
"/user/username/projects/project/main.ts": `let a: string = "Hello"`,
|
||||
[libFile.path]: libFile.content,
|
||||
}, { currentDirectory: "/user/username/projects/project" }),
|
||||
changes: [
|
||||
edits: [
|
||||
{
|
||||
caption: "change main.ts",
|
||||
change: sys => sys.replaceFileText("/user/username/projects/project/main.ts", "Hello", "Hello World"),
|
||||
edit: sys => sys.replaceFileText("/user/username/projects/project/main.ts", "Hello", "Hello World"),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "receive another change event without modifying the file",
|
||||
change: sys => sys.invokeFsWatches("/user/username/projects/project/main.ts", "change", /*modifiedTime*/ undefined, /*useTildeSuffix*/ undefined),
|
||||
edit: sys => sys.invokeFsWatches("/user/username/projects/project/main.ts", "change", /*modifiedTime*/ undefined, /*useTildeSuffix*/ undefined),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "change main.ts to empty text",
|
||||
change: sys => sys.writeFile("/user/username/projects/project/main.ts", ""),
|
||||
edit: sys => sys.writeFile("/user/username/projects/project/main.ts", ""),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "receive another change event without modifying the file",
|
||||
change: sys => sys.invokeFsWatches("/user/username/projects/project/main.ts", "change", /*modifiedTime*/ undefined, /*useTildeSuffix*/ undefined),
|
||||
edit: sys => sys.invokeFsWatches("/user/username/projects/project/main.ts", "change", /*modifiedTime*/ undefined, /*useTildeSuffix*/ undefined),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user