Skip to content

Commit 9115c9d

Browse files
authored
Fix SwiftExecution tests (#820)
the catch block in SwiftPseudoterminal was catching the error thrown by the test setDimensions and wrongly causing the test to pass
1 parent b473625 commit 9115c9d

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

test/fixtures.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class TestSwiftProcess implements SwiftProcess {
3838
number | void
3939
>();
4040

41+
isSpawned: boolean = false;
4142
private error?: Error;
4243

4344
constructor(
@@ -50,18 +51,28 @@ export class TestSwiftProcess implements SwiftProcess {
5051
}
5152

5253
spawn(): void {
54+
this.isSpawned = true;
5355
if (this.error) {
5456
this.errorEmitter.fire(this.error);
5557
} else {
5658
this.spawnEmitter.fire();
5759
}
5860
}
5961

60-
write(line: string): void {
61-
this.writeEmitter.fire(`${line}\n`);
62+
write(line: string, delimiter: string = "\n"): void {
63+
const output = `${line}${delimiter}`;
64+
if (!this.isSpawned) {
65+
this.onDidSpawn(() => this.writeEmitter.fire(output));
66+
return;
67+
}
68+
this.writeEmitter.fire(output);
6269
}
6370

6471
close(exitCode: number): void {
72+
if (!this.isSpawned) {
73+
this.onDidSpawn(() => this.closeEmitter.fire(exitCode));
74+
return;
75+
}
6576
this.closeEmitter.fire(exitCode);
6677
}
6778

@@ -76,12 +87,12 @@ export class TestSwiftProcess implements SwiftProcess {
7687

7788
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7889
handleInput(input: string): void {
79-
throw new Error("Method not implemented.");
90+
// Do nothing
8091
}
8192

8293
// eslint-disable-next-line @typescript-eslint/no-unused-vars
8394
setDimensions(dimensions: vscode.TerminalDimensions): void {
84-
throw new Error("Method not implemented.");
95+
// Do nothing
8596
}
8697
}
8798

test/utilities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export async function executeTaskAndWaitForResult(
4646
}
4747

4848
/**
49-
* Wait for the writeable ficture to write some output
49+
* Wait for the writeable fixture to write some output
5050
*
5151
* @param fixture {@link SwiftTaskFixture} or {@link SwiftTask}
5252
* @returns The string that was written
@@ -61,7 +61,7 @@ export async function waitForWrite(fixture: { onDidWrite: vscode.Event<string> }
6161
}
6262

6363
/**
64-
* Wait for the writeable ficture to write some output
64+
* Wait for the writeable fixture to write some output
6565
*
6666
* @param fixture {@link SwiftTaskFixture} or {@link SwiftTask}
6767
* @returns The string that was written

0 commit comments

Comments
 (0)