Skip to content

Commit 97d9404

Browse files
author
David Ungar
committed
make tempDir constant
1 parent 32eeb97 commit 97d9404

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Tests/SwiftDriverTests/IncrementalCompilationTests.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ final class NonincrementalCompilationTests: XCTestCase {
289289

290290
final class IncrementalCompilationTests: XCTestCase {
291291

292-
var tempDir: AbsolutePath = AbsolutePath("/tmp")
292+
let tempDir: AbsolutePath
293293

294294
let module = "theModule"
295295
var OFM: AbsolutePath {
@@ -336,17 +336,19 @@ final class IncrementalCompilationTests: XCTestCase {
336336
]
337337
+ inputPathsAndContents.map {$0.0.pathString} .sorted()
338338
}
339+
340+
override init(selector: Selector) {
341+
// Prefix directory with test name to ensure directory name is unique when
342+
// testing in parallel.
343+
self.tempDir = try! withTemporaryDirectory(prefix: selector.description, removeTreeOnDeinit: false) {$0}
344+
super.init(selector: selector)
345+
}
346+
339347
deinit {
340348
try? localFileSystem.removeFileTree(tempDir)
341349
}
342350

343351
override func setUp() {
344-
// Prefix directory with test name to ensure directory name is unique when
345-
// testing in parallel.
346-
// name returns e.g. "[SwiftDriverTests.IncrementalCompilationTests testIncremental]
347-
// but we just want "testIncremental"
348-
let testName = name.split(separator: " ").last!.dropLast()
349-
self.tempDir = try! withTemporaryDirectory(prefix: String(testName), removeTreeOnDeinit: false) {$0}
350352
try! localFileSystem.createDirectory(derivedDataPath)
351353
writeOutputFileMapData(module: module,
352354
inputPaths: inputPathsAndContents.map {$0.0},

0 commit comments

Comments
 (0)