Skip to content

Commit 255c622

Browse files
committed
tsc --b --clean tests
1 parent 93d68b3 commit 255c622

File tree

3 files changed

+162
-0
lines changed

3 files changed

+162
-0
lines changed

internal/execute/tscbuild_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,49 @@ func TestBuildCommandLine(t *testing.T) {
132132
}
133133
}
134134

135+
func TestBuildClean(t *testing.T) {
136+
t.Parallel()
137+
testCases := []*tscInput{
138+
{
139+
subScenario: "file name and output name clashing",
140+
files: FileMap{
141+
"/home/src/workspaces/solution/index.js": "",
142+
"/home/src/workspaces/solution/bar.ts": "",
143+
"/home/src/workspaces/solution/tsconfig.json": stringtestutil.Dedent(`
144+
{
145+
"compilerOptions": { "allowJs": true }
146+
}`),
147+
},
148+
cwd: "/home/src/workspaces/solution",
149+
commandLineArgs: []string{"--b", "--clean"},
150+
},
151+
{
152+
subScenario: "tsx with dts emit",
153+
files: FileMap{
154+
"/home/src/workspaces/solution/project/src/main.tsx": "export const x = 10;",
155+
"/home/src/workspaces/solution/project/tsconfig.json": stringtestutil.Dedent(`
156+
{
157+
"compilerOptions": { "declaration": true },
158+
"include": ["src/**/*.tsx", "src/**/*.ts"]
159+
}`),
160+
},
161+
cwd: "/home/src/workspaces/solution",
162+
commandLineArgs: []string{"--b", "project", "-v", "--explainFiles"},
163+
edits: []*tscEdit{
164+
noChange,
165+
{
166+
caption: "clean build",
167+
commandLineArgs: []string{"-b", "project", "--clean"},
168+
},
169+
},
170+
},
171+
}
172+
173+
for _, test := range testCases {
174+
test.run(t, "clean")
175+
}
176+
}
177+
135178
func getBuildCommandLineDifferentOptionsMap(optionName string) FileMap {
136179
return FileMap{
137180
"/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(fmt.Sprintf(`
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
currentDirectory::/home/src/workspaces/solution
2+
useCaseSensitiveFileNames::true
3+
Input::
4+
//// [/home/src/workspaces/solution/bar.ts] *new*
5+
6+
//// [/home/src/workspaces/solution/index.js] *new*
7+
8+
//// [/home/src/workspaces/solution/tsconfig.json] *new*
9+
{
10+
"compilerOptions": { "allowJs": true }
11+
}
12+
13+
tsgo --b --clean
14+
ExitStatus:: Success
15+
Output::
16+
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
currentDirectory::/home/src/workspaces/solution
2+
useCaseSensitiveFileNames::true
3+
Input::
4+
//// [/home/src/workspaces/solution/project/src/main.tsx] *new*
5+
export const x = 10;
6+
//// [/home/src/workspaces/solution/project/tsconfig.json] *new*
7+
{
8+
"compilerOptions": { "declaration": true },
9+
"include": ["src/**/*.tsx", "src/**/*.ts"]
10+
}
11+
12+
tsgo --b project -v --explainFiles
13+
ExitStatus:: Success
14+
Output::
15+
[HH:MM:SS AM] Projects in this build:
16+
* project/tsconfig.json
17+
18+
[HH:MM:SS AM] Project 'project/tsconfig.json' is out of date because output file 'project/tsconfig.tsbuildinfo' does not exist
19+
20+
[HH:MM:SS AM] Building project 'project/tsconfig.json'...
21+
22+
../../tslibs/TS/Lib/lib.d.ts
23+
Default library for target 'ES5'
24+
project/src/main.tsx
25+
Matched by include pattern 'src/**/*.tsx' in 'project/tsconfig.json'
26+
//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib*
27+
/// <reference no-default-lib="true"/>
28+
interface Boolean {}
29+
interface Function {}
30+
interface CallableFunction {}
31+
interface NewableFunction {}
32+
interface IArguments {}
33+
interface Number { toExponential: any; }
34+
interface Object {}
35+
interface RegExp {}
36+
interface String { charAt: any; }
37+
interface Array<T> { length: number; [n: number]: T; }
38+
interface ReadonlyArray<T> {}
39+
interface SymbolConstructor {
40+
(desc?: string | number): symbol;
41+
for(name: string): symbol;
42+
readonly toStringTag: symbol;
43+
}
44+
declare var Symbol: SymbolConstructor;
45+
interface Symbol {
46+
readonly [Symbol.toStringTag]: string;
47+
}
48+
declare const console: { log(msg: any): void; };
49+
//// [/home/src/workspaces/solution/project/src/main.d.ts] *new*
50+
export declare const x = 10;
51+
52+
//// [/home/src/workspaces/solution/project/src/main.js] *new*
53+
"use strict";
54+
Object.defineProperty(exports, "__esModule", { value: true });
55+
exports.x = void 0;
56+
exports.x = 10;
57+
58+
//// [/home/src/workspaces/solution/project/tsconfig.tsbuildinfo] *new*
59+
{"version":"FakeTSVersion","root":["./src/main.tsx"]}
60+
//// [/home/src/workspaces/solution/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new*
61+
{
62+
"version": "FakeTSVersion",
63+
"root": [
64+
{
65+
"files": [
66+
"./src/main.tsx"
67+
],
68+
"original": "./src/main.tsx"
69+
}
70+
],
71+
"size": 53
72+
}
73+
74+
project/tsconfig.json::
75+
SemanticDiagnostics::
76+
*refresh* /home/src/tslibs/TS/Lib/lib.d.ts
77+
*refresh* /home/src/workspaces/solution/project/src/main.tsx
78+
Signatures::
79+
(stored at emit) /home/src/workspaces/solution/project/src/main.tsx
80+
81+
82+
Edit [0]:: no change
83+
84+
tsgo --b project -v --explainFiles
85+
ExitStatus:: Success
86+
Output::
87+
[HH:MM:SS AM] Projects in this build:
88+
* project/tsconfig.json
89+
90+
[HH:MM:SS AM] Project 'project/tsconfig.json' is up to date because newest input 'project/src/main.tsx' is older than output 'project/src/main.js'
91+
92+
93+
94+
95+
Edit [1]:: clean build
96+
97+
tsgo -b project --clean
98+
ExitStatus:: Success
99+
Output::
100+
//// [/home/src/workspaces/solution/project/src/main.d.ts] *deleted*
101+
//// [/home/src/workspaces/solution/project/src/main.js] *deleted*
102+
//// [/home/src/workspaces/solution/project/tsconfig.tsbuildinfo] *deleted*
103+

0 commit comments

Comments
 (0)