@@ -19,10 +19,7 @@ import TestUtilities
1919
2020// MARK: - Instance variables and initialization
2121final class IncrementalCompilationTests : XCTestCase {
22-
2322 var tempDir : AbsolutePath = try ! AbsolutePath ( validating: " /tmp " )
24- var explicitModuleCacheDir : AbsolutePath = try ! AbsolutePath ( validating: " /tmp/ModuleCache " )
25-
2623 var derivedDataDir : AbsolutePath {
2724 tempDir. appending ( component: " derivedData " )
2825 }
@@ -77,6 +74,28 @@ final class IncrementalCompilationTests: XCTestCase {
7774 ]
7875 + inputPathsAndContents. map { $0. 0 . nativePathString ( escaped: true ) } . sorted ( )
7976 }
77+
78+ var explicitModuleCacheDir : AbsolutePath {
79+ tempDir. appending ( component: " ModuleCache " )
80+ }
81+ var explicitDependencyTestInputsPath : AbsolutePath {
82+ tempDir. appending ( component: " ExplicitTestInputs " )
83+ }
84+ var explicitCDependenciesPath : AbsolutePath {
85+ explicitDependencyTestInputsPath. appending ( component: " CHeaders " )
86+ }
87+ var explicitSwiftDependenciesPath : AbsolutePath {
88+ explicitDependencyTestInputsPath. appending ( component: " Swift " )
89+ }
90+
91+ var explicitDependencyTestInputsSourcePath : AbsolutePath {
92+ var root : AbsolutePath = try ! AbsolutePath ( validating: #file)
93+ while root. basename != " Tests " {
94+ root = root. parentDirectory
95+ }
96+ return root. parentDirectory. appending ( component: " TestInputs " )
97+ }
98+
8099 var explicitBuildArgs : [ String ] {
81100 [ " -explicit-module-build " ,
82101 " -module-cache-path " , explicitModuleCacheDir. nativePathString ( escaped: true ) ,
@@ -90,15 +109,38 @@ final class IncrementalCompilationTests: XCTestCase {
90109
91110 override func setUp( ) {
92111 self . tempDir = try ! withTemporaryDirectory ( removeTreeOnDeinit: false ) { $0}
93- self . explicitModuleCacheDir = tempDir . appending ( component : " ModuleCache " )
112+ try ! localFileSystem . createDirectory ( explicitModuleCacheDir )
94113 try ! localFileSystem. createDirectory ( derivedDataPath)
114+ try ! localFileSystem. createDirectory ( explicitDependencyTestInputsPath)
115+ try ! localFileSystem. createDirectory ( explicitCDependenciesPath)
116+ try ! localFileSystem. createDirectory ( explicitSwiftDependenciesPath)
95117 OutputFileMapCreator . write ( module: module,
96118 inputPaths: inputPathsAndContents. map { $0. 0 } ,
97119 derivedData: derivedDataPath,
98120 to: OFM)
99121 for (base, contents) in baseNamesAndContents {
100122 write ( contents, to: base)
101123 }
124+
125+ // Set up a per-test copy of all the explicit build module input artifacts
126+ do {
127+ let ebmSwiftInputsSourcePath = explicitDependencyTestInputsSourcePath
128+ . appending ( component: " ExplicitModuleBuilds " ) . appending ( component: " Swift " )
129+ let ebmCInputsSourcePath = explicitDependencyTestInputsSourcePath
130+ . appending ( component: " ExplicitModuleBuilds " ) . appending ( component: " CHeaders " )
131+ stdoutStream. flush ( )
132+ try ! localFileSystem. getDirectoryContents ( ebmSwiftInputsSourcePath) . forEach { filePath in
133+ let sourceFilePath = ebmSwiftInputsSourcePath. appending ( component: filePath)
134+ let destinationFilePath = explicitSwiftDependenciesPath. appending ( component: filePath)
135+ try ! localFileSystem. copy ( from: sourceFilePath, to: destinationFilePath)
136+ }
137+ try ! localFileSystem. getDirectoryContents ( ebmCInputsSourcePath) . forEach { filePath in
138+ let sourceFilePath = ebmCInputsSourcePath. appending ( component: filePath)
139+ let destinationFilePath = explicitCDependenciesPath. appending ( component: filePath)
140+ try ! localFileSystem. copy ( from: sourceFilePath, to: destinationFilePath)
141+ }
142+ }
143+
102144 let driver = try ! Driver ( args: [ " swiftc " , " -v " ] )
103145 if driver. isFrontendArgSupported ( . moduleLoadMode) {
104146 self . extraExplicitBuildArgs = [ " -Xfrontend " , " -module-load-mode " , " -Xfrontend " , " prefer-interface " ]
@@ -260,23 +302,6 @@ fileprivate extension Driver {
260302
261303// MARK: - Explicit Module Build incremental tests
262304extension IncrementalCompilationTests {
263- private var testExplicitDependencyInputsPath : AbsolutePath {
264- var root : AbsolutePath = try ! AbsolutePath ( validating: #file)
265- while root. basename != " Tests " {
266- root = root. parentDirectory
267- }
268- return root. parentDirectory. appending ( component: " TestInputs " )
269- }
270-
271- private var explicitCDependenciesPath : AbsolutePath {
272- testExplicitDependencyInputsPath. appending ( component: " ExplicitModuleBuilds " )
273- . appending ( component: " CHeaders " )
274- }
275- private var explicitSwiftDependenciesPath : AbsolutePath {
276- testExplicitDependencyInputsPath. appending ( component: " ExplicitModuleBuilds " )
277- . appending ( component: " Swift " )
278- }
279-
280305 func testExplicitIncrementalSimpleBuild( ) throws {
281306 try buildInitialState ( explicitModuleBuild: true )
282307 try checkNullBuild ( explicitModuleBuild: true )
0 commit comments