Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/TestExplorer/TestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,14 @@ export class TestRunner {
outputStream.write(replaced);
});

// If the test run is iterrupted by a cancellation request from VS Code, ensure the task is terminated.
const cancellationDisposable = this.testRun.token.onCancellationRequested(() => {
task.execution.terminate("SIGINT");
});

task.execution.onDidClose(code => {
cancellationDisposable.dispose();

// undefined or 0 are viewed as success
if (!code) {
resolve();
Expand Down Expand Up @@ -925,7 +932,6 @@ export class TestRunner {
return;
}

// add cancelation
const startSession = vscode.debug.onDidStartDebugSession(session => {
if (config.testType === TestLibrary.xctest) {
this.testRun.testRunStarted();
Expand All @@ -945,6 +951,7 @@ export class TestRunner {
}
);

// add cancellation
const cancellation = this.testRun.token.onCancellationRequested(() => {
this.workspaceContext.outputChannel.logDiagnostic(
"Test Debugging Cancelled",
Expand Down
9 changes: 8 additions & 1 deletion src/tasks/SwiftExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class SwiftExecution extends vscode.CustomExecution {
public readonly command: string,
public readonly args: string[],
public readonly options: SwiftExecutionOptions,
swiftProcess: SwiftProcess = new SwiftPtyProcess(command, args, options)
private readonly swiftProcess: SwiftProcess = new SwiftPtyProcess(command, args, options)
) {
super(async () => {
return new SwiftPseudoterminal(swiftProcess, options.presentation || {});
Expand All @@ -54,4 +54,11 @@ export class SwiftExecution extends vscode.CustomExecution {
* @see {@link SwiftProcess.onDidClose}
*/
onDidClose: vscode.Event<number | void>;

/**
* Terminate the underlying executable.
*/
terminate(signal?: NodeJS.Signals) {
this.swiftProcess.terminate(signal);
}
}