@@ -186,13 +186,13 @@ export class SwiftTestingConfigurationSetup {
186
186
* and `xcTestConfig` functions to create
187
187
*/
188
188
export class TestingConfigurationFactory {
189
- public static async swiftTestingConfig (
189
+ public static swiftTestingConfig (
190
190
ctx : FolderContext ,
191
191
buildArguments : SwiftTestingBuildAguments ,
192
192
testKind : TestKind ,
193
193
testList : string [ ] ,
194
194
expandEnvVariables = false
195
- ) : Promise < vscode . DebugConfiguration | null > {
195
+ ) : vscode . DebugConfiguration | null {
196
196
return new TestingConfigurationFactory (
197
197
ctx ,
198
198
testKind ,
@@ -203,12 +203,12 @@ export class TestingConfigurationFactory {
203
203
) . build ( ) ;
204
204
}
205
205
206
- public static async xcTestConfig (
206
+ public static xcTestConfig (
207
207
ctx : FolderContext ,
208
208
testKind : TestKind ,
209
209
testList : string [ ] ,
210
210
expandEnvVariables = false
211
- ) : Promise < vscode . DebugConfiguration | null > {
211
+ ) : vscode . DebugConfiguration | null {
212
212
return new TestingConfigurationFactory (
213
213
ctx ,
214
214
testKind ,
@@ -219,11 +219,11 @@ export class TestingConfigurationFactory {
219
219
) . build ( ) ;
220
220
}
221
221
222
- public static async testExecutableOutputPath (
222
+ public static testExecutableOutputPath (
223
223
ctx : FolderContext ,
224
224
testKind : TestKind ,
225
225
testLibrary : TestLibrary
226
- ) : Promise < string > {
226
+ ) : string {
227
227
return new TestingConfigurationFactory (
228
228
ctx ,
229
229
testKind ,
@@ -251,7 +251,7 @@ export class TestingConfigurationFactory {
251
251
* - Test Kind (coverage, debugging)
252
252
* - Test Library (XCTest, swift-testing)
253
253
*/
254
- private async build ( ) : Promise < vscode . DebugConfiguration | null > {
254
+ private build ( ) : vscode . DebugConfiguration | null {
255
255
if ( ! this . hasTestTarget ) {
256
256
return null ;
257
257
}
@@ -267,7 +267,7 @@ export class TestingConfigurationFactory {
267
267
}
268
268
269
269
/* eslint-disable no-case-declarations */
270
- private async buildWindowsConfig ( ) : Promise < vscode . DebugConfiguration | null > {
270
+ private buildWindowsConfig ( ) : vscode . DebugConfiguration | null {
271
271
if ( isDebugging ( this . testKind ) ) {
272
272
const testEnv = {
273
273
...swiftRuntimeEnv ( ) ,
@@ -288,8 +288,8 @@ export class TestingConfigurationFactory {
288
288
289
289
return {
290
290
...this . baseConfig ,
291
- program : await this . testExecutableOutputPath ( ) ,
292
- args : await this . debuggingTestExecutableArgs ( ) ,
291
+ program : this . testExecutableOutputPath ( ) ,
292
+ args : this . debuggingTestExecutableArgs ( ) ,
293
293
env : testEnv ,
294
294
} ;
295
295
} else {
@@ -298,12 +298,12 @@ export class TestingConfigurationFactory {
298
298
}
299
299
300
300
/* eslint-disable no-case-declarations */
301
- private async buildLinuxConfig ( ) : Promise < vscode . DebugConfiguration | null > {
301
+ private buildLinuxConfig ( ) : vscode . DebugConfiguration | null {
302
302
if ( isDebugging ( this . testKind ) && this . testLibrary === TestLibrary . xctest ) {
303
303
return {
304
304
...this . baseConfig ,
305
- program : await this . testExecutableOutputPath ( ) ,
306
- args : await this . debuggingTestExecutableArgs ( ) ,
305
+ program : this . testExecutableOutputPath ( ) ,
306
+ args : this . debuggingTestExecutableArgs ( ) ,
307
307
env : {
308
308
...swiftRuntimeEnv (
309
309
process . env ,
@@ -313,11 +313,11 @@ export class TestingConfigurationFactory {
313
313
} ,
314
314
} ;
315
315
} else {
316
- return await this . buildDarwinConfig ( ) ;
316
+ return this . buildDarwinConfig ( ) ;
317
317
}
318
318
}
319
319
320
- private async buildDarwinConfig ( ) : Promise < vscode . DebugConfiguration | null > {
320
+ private buildDarwinConfig ( ) : vscode . DebugConfiguration | null {
321
321
switch ( this . testLibrary ) {
322
322
case TestLibrary . swiftTesting :
323
323
switch ( this . testKind ) {
@@ -362,8 +362,8 @@ export class TestingConfigurationFactory {
362
362
363
363
const result = {
364
364
...this . baseConfig ,
365
- program : await this . testExecutableOutputPath ( ) ,
366
- args : await this . debuggingTestExecutableArgs ( ) ,
365
+ program : this . testExecutableOutputPath ( ) ,
366
+ args : this . debuggingTestExecutableArgs ( ) ,
367
367
env : {
368
368
...this . testEnv ,
369
369
...this . sanitizerRuntimeEnvironment ,
@@ -631,45 +631,6 @@ export class TestingConfigurationFactory {
631
631
) ;
632
632
}
633
633
634
- private swiftTestingOutputPath ( ) : string {
635
- return path . join (
636
- this . buildDirectory ,
637
- this . artifactFolderForTestKind ,
638
- `${ this . ctx . swiftPackage . name } PackageTests.swift-testing`
639
- ) ;
640
- }
641
-
642
- private buildDescriptionPath ( ) : string {
643
- return path . join ( this . buildDirectory , this . artifactFolderForTestKind , "description.json" ) ;
644
- }
645
-
646
- private async isUnifiedTestingBinary ( ) : Promise < boolean > {
647
- // Toolchains that contain https://github.com/swiftlang/swift-package-manager/commit/844bd137070dcd18d0f46dd95885ef7907ea0697
648
- // no longer produce a .swift-testing binary, instead we want to use `unifiedTestingOutputPath`.
649
- // In order to determine if we're working with a unified binary we need to check if the .swift-testing
650
- // binary was produced by the latest build. If it was then we are not using a unified binary.
651
-
652
- // TODO: When Swift 6 is released and enough time has passed that we're sure no one is building the .swift-testing
653
- // binary anymore this workaround can be removed and `swiftTestingPath` can be returned, and the build config
654
- // generation can be made synchronous again.
655
-
656
- try {
657
- const buildDescriptionStr = await fs . readFile ( this . buildDescriptionPath ( ) , "utf-8" ) ;
658
- const buildDescription = JSON . parse ( buildDescriptionStr ) ;
659
- const testProducts = buildDescription . builtTestProducts as { binaryPath : string } [ ] ;
660
- if ( ! testProducts ) {
661
- return false ;
662
- }
663
- const testBinaryPaths = testProducts . map ( ( { binaryPath } ) => binaryPath ) ;
664
- const swiftTestingBinaryRealPath = await fs . realpath ( this . swiftTestingOutputPath ( ) ) ;
665
- return ! testBinaryPaths . includes ( swiftTestingBinaryRealPath ) ;
666
- } catch {
667
- // If the .swift-testing binary wasn't produced by the latest build then we assume the
668
- // swift-testing tests are in the unified binary.
669
- return true ;
670
- }
671
- }
672
-
673
634
private unifiedTestingOutputPath ( ) : string {
674
635
// The unified binary that contains both swift-testing and XCTests
675
636
// is named the same as the old style .xctest binary. The swiftpm-testing-helper
@@ -686,24 +647,19 @@ export class TestingConfigurationFactory {
686
647
}
687
648
}
688
649
689
- private async testExecutableOutputPath ( ) : Promise < string > {
650
+ private testExecutableOutputPath ( ) : string {
690
651
switch ( this . testLibrary ) {
691
652
case TestLibrary . swiftTesting :
692
- return ( await this . isUnifiedTestingBinary ( ) )
693
- ? this . unifiedTestingOutputPath ( )
694
- : this . swiftTestingOutputPath ( ) ;
653
+ return this . unifiedTestingOutputPath ( ) ;
695
654
case TestLibrary . xctest :
696
655
return this . xcTestOutputPath ( ) ;
697
656
}
698
657
}
699
658
700
- private async debuggingTestExecutableArgs ( ) : Promise < string [ ] > {
659
+ private debuggingTestExecutableArgs ( ) : string [ ] {
701
660
switch ( this . testLibrary ) {
702
661
case TestLibrary . swiftTesting : {
703
- const isUnifiedBinary = await this . isUnifiedTestingBinary ( ) ;
704
- const swiftTestingArgs = isUnifiedBinary
705
- ? [ "--testing-library" , "swift-testing" ]
706
- : [ ] ;
662
+ const swiftTestingArgs = [ "--testing-library" , "swift-testing" ] ;
707
663
708
664
return this . addBuildOptionsToArgs (
709
665
this . addTestsToArgs ( this . addSwiftTestingFlagsArgs ( swiftTestingArgs ) )
0 commit comments