Skip to content

Commit 730a52b

Browse files
committed
Better format for the exit code test
1 parent cd34808 commit 730a52b

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

src/testRunner/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
"unittests/tsbuild/demo.ts",
100100
"unittests/tsbuild/emitDeclarationOnly.ts",
101101
"unittests/tsbuild/emptyFiles.ts",
102+
"unittests/tsbuild/exitCodeOnBogusFile.ts",
102103
"unittests/tsbuild/graphOrdering.ts",
103104
"unittests/tsbuild/inferredTypeFromTransitiveModule.ts",
104105
"unittests/tsbuild/javascriptProjectEmit.ts",

src/testRunner/unittests/tsbuild/demo.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,17 @@ namespace ts {
3939

4040
interface VerifyBuild {
4141
modifyDiskLayout: (fs: vfs.FileSystem) => void;
42-
tsconfigs?: readonly string[];
4342
expectedExitStatus: ExitStatus;
4443
expectedDiagnostics: (fs: vfs.FileSystem) => fakes.ExpectedDiagnostic[];
4544
expectedOutputs: readonly string[];
4645
notExpectedOutputs: readonly string[];
4746
}
4847

49-
function verifyBuild({ modifyDiskLayout, tsconfigs = ["/src/tsconfig.json"],
50-
expectedExitStatus, expectedDiagnostics, expectedOutputs, notExpectedOutputs }: VerifyBuild) {
48+
function verifyBuild({ modifyDiskLayout, expectedExitStatus, expectedDiagnostics, expectedOutputs, notExpectedOutputs }: VerifyBuild) {
5149
const fs = projFs.shadow();
5250
const host = fakes.SolutionBuilderHost.create(fs);
5351
modifyDiskLayout(fs);
54-
const builder = createSolutionBuilder(host, tsconfigs, { verbose: true });
52+
const builder = createSolutionBuilder(host, ["/src/tsconfig.json"], { verbose: true });
5553
const exitStatus = builder.build();
5654
assert.equal(exitStatus, expectedExitStatus);
5755
host.assertDiagnosticMessages(...expectedDiagnostics(fs));
@@ -158,19 +156,5 @@ namespace ts {
158156
notExpectedOutputs: [...coreOutputs(), ...animalOutputs(), ...zooOutputs()]
159157
});
160158
});
161-
162-
it("returns an error exit in case of a bogus file", () => {
163-
verifyBuild({
164-
modifyDiskLayout: noop,
165-
tsconfigs: ["bogus.json"],
166-
expectedExitStatus: ExitStatus.DiagnosticsPresent_OutputsSkipped,
167-
expectedDiagnostics: _ => [
168-
getExpectedDiagnosticForProjectsInBuild("bogus.json"),
169-
errorDiagnostic([Diagnostics.File_0_not_found, "/bogus.json"]),
170-
],
171-
expectedOutputs: emptyArray,
172-
notExpectedOutputs: [...coreOutputs(), ...animalOutputs(), ...zooOutputs()]
173-
});
174-
});
175159
});
176160
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace ts {
2+
// https://github.com/microsoft/TypeScript/issues/33849
3+
describe("unittests:: tsbuild:: exitCodeOnBogusFile:: test exit code", () => {
4+
verifyTsc({
5+
scenario: "exitCodeOnBogusFile",
6+
subScenario: `test exit code`,
7+
fs: () => loadProjectFromFiles({}, symbolLibContent),
8+
commandLineArgs: ["-b", "bogus.json"]
9+
});
10+
});
11+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//// [/lib/initial-buildOutput.txt]
2+
/lib/tsc -b bogus.json
3+
error TS6053: File '/bogus.json' not found.
4+
exitCode:: 1
5+
6+

0 commit comments

Comments
 (0)