@@ -53,7 +53,7 @@ struct PrepareHandlerTests {
53
53
sdkRootPaths: [ " iphonesimulator " : " bar " ]
54
54
)
55
55
56
- let expectedCommand = " bazel --output_base=/tmp/output_base build //HelloWorld --config=index "
56
+ let expectedCommand = " bazel --output_base=/tmp/output_base --preemptible build //HelloWorld --config=index "
57
57
commandRunner. setResponse ( for: expectedCommand, cwd: rootUri, response: " " )
58
58
59
59
let handler = PrepareHandler (
@@ -101,7 +101,7 @@ struct PrepareHandlerTests {
101
101
sdkRootPaths: [ " iphonesimulator " : " bar " ]
102
102
)
103
103
104
- let expectedCommand = " bazel --output_base=/tmp/output_base build //HelloWorld //HelloWorld2 --config=index "
104
+ let expectedCommand = " bazel --output_base=/tmp/output_base --preemptible build //HelloWorld //HelloWorld2 --config=index "
105
105
commandRunner. setResponse ( for: expectedCommand, response: " Build completed " )
106
106
107
107
let handler = PrepareHandler (
@@ -124,4 +124,55 @@ struct PrepareHandlerTests {
124
124
#expect( ranCommands [ 0 ] . command == expectedCommand)
125
125
#expect( ranCommands [ 0 ] . cwd == " /path/to/project " )
126
126
}
127
+
128
+ @Test
129
+ func skipsPreemptibleFlagIfUsingSeparateOutputBaseForAquery( ) throws {
130
+ let commandRunner = CommandRunnerFake ( )
131
+ let connection = LSPConnectionFake ( )
132
+
133
+ let rootUri = " /path/to/project "
134
+ let baseConfig = BaseServerConfig (
135
+ bazelWrapper: " bazel " ,
136
+ targets: [ " //HelloWorld " ] ,
137
+ indexFlags: [ " --config=index " ] ,
138
+ buildTestSuffix: " _(PLAT)_skbsp " ,
139
+ buildTestPlatformPlaceholder: " (PLAT) " ,
140
+ filesToWatch: nil ,
141
+ useSeparateOutputBaseForAquery: true
142
+ )
143
+
144
+ let initializedConfig = InitializedServerConfig (
145
+ baseConfig: baseConfig,
146
+ rootUri: rootUri,
147
+ outputBase: " /tmp/output_base " ,
148
+ outputPath: " /tmp/output_path " ,
149
+ devDir: " /Applications/Xcode.app/Contents/Developer " ,
150
+ devToolchainPath: " /a/b/XcodeDefault.xctoolchain/ " ,
151
+ executionRoot: " /tmp/output_path/execoot/_main " ,
152
+ sdkRootPaths: [ " iphonesimulator " : " bar " ]
153
+ )
154
+
155
+ let expectedCommand = " bazel --output_base=/tmp/output_base build //HelloWorld --config=index "
156
+ commandRunner. setResponse ( for: expectedCommand, cwd: rootUri, response: " " )
157
+
158
+ let handler = PrepareHandler (
159
+ initializedConfig: initializedConfig,
160
+ targetStore: BazelTargetStoreImpl ( initializedConfig: initializedConfig) ,
161
+ commandRunner: commandRunner,
162
+ connection: connection
163
+ )
164
+
165
+ let semaphore = DispatchSemaphore ( value: 0 )
166
+ try handler. build ( bazelLabels: baseConfig. targets, id: RequestID . number ( 1 ) ) { error in
167
+ #expect( error == nil )
168
+ semaphore. signal ( )
169
+ }
170
+
171
+ #expect( semaphore. wait ( timeout: . now( ) + 1 ) == . success)
172
+
173
+ let ranCommands = commandRunner. commands
174
+ #expect( ranCommands. count == 1 )
175
+ #expect( ranCommands [ 0 ] . command == expectedCommand)
176
+ #expect( ranCommands [ 0 ] . cwd == rootUri)
177
+ }
127
178
}
0 commit comments