@@ -21,6 +21,17 @@ import { globalWorkspaceContextPromise } from "./extension.test";
2121import { Version } from "../../src/utilities/version" ;
2222import { SwiftExecution } from "../../src/tasks/SwiftExecution" ;
2323
24+ function assertContainsArg ( execution : SwiftExecution , arg : string ) {
25+ assert ( execution ?. args . find ( a => a === arg ) ) ;
26+ }
27+
28+ function assertNotContainsArg ( execution : SwiftExecution , arg : string ) {
29+ assert . equal (
30+ execution ?. args . find ( a => a . includes ( arg ) ) ,
31+ undefined
32+ ) ;
33+ }
34+
2435suite ( "WorkspaceContext Test Suite" , ( ) => {
2536 let workspaceContext : WorkspaceContext ;
2637 const packageFolder : vscode . Uri = testAssetUri ( "defaultPackage" ) ;
@@ -73,10 +84,10 @@ suite("WorkspaceContext Test Suite", () => {
7384 const execution = buildAllTask . execution ;
7485 assert . strictEqual ( buildAllTask . definition . type , "swift" ) ;
7586 assert . strictEqual ( buildAllTask . name , "Build All (defaultPackage)" ) ;
76- assert . strictEqual ( execution ?. args [ 0 ] , "build" ) ;
77- assert . strictEqual ( execution ?. args [ 1 ] , "--build-tests" ) ;
78- assert . strictEqual ( execution ?. args [ 2 ] , "-Xswiftc" ) ;
79- assert . strictEqual ( execution ?. args [ 3 ] , "-diagnostic-style=llvm" ) ;
87+ assertContainsArg ( execution , "build" ) ;
88+ assertContainsArg ( execution , "--build-tests" ) ;
89+ assertContainsArg ( execution , "-Xswiftc" ) ;
90+ assertContainsArg ( execution , "-diagnostic-style=llvm" ) ;
8091 assert . strictEqual ( buildAllTask . scope , folder . workspaceFolder ) ;
8192 } ) ;
8293
@@ -90,8 +101,9 @@ suite("WorkspaceContext Test Suite", () => {
90101 const execution = buildAllTask . execution ;
91102 assert . strictEqual ( buildAllTask . definition . type , "swift" ) ;
92103 assert . strictEqual ( buildAllTask . name , "Build All (defaultPackage)" ) ;
93- assert . strictEqual ( execution ?. args [ 0 ] , "build" ) ;
94- assert . strictEqual ( execution ?. args [ 1 ] , "--build-tests" ) ;
104+ assertContainsArg ( execution , "build" ) ;
105+ assertContainsArg ( execution , "--build-tests" ) ;
106+ assertNotContainsArg ( execution , "-diagnostic-style" ) ;
95107 assert . strictEqual ( buildAllTask . scope , folder . workspaceFolder ) ;
96108 } ) ;
97109
@@ -105,10 +117,10 @@ suite("WorkspaceContext Test Suite", () => {
105117 const execution = buildAllTask . execution ;
106118 assert . strictEqual ( buildAllTask . definition . type , "swift" ) ;
107119 assert . strictEqual ( buildAllTask . name , "Build All (defaultPackage)" ) ;
108- assert . strictEqual ( execution ?. args [ 0 ] , "build" ) ;
109- assert . strictEqual ( execution ?. args [ 1 ] , "--build-tests" ) ;
110- assert . strictEqual ( execution ?. args [ 2 ] , "-Xswiftc" ) ;
111- assert . strictEqual ( execution ?. args [ 3 ] , "-diagnostic-style=swift" ) ;
120+ assertContainsArg ( execution , "build" ) ;
121+ assertContainsArg ( execution , "--build-tests" ) ;
122+ assertContainsArg ( execution , "-Xswiftc" ) ;
123+ assertContainsArg ( execution , "-diagnostic-style=swift" ) ;
112124 assert . strictEqual ( buildAllTask . scope , folder . workspaceFolder ) ;
113125 } ) ;
114126
@@ -121,11 +133,7 @@ suite("WorkspaceContext Test Suite", () => {
121133 await swiftConfig . update ( "buildArguments" , [ "--sanitize=thread" ] ) ;
122134 const buildAllTask = createBuildAllTask ( folder ) ;
123135 const execution = buildAllTask . execution as SwiftExecution ;
124- assert . strictEqual ( execution ?. args [ 0 ] , "build" ) ;
125- assert . strictEqual ( execution ?. args [ 1 ] , "--build-tests" ) ;
126- assert . strictEqual ( execution ?. args [ 2 ] , "-Xswiftc" ) ;
127- assert . strictEqual ( execution ?. args [ 3 ] , "-diagnostic-style=llvm" ) ;
128- assert . strictEqual ( execution ?. args [ 4 ] , "--sanitize=thread" ) ;
136+ assertContainsArg ( execution , "--sanitize=thread" ) ;
129137 await swiftConfig . update ( "buildArguments" , [ ] ) ;
130138 } ) ;
131139
0 commit comments