@@ -205,6 +205,20 @@ private func checkCachingBuildJobDependencies(job: Job,
205205
206206
207207final 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+
208222 private func pathMatchesSwiftModule( path: VirtualPath , _ name: String ) -> Bool {
209223 return path. basenameWithoutExt. starts ( with: " \( name) - " ) &&
210224 path. extension! == FileType . swiftModule. rawValue
@@ -234,9 +248,6 @@ final class CachingBuildTests: XCTestCase {
234248 " -cache-compile-job " , " -cas-path " , casPath. nativePathString ( escaped: true ) ,
235249 " -import-objc-header " , bridgingHeaderpath. nativePathString ( escaped: true ) ,
236250 main. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting)
237- guard driver. isFeatureSupported ( . cache_compile_job) else {
238- throw XCTSkip ( " toolchain does not support caching. " )
239- }
240251
241252 let jobs = try driver. planBuild ( )
242253 let dependencyGraph = try driver. gatherModuleDependencies ( )
@@ -361,9 +372,6 @@ final class CachingBuildTests: XCTestCase {
361372 guard driver. supportExplicitModuleVerifyInterface ( ) else {
362373 throw XCTSkip ( " -typecheck-module-from-interface doesn't support explicit build. " )
363374 }
364- guard driver. isFeatureSupported ( . cache_compile_job) else {
365- throw XCTSkip ( " toolchain does not support caching. " )
366- }
367375
368376 let jobs = try driver. planBuild ( )
369377 // Figure out which Triples to use.
@@ -492,9 +500,6 @@ final class CachingBuildTests: XCTestCase {
492500 " -working-directory " , path. nativePathString ( escaped: true ) ,
493501 main. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting,
494502 env: ProcessEnv . vars)
495- guard driver. isFeatureSupported ( . cache_compile_job) else {
496- throw XCTSkip ( " toolchain does not support caching. " )
497- }
498503 let jobs = try driver. planBuild ( )
499504 try driver. run ( jobs: jobs)
500505 XCTAssertFalse ( driver. diagnosticEngine. hasErrors)
@@ -553,10 +558,6 @@ final class CachingBuildTests: XCTestCase {
553558 + sdkArgumentsForTesting,
554559 env: ProcessEnv . vars)
555560
556- // Ensure this tooling supports this functionality
557- guard fooBuildDriver. isFeatureSupported ( . cache_compile_job) else {
558- throw XCTSkip ( " toolchain does not support caching. " )
559- }
560561 let dependencyOracle = InterModuleDependencyOracle ( )
561562 let scanLibPath = try XCTUnwrap ( fooBuildDriver. toolchain. lookupSwiftScanLib ( ) )
562563 guard try dependencyOracle
@@ -623,9 +624,6 @@ final class CachingBuildTests: XCTestCase {
623624 " -disable-clang-target " ,
624625 main. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting,
625626 env: ProcessEnv . vars)
626- guard driver. isFeatureSupported ( . cache_compile_job) else {
627- throw XCTSkip ( " toolchain does not support caching. " )
628- }
629627 let dependencyOracle = InterModuleDependencyOracle ( )
630628 let scanLibPath = try XCTUnwrap ( driver. toolchain. lookupSwiftScanLib ( ) )
631629 guard try dependencyOracle
@@ -763,9 +761,6 @@ final class CachingBuildTests: XCTestCase {
763761 " -scanner-prefix-map " , path. description + " =/^tmp " ,
764762 main. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting,
765763 env: ProcessEnv . vars)
766- guard driver. isFeatureSupported ( . cache_compile_job) else {
767- throw XCTSkip ( " toolchain does not support caching. " )
768- }
769764 guard driver. isFrontendArgSupported ( . scannerPrefixMap) else {
770765 throw XCTSkip ( " frontend doesn't support prefix map " )
771766 }
@@ -836,9 +831,6 @@ final class CachingBuildTests: XCTestCase {
836831 " -working-directory " , path. nativePathString ( escaped: true ) ,
837832 main. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting,
838833 env: ProcessEnv . vars)
839- guard driver. isFeatureSupported ( . cache_compile_job) else {
840- throw XCTSkip ( " toolchain does not support caching. " )
841- }
842834 let jobs = try driver. planBuild ( )
843835 try driver. run ( jobs: jobs)
844836 XCTAssertFalse ( driver. diagnosticEngine. hasErrors)
0 commit comments