@@ -289,7 +289,7 @@ final class NonincrementalCompilationTests: XCTestCase {
289289
290290final 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