@@ -19,10 +19,7 @@ import TestUtilities
19
19
20
20
// MARK: - Instance variables and initialization
21
21
final class IncrementalCompilationTests : XCTestCase {
22
-
23
22
var tempDir : AbsolutePath = try ! AbsolutePath ( validating: " /tmp " )
24
- var explicitModuleCacheDir : AbsolutePath = try ! AbsolutePath ( validating: " /tmp/ModuleCache " )
25
-
26
23
var derivedDataDir : AbsolutePath {
27
24
tempDir. appending ( component: " derivedData " )
28
25
}
@@ -77,6 +74,28 @@ final class IncrementalCompilationTests: XCTestCase {
77
74
]
78
75
+ inputPathsAndContents. map { $0. 0 . nativePathString ( escaped: true ) } . sorted ( )
79
76
}
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
+
80
99
var explicitBuildArgs : [ String ] {
81
100
[ " -explicit-module-build " ,
82
101
" -module-cache-path " , explicitModuleCacheDir. nativePathString ( escaped: true ) ,
@@ -90,15 +109,38 @@ final class IncrementalCompilationTests: XCTestCase {
90
109
91
110
override func setUp( ) {
92
111
self . tempDir = try ! withTemporaryDirectory ( removeTreeOnDeinit: false ) { $0}
93
- self . explicitModuleCacheDir = tempDir . appending ( component : " ModuleCache " )
112
+ try ! localFileSystem . createDirectory ( explicitModuleCacheDir )
94
113
try ! localFileSystem. createDirectory ( derivedDataPath)
114
+ try ! localFileSystem. createDirectory ( explicitDependencyTestInputsPath)
115
+ try ! localFileSystem. createDirectory ( explicitCDependenciesPath)
116
+ try ! localFileSystem. createDirectory ( explicitSwiftDependenciesPath)
95
117
OutputFileMapCreator . write ( module: module,
96
118
inputPaths: inputPathsAndContents. map { $0. 0 } ,
97
119
derivedData: derivedDataPath,
98
120
to: OFM)
99
121
for (base, contents) in baseNamesAndContents {
100
122
write ( contents, to: base)
101
123
}
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
+
102
144
let driver = try ! Driver ( args: [ " swiftc " , " -v " ] )
103
145
if driver. isFrontendArgSupported ( . moduleLoadMode) {
104
146
self . extraExplicitBuildArgs = [ " -Xfrontend " , " -module-load-mode " , " -Xfrontend " , " prefer-interface " ]
@@ -260,23 +302,6 @@ fileprivate extension Driver {
260
302
261
303
// MARK: - Explicit Module Build incremental tests
262
304
extension 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
-
280
305
func testExplicitIncrementalSimpleBuild( ) throws {
281
306
try buildInitialState ( explicitModuleBuild: true )
282
307
try checkNullBuild ( explicitModuleBuild: true )
0 commit comments