@@ -38,25 +38,7 @@ import { TestClass, runnableTag, upsertTestItem } from "./TestDiscovery";
38
38
import { TestCoverage } from "../coverage/LcovResults" ;
39
39
import { TestingDebugConfigurationFactory } from "../debugger/buildConfig" ;
40
40
import { SwiftExecution } from "../tasks/SwiftExecution" ;
41
-
42
- /** Workspace Folder events */
43
- export enum TestKind {
44
- // run tests serially
45
- standard = "Standard" ,
46
- // run tests in parallel
47
- parallel = "Parallel" ,
48
- // run tests and extract test coverage
49
- coverage = "Coverage" ,
50
- // run tests and extract test coverage
51
- debug = "Debug" ,
52
- }
53
-
54
- export enum RunProfileName {
55
- run = "Run Tests" ,
56
- runParallel = "Run Tests (Parallel)" ,
57
- coverage = "Test Coverage" ,
58
- debug = "Debug Tests" ,
59
- }
41
+ import { TestKind , isDebugging , isRelease } from "./TestKind" ;
60
42
61
43
export enum TestLibrary {
62
44
xctest = "XCTest" ,
@@ -248,7 +230,7 @@ export class TestRunner {
248
230
) {
249
231
this . testArgs = new TestRunArguments (
250
232
this . ensureRequestIncludesTests ( this . request ) ,
251
- testKind === TestKind . debug
233
+ isDebugging ( testKind )
252
234
) ;
253
235
this . testRun = new TestRunProxy ( request , controller , this . testArgs , folderContext ) ;
254
236
this . xcTestOutputParser =
@@ -291,9 +273,9 @@ export class TestRunner {
291
273
onCreateTestRun : vscode . EventEmitter < TestRunProxy >
292
274
) : vscode . TestRunProfile [ ] {
293
275
return [
294
- // Add non-debug profile
276
+ // Add non-debug profiles
295
277
controller . createRunProfile (
296
- RunProfileName . run ,
278
+ TestKind . standard ,
297
279
vscode . TestRunProfileKind . Run ,
298
280
async ( request , token ) => {
299
281
const runner = new TestRunner (
@@ -308,9 +290,8 @@ export class TestRunner {
308
290
true ,
309
291
runnableTag
310
292
) ,
311
- // Add non-debug profile
312
293
controller . createRunProfile (
313
- RunProfileName . runParallel ,
294
+ TestKind . parallel ,
314
295
vscode . TestRunProfileKind . Run ,
315
296
async ( request , token ) => {
316
297
const runner = new TestRunner (
@@ -325,9 +306,25 @@ export class TestRunner {
325
306
false ,
326
307
runnableTag
327
308
) ,
309
+ controller . createRunProfile (
310
+ TestKind . release ,
311
+ vscode . TestRunProfileKind . Run ,
312
+ async ( request , token ) => {
313
+ const runner = new TestRunner (
314
+ TestKind . release ,
315
+ request ,
316
+ folderContext ,
317
+ controller
318
+ ) ;
319
+ onCreateTestRun . fire ( runner . testRun ) ;
320
+ await runner . runHandler ( token ) ;
321
+ } ,
322
+ false ,
323
+ runnableTag
324
+ ) ,
328
325
// Add coverage profile
329
326
controller . createRunProfile (
330
- RunProfileName . coverage ,
327
+ TestKind . coverage ,
331
328
vscode . TestRunProfileKind . Coverage ,
332
329
async ( request , token ) => {
333
330
const runner = new TestRunner (
@@ -350,7 +347,7 @@ export class TestRunner {
350
347
) ,
351
348
// Add debug profile
352
349
controller . createRunProfile (
353
- RunProfileName . debug ,
350
+ TestKind . debug ,
354
351
vscode . TestRunProfileKind . Debug ,
355
352
async ( request , token ) => {
356
353
const runner = new TestRunner (
@@ -365,6 +362,22 @@ export class TestRunner {
365
362
false ,
366
363
runnableTag
367
364
) ,
365
+ controller . createRunProfile (
366
+ TestKind . debugRelease ,
367
+ vscode . TestRunProfileKind . Debug ,
368
+ async ( request , token ) => {
369
+ const runner = new TestRunner (
370
+ TestKind . debugRelease ,
371
+ request ,
372
+ folderContext ,
373
+ controller
374
+ ) ;
375
+ onCreateTestRun . fire ( runner . testRun ) ;
376
+ await runner . runHandler ( token ) ;
377
+ } ,
378
+ false ,
379
+ runnableTag
380
+ ) ,
368
381
] ;
369
382
}
370
383
@@ -377,7 +390,7 @@ export class TestRunner {
377
390
async runHandler ( token : vscode . CancellationToken ) {
378
391
const runState = new TestRunnerTestRunState ( this . testRun ) ;
379
392
try {
380
- if ( this . testKind === TestKind . debug ) {
393
+ if ( isDebugging ( this . testKind ) ) {
381
394
await this . debugSession ( token , runState ) ;
382
395
} else {
383
396
await this . runSession ( token , runState ) ;
@@ -549,7 +562,13 @@ export class TestRunner {
549
562
kindLabel = " In Parallel" ;
550
563
break ;
551
564
case TestKind . debug :
552
- kindLabel = "For Debugging" ;
565
+ kindLabel = " For Debugging" ;
566
+ break ;
567
+ case TestKind . release :
568
+ kindLabel = " in Release Mode" ;
569
+ break ;
570
+ case TestKind . debugRelease :
571
+ kindLabel = " For Debugging in Release Mode" ;
553
572
break ;
554
573
case TestKind . standard :
555
574
kindLabel = "" ;
@@ -662,6 +681,17 @@ export class TestRunner {
662
681
return ;
663
682
}
664
683
684
+ if ( isRelease ( this . testKind ) ) {
685
+ buildAllTask . definition . args = [
686
+ ...buildAllTask . definition . args ,
687
+ "-c" ,
688
+ "release" ,
689
+ "-Xswiftc" ,
690
+ "-enable-testing" ,
691
+ ] ;
692
+ buildAllTask . detail = `swift ${ buildAllTask . definition . args . join ( " " ) } ` ;
693
+ }
694
+
665
695
const subscriptions : vscode . Disposable [ ] = [ ] ;
666
696
let buildExitCode = 0 ;
667
697
const buildTask = vscode . tasks . onDidStartTask ( e => {
@@ -699,20 +729,21 @@ export class TestRunner {
699
729
const swiftTestBuildConfig = TestingDebugConfigurationFactory . swiftTestingConfig (
700
730
this . folderContext ,
701
731
fifoPipePath ,
702
- TestKind . debug ,
732
+ this . testKind ,
703
733
this . testArgs . swiftTestArgs ,
704
734
true
705
735
) ;
706
736
707
737
if ( swiftTestBuildConfig !== null ) {
708
- // output test build configuration
709
- if ( configuration . diagnostics ) {
710
- const configJSON = JSON . stringify ( swiftTestBuildConfig ) ;
711
- this . workspaceContext . outputChannel . logDiagnostic (
712
- `swift-testing Debug Config: ${ configJSON } ` ,
713
- this . folderContext . name
714
- ) ;
715
- }
738
+ swiftTestBuildConfig . testType = TestLibrary . swiftTesting ;
739
+ swiftTestBuildConfig . preLaunchTask = null ;
740
+
741
+ // If we're testing in both frameworks we're going to start more than one debugging
742
+ // session. If both build configurations have the same name LLDB will replace the
743
+ // output of the first one in the Debug Console with the output of the second one.
744
+ // If they each have a unique name the Debug Console gets a nice dropdown the user
745
+ // can switch between to see the output for both sessions.
746
+ swiftTestBuildConfig . name = `Swift Testing: ${ swiftTestBuildConfig . name } ` ;
716
747
717
748
// output test build configuration
718
749
if ( configuration . diagnostics ) {
@@ -723,15 +754,6 @@ export class TestRunner {
723
754
) ;
724
755
}
725
756
726
- swiftTestBuildConfig . testType = TestLibrary . swiftTesting ;
727
- swiftTestBuildConfig . preLaunchTask = null ;
728
-
729
- // If we're testing in both frameworks we're going to start more than one debugging
730
- // session. If both build configurations have the same name LLDB will replace the
731
- // output of the first one in the Debug Console with the output of the second one.
732
- // If they each have a unique name the Debug Console gets a nice dropdown the user
733
- // can switch between to see the output for both sessions.
734
- swiftTestBuildConfig . name = `Swift Testing: ${ swiftTestBuildConfig . name } ` ;
735
757
buildConfigs . push ( swiftTestBuildConfig ) ;
736
758
}
737
759
}
@@ -740,12 +762,16 @@ export class TestRunner {
740
762
if ( this . testArgs . hasXCTests ) {
741
763
const xcTestBuildConfig = TestingDebugConfigurationFactory . xcTestConfig (
742
764
this . folderContext ,
743
- TestKind . debug ,
765
+ this . testKind ,
744
766
this . testArgs . xcTestArgs ,
745
767
true
746
768
) ;
747
769
748
770
if ( xcTestBuildConfig !== null ) {
771
+ xcTestBuildConfig . testType = TestLibrary . xctest ;
772
+ xcTestBuildConfig . preLaunchTask = null ;
773
+ xcTestBuildConfig . name = `XCTest: ${ xcTestBuildConfig . name } ` ;
774
+
749
775
// output test build configuration
750
776
if ( configuration . diagnostics ) {
751
777
const configJSON = JSON . stringify ( xcTestBuildConfig ) ;
@@ -755,9 +781,6 @@ export class TestRunner {
755
781
) ;
756
782
}
757
783
758
- xcTestBuildConfig . testType = TestLibrary . xctest ;
759
- xcTestBuildConfig . preLaunchTask = null ;
760
- xcTestBuildConfig . name = `XCTest: ${ xcTestBuildConfig . name } ` ;
761
784
buildConfigs . push ( xcTestBuildConfig ) ;
762
785
}
763
786
}
0 commit comments