Skip to content

Commit 4b13406

Browse files
committed
transitiveReferences as baseline
1 parent 25db0b0 commit 4b13406

File tree

4 files changed

+334
-53
lines changed

4 files changed

+334
-53
lines changed
Lines changed: 17 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,13 @@
11
namespace ts {
22
describe("unittests:: tsbuild:: when project reference is referenced transitively", () => {
33
let projFs: vfs.FileSystem;
4-
const allExpectedOutputs = [
5-
"/src/a.js", "/src/a.d.ts",
6-
"/src/b.js", "/src/b.d.ts",
7-
"/src/c.js"
8-
];
9-
const expectedFileTraces = [
10-
"/lib/lib.d.ts",
11-
"/src/a.ts",
12-
"/lib/lib.d.ts",
13-
"/src/a.d.ts",
14-
"/src/b.ts",
15-
"/lib/lib.d.ts",
16-
"/src/a.d.ts",
17-
"/src/b.d.ts",
18-
"/src/refs/a.d.ts",
19-
"/src/c.ts"
20-
];
214
before(() => {
225
projFs = loadProjectFromDisk("tests/projects/transitiveReferences");
236
});
247
after(() => {
258
projFs = undefined!; // Release the contents
269
});
2710

28-
function verifyBuild(modifyDiskLayout: (fs: vfs.FileSystem) => void, allExpectedOutputs: readonly string[], expectedFileTraces: readonly string[], ...expectedDiagnostics: fakes.ExpectedDiagnostic[]) {
29-
const fs = projFs.shadow();
30-
const host = fakes.SolutionBuilderHost.create(fs);
31-
modifyDiskLayout(fs);
32-
const builder = createSolutionBuilder(host, ["/src/tsconfig.c.json"], { listFiles: true });
33-
builder.build();
34-
host.assertDiagnosticMessages(...expectedDiagnostics);
35-
verifyOutputsPresent(fs, allExpectedOutputs);
36-
assert.deepEqual(host.traces, expectedFileTraces);
37-
}
38-
3911
function modifyFsBTsToNonRelativeImport(fs: vfs.FileSystem, moduleResolution: "node" | "classic") {
4012
fs.writeFileSync("/src/b.ts", `import {A} from 'a';
4113
export const b = new A();`);
@@ -49,35 +21,27 @@ export const b = new A();`);
4921
}));
5022
}
5123

52-
it("verify that it builds correctly", () => {
53-
verifyBuild(noop, allExpectedOutputs, expectedFileTraces);
24+
verifyTsc({
25+
scenario: "transitiveReferences",
26+
subScenario: "builds correctly",
27+
fs: () => projFs,
28+
commandLineArgs: ["--b", "/src/tsconfig.c.json", "--listFiles"],
5429
});
5530

56-
it("verify that it builds correctly when the referenced project uses different module resolution", () => {
57-
verifyBuild(fs => modifyFsBTsToNonRelativeImport(fs, "classic"), allExpectedOutputs, expectedFileTraces);
31+
verifyTsc({
32+
scenario: "transitiveReferences",
33+
subScenario: "builds correctly when the referenced project uses different module resolution",
34+
fs: () => projFs,
35+
commandLineArgs: ["--b", "/src/tsconfig.c.json", "--listFiles"],
36+
modifyFs: fs => modifyFsBTsToNonRelativeImport(fs, "classic"),
5837
});
5938

60-
it("verify that it build reports error about module not found with node resolution with external module name", () => {
61-
// Error in b build only a
62-
const allExpectedOutputs = ["/src/a.js", "/src/a.d.ts"];
63-
const expectedFileTraces = [
64-
"/lib/lib.d.ts",
65-
"/src/a.ts",
66-
"/lib/lib.d.ts",
67-
"/src/b.ts"
68-
];
69-
verifyBuild(fs => modifyFsBTsToNonRelativeImport(fs, "node"),
70-
allExpectedOutputs,
71-
expectedFileTraces,
72-
{
73-
message: [Diagnostics.Cannot_find_module_0, "a"],
74-
location: {
75-
file: "/src/b.ts",
76-
start: `import {A} from 'a';`.indexOf(`'a'`),
77-
length: `'a'`.length
78-
}
79-
},
80-
);
39+
verifyTsc({
40+
scenario: "transitiveReferences",
41+
subScenario: "reports error about module not found with node resolution with external module name",
42+
fs: () => projFs,
43+
commandLineArgs: ["--b", "/src/tsconfig.c.json", "--listFiles"],
44+
modifyFs: fs => modifyFsBTsToNonRelativeImport(fs, "node"),
8145
});
8246
});
8347
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
//// [/lib/initial-buildOutput.txt]
2+
/lib/tsc --b /src/tsconfig.c.json --listFiles
3+
/lib/lib.d.ts
4+
/src/a.ts
5+
/lib/lib.d.ts
6+
/src/a.d.ts
7+
/src/b.ts
8+
/lib/lib.d.ts
9+
/src/a.d.ts
10+
/src/b.d.ts
11+
/src/refs/a.d.ts
12+
/src/c.ts
13+
exitCode:: ExitStatus.Success
14+
15+
16+
//// [/src/a.d.ts]
17+
export declare class A {
18+
}
19+
20+
21+
//// [/src/a.js]
22+
"use strict";
23+
exports.__esModule = true;
24+
var A = /** @class */ (function () {
25+
function A() {
26+
}
27+
return A;
28+
}());
29+
exports.A = A;
30+
31+
32+
//// [/src/b.d.ts]
33+
import { A } from 'a';
34+
export declare const b: A;
35+
36+
37+
//// [/src/b.js]
38+
"use strict";
39+
exports.__esModule = true;
40+
var a_1 = require("a");
41+
exports.b = new a_1.A();
42+
43+
44+
//// [/src/b.ts]
45+
import {A} from 'a';
46+
export const b = new A();
47+
48+
//// [/src/c.js]
49+
"use strict";
50+
exports.__esModule = true;
51+
var b_1 = require("./b");
52+
var a_1 = require("@ref/a");
53+
b_1.b;
54+
a_1.X;
55+
56+
57+
//// [/src/tsconfig.a.tsbuildinfo]
58+
{
59+
"program": {
60+
"fileInfos": {
61+
"../lib/lib.d.ts": {
62+
"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; };",
63+
"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; };"
64+
},
65+
"./a.ts": {
66+
"version": "-8566332115-export class A {}\r\n",
67+
"signature": "-9529994156-export declare class A {\r\n}\r\n"
68+
}
69+
},
70+
"options": {
71+
"composite": true,
72+
"listFiles": true,
73+
"configFilePath": "./tsconfig.a.json"
74+
},
75+
"referencedMap": {},
76+
"exportedModulesMap": {},
77+
"semanticDiagnosticsPerFile": [
78+
"../lib/lib.d.ts",
79+
"./a.ts"
80+
]
81+
},
82+
"version": "FakeTSVersion"
83+
}
84+
85+
//// [/src/tsconfig.b.json]
86+
{"compilerOptions":{"composite":true,"moduleResolution":"classic"},"files":["b.ts"],"references":[{"path":"tsconfig.a.json"}]}
87+
88+
//// [/src/tsconfig.b.tsbuildinfo]
89+
{
90+
"program": {
91+
"fileInfos": {
92+
"../lib/lib.d.ts": {
93+
"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; };",
94+
"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; };"
95+
},
96+
"./a.ts": {
97+
"version": "-9529994156-export declare class A {\r\n}\r\n",
98+
"signature": "-9529994156-export declare class A {\r\n}\r\n"
99+
},
100+
"./b.ts": {
101+
"version": "-17186364832-import {A} from 'a';\nexport const b = new A();",
102+
"signature": "-9520743082-import { A } from 'a';\r\nexport declare const b: A;\r\n"
103+
}
104+
},
105+
"options": {
106+
"composite": true,
107+
"moduleResolution": 1,
108+
"listFiles": true,
109+
"configFilePath": "./tsconfig.b.json"
110+
},
111+
"referencedMap": {
112+
"./b.ts": [
113+
"./a.d.ts"
114+
]
115+
},
116+
"exportedModulesMap": {
117+
"./b.ts": [
118+
"./a.d.ts"
119+
]
120+
},
121+
"semanticDiagnosticsPerFile": [
122+
"../lib/lib.d.ts",
123+
"./a.ts",
124+
"./b.ts"
125+
]
126+
},
127+
"version": "FakeTSVersion"
128+
}
129+
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
//// [/lib/initial-buildOutput.txt]
2+
/lib/tsc --b /src/tsconfig.c.json --listFiles
3+
/lib/lib.d.ts
4+
/src/a.ts
5+
/lib/lib.d.ts
6+
/src/a.d.ts
7+
/src/b.ts
8+
/lib/lib.d.ts
9+
/src/a.d.ts
10+
/src/b.d.ts
11+
/src/refs/a.d.ts
12+
/src/c.ts
13+
exitCode:: ExitStatus.Success
14+
15+
16+
//// [/src/a.d.ts]
17+
export declare class A {
18+
}
19+
20+
21+
//// [/src/a.js]
22+
"use strict";
23+
exports.__esModule = true;
24+
var A = /** @class */ (function () {
25+
function A() {
26+
}
27+
return A;
28+
}());
29+
exports.A = A;
30+
31+
32+
//// [/src/b.d.ts]
33+
import { A } from '@ref/a';
34+
export declare const b: A;
35+
36+
37+
//// [/src/b.js]
38+
"use strict";
39+
exports.__esModule = true;
40+
var a_1 = require("@ref/a");
41+
exports.b = new a_1.A();
42+
43+
44+
//// [/src/c.js]
45+
"use strict";
46+
exports.__esModule = true;
47+
var b_1 = require("./b");
48+
var a_1 = require("@ref/a");
49+
b_1.b;
50+
a_1.X;
51+
52+
53+
//// [/src/tsconfig.a.tsbuildinfo]
54+
{
55+
"program": {
56+
"fileInfos": {
57+
"../lib/lib.d.ts": {
58+
"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; };",
59+
"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; };"
60+
},
61+
"./a.ts": {
62+
"version": "-8566332115-export class A {}\r\n",
63+
"signature": "-9529994156-export declare class A {\r\n}\r\n"
64+
}
65+
},
66+
"options": {
67+
"composite": true,
68+
"listFiles": true,
69+
"configFilePath": "./tsconfig.a.json"
70+
},
71+
"referencedMap": {},
72+
"exportedModulesMap": {},
73+
"semanticDiagnosticsPerFile": [
74+
"../lib/lib.d.ts",
75+
"./a.ts"
76+
]
77+
},
78+
"version": "FakeTSVersion"
79+
}
80+
81+
//// [/src/tsconfig.b.tsbuildinfo]
82+
{
83+
"program": {
84+
"fileInfos": {
85+
"../lib/lib.d.ts": {
86+
"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; };",
87+
"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; };"
88+
},
89+
"./a.ts": {
90+
"version": "-9529994156-export declare class A {\r\n}\r\n",
91+
"signature": "-9529994156-export declare class A {\r\n}\r\n"
92+
},
93+
"./b.ts": {
94+
"version": "-13104686224-import {A} from '@ref/a';\r\nexport const b = new A();\r\n",
95+
"signature": "-10067914302-import { A } from '@ref/a';\r\nexport declare const b: A;\r\n"
96+
}
97+
},
98+
"options": {
99+
"composite": true,
100+
"baseUrl": "./",
101+
"paths": {
102+
"@ref/*": [
103+
"./*"
104+
]
105+
},
106+
"listFiles": true,
107+
"configFilePath": "./tsconfig.b.json"
108+
},
109+
"referencedMap": {
110+
"./b.ts": [
111+
"./a.d.ts"
112+
]
113+
},
114+
"exportedModulesMap": {
115+
"./b.ts": [
116+
"./a.d.ts"
117+
]
118+
},
119+
"semanticDiagnosticsPerFile": [
120+
"../lib/lib.d.ts",
121+
"./a.ts",
122+
"./b.ts"
123+
]
124+
},
125+
"version": "FakeTSVersion"
126+
}
127+

0 commit comments

Comments
 (0)