@@ -37,6 +37,7 @@ import { TemporaryFolder } from "../utilities/tempFolder";
37
37
import { TestClass , runnableTag , upsertTestItem } from "./TestDiscovery" ;
38
38
import { TestCoverage } from "../coverage/LcovResults" ;
39
39
import { TestingDebugConfigurationFactory } from "../debugger/buildConfig" ;
40
+ import { SwiftExecution } from "../tasks/SwiftExecution" ;
40
41
41
42
/** Workspace Folder events */
42
43
export enum TestKind {
@@ -731,6 +732,25 @@ export class TestRunner {
731
732
const debugRuns = validBuildConfigs . map ( config => {
732
733
return ( ) =>
733
734
new Promise < void > ( ( resolve , reject ) => {
735
+ let buildFailed = false ;
736
+ const buildTask = vscode . tasks . onDidStartTask ( e => {
737
+ if ( e . execution . task . name === "Build All" ) {
738
+ const exec = e . execution . task . execution as SwiftExecution ;
739
+ const didCloseBuildTask = exec . onDidClose ( exitCode => {
740
+ if (
741
+ exitCode !== 0 &&
742
+ config . testType === TestLibrary . swiftTesting
743
+ ) {
744
+ buildFailed = true ;
745
+ this . swiftTestOutputParser . close ( ) ;
746
+ subscriptions . forEach ( sub => sub . dispose ( ) ) ;
747
+ }
748
+ } ) ;
749
+ subscriptions . push ( didCloseBuildTask ) ;
750
+ }
751
+ } ) ;
752
+ subscriptions . push ( buildTask ) ;
753
+
734
754
// add cancelation
735
755
const startSession = vscode . debug . onDidStartDebugSession ( session => {
736
756
if ( config . testType === TestLibrary . xctest ) {
@@ -762,14 +782,18 @@ export class TestRunner {
762
782
. startDebugging ( this . folderContext . workspaceFolder , config )
763
783
. then (
764
784
started => {
785
+ if ( buildFailed ) {
786
+ reject ( "Build Failed" ) ;
787
+ return ;
788
+ }
765
789
if ( started ) {
766
790
// show test results pane
767
791
vscode . commands . executeCommand (
768
792
"testing.showMostRecentOutput"
769
793
) ;
770
794
771
795
const terminateSession =
772
- vscode . debug . onDidTerminateDebugSession ( async ( ) => {
796
+ vscode . debug . onDidTerminateDebugSession ( ( ) => {
773
797
this . workspaceContext . outputChannel . logDiagnostic (
774
798
"Stop Test Debugging" ,
775
799
this . folderContext . name
0 commit comments