@@ -89,14 +89,42 @@ export class TestingDebugConfigurationFactory {
8989
9090 switch ( process . platform ) {
9191 case "darwin" :
92- return this . buildDarwinConfg ( ) ;
92+ return this . buildDarwinConfig ( ) ;
93+ case "win32" :
94+ return this . buildWindowsConfig ( ) ;
9395 default :
94- return this . buildNonDarwinConfig ( ) ;
96+ return this . buildLinuxConfig ( ) ;
9597 }
9698 }
9799
98100 /* eslint-disable no-case-declarations */
99- private buildNonDarwinConfig ( ) : vscode . DebugConfiguration | null {
101+ private buildWindowsConfig ( ) : vscode . DebugConfiguration | null {
102+ if ( isDebugging ( this . testKind ) && this . testLibrary === TestLibrary . xctest ) {
103+ const testEnv = {
104+ ...swiftRuntimeEnv ( ) ,
105+ ...configuration . folder ( this . ctx . workspaceFolder ) . testEnvironmentVariables ,
106+ } ;
107+ // On Windows, add XCTest.dll to the Path
108+ // and run the .xctest executable from the .build directory.
109+ const runtimePath = this . ctx . workspaceContext . toolchain . runtimePath ;
110+ const xcTestPath = this . ctx . workspaceContext . toolchain . xcTestPath ;
111+ if ( xcTestPath && xcTestPath !== runtimePath ) {
112+ testEnv . Path = `${ xcTestPath } ;${ testEnv . Path ?? process . env . Path } ` ;
113+ }
114+
115+ return {
116+ ...this . baseConfig ,
117+ program : this . xcTestOutputPath ,
118+ args : this . testList ,
119+ env : testEnv ,
120+ } ;
121+ } else {
122+ return this . buildDarwinConfig ( ) ;
123+ }
124+ }
125+
126+ /* eslint-disable no-case-declarations */
127+ private buildLinuxConfig ( ) : vscode . DebugConfiguration | null {
100128 if ( isDebugging ( this . testKind ) && this . testLibrary === TestLibrary . xctest ) {
101129 return {
102130 ...this . baseConfig ,
@@ -108,11 +136,11 @@ export class TestingDebugConfigurationFactory {
108136 } ,
109137 } ;
110138 } else {
111- return this . buildDarwinConfg ( ) ;
139+ return this . buildDarwinConfig ( ) ;
112140 }
113141 }
114142
115- private buildDarwinConfg ( ) : vscode . DebugConfiguration | null {
143+ private buildDarwinConfig ( ) : vscode . DebugConfiguration | null {
116144 switch ( this . testLibrary ) {
117145 case TestLibrary . swiftTesting :
118146 switch ( this . testKind ) {
0 commit comments