Skip to content

Commit

Permalink
Baseline showing #41801 and other issues with output path calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Dec 4, 2020
1 parent 387b6dc commit ff03ed0
Show file tree
Hide file tree
Showing 7 changed files with 577 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/testRunner/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"unittests/tsbuild/moduleSpecifiers.ts",
"unittests/tsbuild/noEmitOnError.ts",
"unittests/tsbuild/outFile.ts",
"unittests/tsbuild/outputPaths.ts",
"unittests/tsbuild/referencesWithRootDirInParent.ts",
"unittests/tsbuild/resolveJsonModule.ts",
"unittests/tsbuild/sample.ts",
Expand Down
95 changes: 95 additions & 0 deletions src/testRunner/unittests/tsbuild/outputPaths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
namespace ts {
describe("unittests:: tsbuild - output file paths", () => {
const incrementalScenarios: TscIncremental[] = [
noChangeRun,
{
buildKind: BuildKind.NoChangeRun,
modifyFs: noop,
subScenario: "Normal build without change, that does not block emit on error to show files that get emitted",
commandLineArgs: ["-p", "/src/tsconfig.json"],
}
];

verifyTscSerializedIncrementalEdits({
scenario: "outputPaths",
subScenario: "when rootDir is not specified",
fs: () => loadProjectFromFiles({
"/src/src/index.ts": "export const x = 10;",
"/src/tsconfig.json": JSON.stringify({
compilerOptions: {
outDir: "dist"
}
})
}),
commandLineArgs: ["--b", "/src/tsconfig.json", "-v"],
incrementalScenarios,
});

verifyTscSerializedIncrementalEdits({
scenario: "outputPaths",
subScenario: "when rootDir is not specified and is composite",
fs: () => loadProjectFromFiles({
"/src/src/index.ts": "export const x = 10;",
"/src/tsconfig.json": JSON.stringify({
compilerOptions: {
outDir: "dist",
composite: true
}
})
}),
commandLineArgs: ["--b", "/src/tsconfig.json", "-v"],
incrementalScenarios,
});

verifyTscSerializedIncrementalEdits({
scenario: "outputPaths",
subScenario: "when rootDir is specified",
fs: () => loadProjectFromFiles({
"/src/src/index.ts": "export const x = 10;",
"/src/tsconfig.json": JSON.stringify({
compilerOptions: {
outDir: "dist",
rootDir: "src"
}
})
}),
commandLineArgs: ["--b", "/src/tsconfig.json", "-v"],
incrementalScenarios,
});

verifyTscSerializedIncrementalEdits({
scenario: "outputPaths",
subScenario: "when rootDir is specified but not all files belong to rootDir",
fs: () => loadProjectFromFiles({
"/src/src/index.ts": "export const x = 10;",
"/src/types/type.ts": "export type t = string;",
"/src/tsconfig.json": JSON.stringify({
compilerOptions: {
outDir: "dist",
rootDir: "src"
}
})
}),
commandLineArgs: ["--b", "/src/tsconfig.json", "-v"],
incrementalScenarios,
});

verifyTscSerializedIncrementalEdits({
scenario: "outputPaths",
subScenario: "when rootDir is specified but not all files belong to rootDir and is composite",
fs: () => loadProjectFromFiles({
"/src/src/index.ts": "export const x = 10;",
"/src/types/type.ts": "export type t = string;",
"/src/tsconfig.json": JSON.stringify({
compilerOptions: {
outDir: "dist",
rootDir: "src",
composite: true
}
})
}),
commandLineArgs: ["--b", "/src/tsconfig.json", "-v"],
incrementalScenarios,
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
Input::
//// [/lib/lib.d.ts]
/// <reference no-default-lib="true"/>
interface Boolean {}
interface Function {}
interface CallableFunction {}
interface NewableFunction {}
interface IArguments {}
interface Number { toExponential: any; }
interface Object {}
interface RegExp {}
interface String { charAt: any; }
interface Array<T> { length: number; [n: number]: T; }
interface ReadonlyArray<T> {}
declare const console: { log(msg: any): void; };

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

//// [/src/tsconfig.json]
{"compilerOptions":{"outDir":"dist","composite":true}}



Output::
/lib/tsc --b /src/tsconfig.json -v
[12:01:00 AM] Projects in this build:
* src/tsconfig.json

[12:01:00 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/src/index.js' does not exist

[12:01:00 AM] Building project '/src/tsconfig.json'...

exitCode:: ExitStatus.Success


//// [/src/dist/src/index.d.ts]
export declare const x = 10;


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


//// [/src/dist/tsconfig.tsbuildinfo]
{
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"affectsGlobalScope": true
},
"../src/index.ts": {
"version": "-10726455937-export const x = 10;",
"signature": "-6057683066-export declare const x = 10;\r\n",
"affectsGlobalScope": false
}
},
"options": {
"outDir": "./",
"composite": true,
"configFilePath": "../tsconfig.json"
},
"referencedMap": {},
"exportedModulesMap": {},
"semanticDiagnosticsPerFile": [
"../../lib/lib.d.ts",
"../src/index.ts"
]
},
"version": "FakeTSVersion"
}



Change:: no-change-run
Input::


Output::
/lib/tsc --b /src/tsconfig.json -v
[12:04:00 AM] Projects in this build:
* src/tsconfig.json

[12:04:00 AM] Project 'src/tsconfig.json' is up to date because newest input 'src/src/index.ts' is older than oldest output 'src/dist/src/index.js'

exitCode:: ExitStatus.Success




Change:: Normal build without change, that does not block emit on error to show files that get emitted
Input::


Output::
/lib/tsc -p /src/tsconfig.json
exitCode:: ExitStatus.Success


Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Input::
//// [/lib/lib.d.ts]
/// <reference no-default-lib="true"/>
interface Boolean {}
interface Function {}
interface CallableFunction {}
interface NewableFunction {}
interface IArguments {}
interface Number { toExponential: any; }
interface Object {}
interface RegExp {}
interface String { charAt: any; }
interface Array<T> { length: number; [n: number]: T; }
interface ReadonlyArray<T> {}
declare const console: { log(msg: any): void; };

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

//// [/src/tsconfig.json]
{"compilerOptions":{"outDir":"dist"}}



Output::
/lib/tsc --b /src/tsconfig.json -v
[12:01:00 AM] Projects in this build:
* src/tsconfig.json

[12:01:00 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/src/index.js' does not exist

[12:01:00 AM] Building project '/src/tsconfig.json'...

exitCode:: ExitStatus.Success


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




Change:: no-change-run
Input::


Output::
/lib/tsc --b /src/tsconfig.json -v
[12:04:00 AM] Projects in this build:
* src/tsconfig.json

[12:04:00 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/src/index.js' does not exist

[12:04:00 AM] Building project '/src/tsconfig.json'...

exitCode:: ExitStatus.Success


//// [/src/dist/index.js] file written with same contents


Change:: Normal build without change, that does not block emit on error to show files that get emitted
Input::


Output::
/lib/tsc -p /src/tsconfig.json
exitCode:: ExitStatus.Success


//// [/src/dist/index.js] file written with same contents
Loading

0 comments on commit ff03ed0

Please sign in to comment.