File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -729,7 +729,14 @@ export class TestRunner {
729
729
outputStream . write ( replaced ) ;
730
730
} ) ;
731
731
732
+ // If the test run is iterrupted by a cancellation request from VS Code, ensure the task is terminated.
733
+ const cancellationDisposable = this . testRun . token . onCancellationRequested ( ( ) => {
734
+ task . execution . terminate ( "SIGINT" ) ;
735
+ } ) ;
736
+
732
737
task . execution . onDidClose ( code => {
738
+ cancellationDisposable . dispose ( ) ;
739
+
733
740
// undefined or 0 are viewed as success
734
741
if ( ! code ) {
735
742
resolve ( ) ;
@@ -925,7 +932,6 @@ export class TestRunner {
925
932
return ;
926
933
}
927
934
928
- // add cancelation
929
935
const startSession = vscode . debug . onDidStartDebugSession ( session => {
930
936
if ( config . testType === TestLibrary . xctest ) {
931
937
this . testRun . testRunStarted ( ) ;
@@ -945,6 +951,7 @@ export class TestRunner {
945
951
}
946
952
) ;
947
953
954
+ // add cancellation
948
955
const cancellation = this . testRun . token . onCancellationRequested ( ( ) => {
949
956
this . workspaceContext . outputChannel . logDiagnostic (
950
957
"Test Debugging Cancelled" ,
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ export class SwiftExecution extends vscode.CustomExecution {
30
30
public readonly command : string ,
31
31
public readonly args : string [ ] ,
32
32
public readonly options : SwiftExecutionOptions ,
33
- swiftProcess : SwiftProcess = new SwiftPtyProcess ( command , args , options )
33
+ private readonly swiftProcess : SwiftProcess = new SwiftPtyProcess ( command , args , options )
34
34
) {
35
35
super ( async ( ) => {
36
36
return new SwiftPseudoterminal ( swiftProcess , options . presentation || { } ) ;
@@ -54,4 +54,11 @@ export class SwiftExecution extends vscode.CustomExecution {
54
54
* @see {@link SwiftProcess.onDidClose }
55
55
*/
56
56
onDidClose : vscode . Event < number | void > ;
57
+
58
+ /**
59
+ * Terminate the underlying executable.
60
+ */
61
+ terminate ( signal ?: NodeJS . Signals ) {
62
+ this . swiftProcess . terminate ( signal ) ;
63
+ }
57
64
}
You can’t perform that action at this time.
0 commit comments