@@ -21,7 +21,6 @@ import { testAssetUri } from "../../fixtures";
21
21
import { FolderContext } from "../../../src/FolderContext" ;
22
22
import { WorkspaceContext } from "../../../src/WorkspaceContext" ;
23
23
import { Commands } from "../../../src/commands" ;
24
- import { Workbench } from "../../../src/utilities/commands" ;
25
24
import { continueSession , waitForDebugAdapterRequest } from "../../utilities/debug" ;
26
25
import { activateExtensionForSuite , folderInRootWorkspace } from "../utilities/testutilities" ;
27
26
import { Version } from "../../../src/utilities/version" ;
@@ -42,51 +41,31 @@ suite("Build Commands @slow", function () {
42
41
// The description of this package is crashing on Windows with Swift 5.9.x and below
43
42
if (
44
43
process . platform === "win32" &&
45
- ctx . globalToolchain . swiftVersion . isLessThanOrEqual ( new Version ( 5 , 9 , 0 ) )
44
+ ctx . globalToolchain . swiftVersion . isLessThan ( new Version ( 5 , 10 , 0 ) )
46
45
) {
47
46
this . skip ( ) ;
48
47
}
48
+ // A breakpoint will have not effect on the Run command.
49
+ vscode . debug . addBreakpoints ( breakpoints ) ;
49
50
50
51
workspaceContext = ctx ;
51
52
await waitForNoRunningTasks ( ) ;
52
53
folderContext = await folderInRootWorkspace ( "defaultPackage" , workspaceContext ) ;
53
54
await workspaceContext . focusFolder ( folderContext ) ;
54
- await vscode . window . showTextDocument ( uri ) ;
55
- } ,
56
- async teardown ( ) {
57
- await vscode . commands . executeCommand ( Workbench . ACTION_CLOSEALLEDITORS ) ;
58
55
} ,
59
56
requiresDebugger : true ,
60
57
} ) ;
61
58
62
- test ( "Swift: Run Build" , async ( ) => {
63
- // A breakpoint will have not effect on the Run command.
64
- vscode . debug . addBreakpoints ( breakpoints ) ;
65
-
66
- const result = await vscode . commands . executeCommand ( Commands . RUN ) ;
67
- expect ( result ) . to . be . true ;
68
-
59
+ suiteTeardown ( async ( ) => {
69
60
vscode . debug . removeBreakpoints ( breakpoints ) ;
70
61
} ) ;
71
62
72
- test ( "Swift: Clean Build" , async ( ) => {
73
- let result = await vscode . commands . executeCommand ( Commands . RUN ) ;
74
- expect ( result ) . to . be . true ;
75
-
76
- const buildPath = path . join ( folderContext . folder . fsPath , ".build" ) ;
77
- const beforeItemCount = ( await fs . readdir ( buildPath ) ) . length ;
78
-
79
- result = await vscode . commands . executeCommand ( Commands . CLEAN_BUILD ) ;
63
+ test ( "Swift: Run Build" , async ( ) => {
64
+ const result = await vscode . commands . executeCommand ( Commands . RUN , "PackageExe" ) ;
80
65
expect ( result ) . to . be . true ;
81
-
82
- const afterItemCount = ( await fs . readdir ( buildPath ) ) . length ;
83
- // .build folder is going to be filled with built artifacts after Commands.RUN command
84
- // After executing the clean command the build directory is guranteed to have less entry.
85
- expect ( afterItemCount ) . to . be . lessThan ( beforeItemCount ) ;
86
66
} ) ;
87
67
88
68
test ( "Swift: Debug Build" , async ( ) => {
89
- vscode . debug . addBreakpoints ( breakpoints ) ;
90
69
// Promise used to indicate we hit the break point.
91
70
// NB: "stopped" is the exact command when debuggee has stopped due to break point,
92
71
// but "stackTrace" is the deterministic sync point we will use to make sure we can execute continue
@@ -96,12 +75,34 @@ suite("Build Commands @slow", function () {
96
75
"stackTrace"
97
76
) ;
98
77
99
- const result = vscode . commands . executeCommand ( Commands . DEBUG ) ;
100
- expect ( result ) . to . eventually . be . true ;
78
+ const resultPromise : Thenable < boolean > = vscode . commands . executeCommand (
79
+ Commands . DEBUG ,
80
+ "PackageExe"
81
+ ) ;
101
82
102
83
await bpPromise ;
103
- await continueSession ( ) ;
84
+ let succeeded = false ;
85
+ resultPromise . then ( s => ( succeeded = s ) ) ;
86
+ while ( ! succeeded ) {
87
+ await continueSession ( ) ;
88
+ await new Promise ( r => setTimeout ( r , 500 ) ) ;
89
+ }
90
+ await expect ( resultPromise ) . to . eventually . be . true ;
91
+ } ) ;
104
92
105
- vscode . debug . removeBreakpoints ( breakpoints ) ;
93
+ test ( "Swift: Clean Build" , async ( ) => {
94
+ let result = await vscode . commands . executeCommand ( Commands . RUN , "PackageExe" ) ;
95
+ expect ( result ) . to . be . true ;
96
+
97
+ const buildPath = path . join ( folderContext . folder . fsPath , ".build" ) ;
98
+ const beforeItemCount = ( await fs . readdir ( buildPath ) ) . length ;
99
+
100
+ result = await vscode . commands . executeCommand ( Commands . CLEAN_BUILD ) ;
101
+ expect ( result ) . to . be . true ;
102
+
103
+ const afterItemCount = ( await fs . readdir ( buildPath ) ) . length ;
104
+ // .build folder is going to be filled with built artifacts after Commands.RUN command
105
+ // After executing the clean command the build directory is guranteed to have less entry.
106
+ expect ( afterItemCount ) . to . be . lessThan ( beforeItemCount ) ;
106
107
} ) ;
107
108
} ) ;
0 commit comments