@@ -205,6 +205,20 @@ private func checkCachingBuildJobDependencies(job: Job,
205
205
206
206
207
207
final class CachingBuildTests : XCTestCase {
208
+ override func setUpWithError( ) throws {
209
+ try super. setUpWithError ( )
210
+
211
+ // If the toolchain doesn't support caching, skip directly.
212
+ let driver = try Driver ( args: [ " swiftc " , " -v " ] )
213
+ #if os(Windows)
214
+ throw XCTSkip ( " caching not supported on windows " )
215
+ #else
216
+ guard driver. isFeatureSupported ( . cache_compile_job) else {
217
+ throw XCTSkip ( " caching not supported " )
218
+ }
219
+ #endif
220
+ }
221
+
208
222
private func pathMatchesSwiftModule( path: VirtualPath , _ name: String ) -> Bool {
209
223
return path. basenameWithoutExt. starts ( with: " \( name) - " ) &&
210
224
path. extension! == FileType . swiftModule. rawValue
@@ -234,9 +248,6 @@ final class CachingBuildTests: XCTestCase {
234
248
" -cache-compile-job " , " -cas-path " , casPath. nativePathString ( escaped: true ) ,
235
249
" -import-objc-header " , bridgingHeaderpath. nativePathString ( escaped: true ) ,
236
250
main. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting)
237
- guard driver. isFeatureSupported ( . cache_compile_job) else {
238
- throw XCTSkip ( " toolchain does not support caching. " )
239
- }
240
251
241
252
let jobs = try driver. planBuild ( )
242
253
let dependencyGraph = try driver. gatherModuleDependencies ( )
@@ -361,9 +372,6 @@ final class CachingBuildTests: XCTestCase {
361
372
guard driver. supportExplicitModuleVerifyInterface ( ) else {
362
373
throw XCTSkip ( " -typecheck-module-from-interface doesn't support explicit build. " )
363
374
}
364
- guard driver. isFeatureSupported ( . cache_compile_job) else {
365
- throw XCTSkip ( " toolchain does not support caching. " )
366
- }
367
375
368
376
let jobs = try driver. planBuild ( )
369
377
// Figure out which Triples to use.
@@ -492,9 +500,6 @@ final class CachingBuildTests: XCTestCase {
492
500
" -working-directory " , path. nativePathString ( escaped: true ) ,
493
501
main. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting,
494
502
env: ProcessEnv . vars)
495
- guard driver. isFeatureSupported ( . cache_compile_job) else {
496
- throw XCTSkip ( " toolchain does not support caching. " )
497
- }
498
503
let jobs = try driver. planBuild ( )
499
504
try driver. run ( jobs: jobs)
500
505
XCTAssertFalse ( driver. diagnosticEngine. hasErrors)
@@ -553,10 +558,6 @@ final class CachingBuildTests: XCTestCase {
553
558
+ sdkArgumentsForTesting,
554
559
env: ProcessEnv . vars)
555
560
556
- // Ensure this tooling supports this functionality
557
- guard fooBuildDriver. isFeatureSupported ( . cache_compile_job) else {
558
- throw XCTSkip ( " toolchain does not support caching. " )
559
- }
560
561
let dependencyOracle = InterModuleDependencyOracle ( )
561
562
let scanLibPath = try XCTUnwrap ( fooBuildDriver. toolchain. lookupSwiftScanLib ( ) )
562
563
guard try dependencyOracle
@@ -623,9 +624,6 @@ final class CachingBuildTests: XCTestCase {
623
624
" -disable-clang-target " ,
624
625
main. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting,
625
626
env: ProcessEnv . vars)
626
- guard driver. isFeatureSupported ( . cache_compile_job) else {
627
- throw XCTSkip ( " toolchain does not support caching. " )
628
- }
629
627
let dependencyOracle = InterModuleDependencyOracle ( )
630
628
let scanLibPath = try XCTUnwrap ( driver. toolchain. lookupSwiftScanLib ( ) )
631
629
guard try dependencyOracle
@@ -763,9 +761,6 @@ final class CachingBuildTests: XCTestCase {
763
761
" -scanner-prefix-map " , path. description + " =/^tmp " ,
764
762
main. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting,
765
763
env: ProcessEnv . vars)
766
- guard driver. isFeatureSupported ( . cache_compile_job) else {
767
- throw XCTSkip ( " toolchain does not support caching. " )
768
- }
769
764
guard driver. isFrontendArgSupported ( . scannerPrefixMap) else {
770
765
throw XCTSkip ( " frontend doesn't support prefix map " )
771
766
}
@@ -836,9 +831,6 @@ final class CachingBuildTests: XCTestCase {
836
831
" -working-directory " , path. nativePathString ( escaped: true ) ,
837
832
main. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting,
838
833
env: ProcessEnv . vars)
839
- guard driver. isFeatureSupported ( . cache_compile_job) else {
840
- throw XCTSkip ( " toolchain does not support caching. " )
841
- }
842
834
let jobs = try driver. planBuild ( )
843
835
try driver. run ( jobs: jobs)
844
836
XCTAssertFalse ( driver. diagnosticEngine. hasErrors)
0 commit comments