From a1737ce71306458949c2afcc0c88d1c166b6ff2e Mon Sep 17 00:00:00 2001 From: David Ungar Date: Tue, 17 Nov 2020 14:25:01 -0800 Subject: [PATCH 1/5] Ensure temp dir is different between testIncremental and testIncrementalDiagnostics to see if that fixes the test breakage in CI --- Tests/SwiftDriverTests/IncrementalCompilationTests.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Tests/SwiftDriverTests/IncrementalCompilationTests.swift b/Tests/SwiftDriverTests/IncrementalCompilationTests.swift index 4c0525a4c..a8f6db4fc 100644 --- a/Tests/SwiftDriverTests/IncrementalCompilationTests.swift +++ b/Tests/SwiftDriverTests/IncrementalCompilationTests.swift @@ -340,8 +340,9 @@ final class IncrementalCompilationTests: XCTestCase { try? localFileSystem.removeFileTree(tempDir) } - override func setUp() { - self.tempDir = try! withTemporaryDirectory(removeTreeOnDeinit: false) {$0} + func prepare(line: Int = #line) { + // ensure tempDir is unique by using line prefix + self.tempDir = try! withTemporaryDirectory(prefix: line.description, removeTreeOnDeinit: false) {$0} try! localFileSystem.createDirectory(derivedDataPath) writeOutputFileMapData(module: module, inputPaths: inputPathsAndContents.map {$0.0}, @@ -358,11 +359,13 @@ final class IncrementalCompilationTests: XCTestCase { // FIXME: why does it fail on Linux in CI? func testIncrementalDiagnostics() throws { #if !os(Linux) + prepare() try testIncremental(checkDiagnostics: true) #endif } func testIncremental() throws { + prepare() try testIncremental(checkDiagnostics: false) } @@ -553,6 +556,7 @@ final class IncrementalCompilationTests: XCTestCase { /// autolink job. /// Much of the code below is taking from testLinking(), but uses the output file map code here. func testAutolinkOutputPath() { + prepare() var env = ProcessEnv.vars env["SWIFT_DRIVER_TESTS_ENABLE_EXEC_PATH_FALLBACK"] = "1" env["SWIFT_DRIVER_SWIFT_AUTOLINK_EXTRACT_EXEC"] = "/garbage/swift-autolink-extract" From 7356075764883dfc58d56431f407c4889af509aa Mon Sep 17 00:00:00 2001 From: David Ungar Date: Tue, 17 Nov 2020 14:28:30 -0800 Subject: [PATCH 2/5] reenable the test --- Tests/SwiftDriverTests/IncrementalCompilationTests.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Tests/SwiftDriverTests/IncrementalCompilationTests.swift b/Tests/SwiftDriverTests/IncrementalCompilationTests.swift index a8f6db4fc..616c9be68 100644 --- a/Tests/SwiftDriverTests/IncrementalCompilationTests.swift +++ b/Tests/SwiftDriverTests/IncrementalCompilationTests.swift @@ -358,10 +358,8 @@ final class IncrementalCompilationTests: XCTestCase { // FIXME: why does it fail on Linux in CI? func testIncrementalDiagnostics() throws { - #if !os(Linux) prepare() try testIncremental(checkDiagnostics: true) - #endif } func testIncremental() throws { From 32eeb97625cdc4a36681245cab92ec9dfbdd0cea Mon Sep 17 00:00:00 2001 From: David Ungar Date: Tue, 17 Nov 2020 17:54:14 -0800 Subject: [PATCH 3/5] Address review --- .../IncrementalCompilationTests.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Tests/SwiftDriverTests/IncrementalCompilationTests.swift b/Tests/SwiftDriverTests/IncrementalCompilationTests.swift index 616c9be68..31965d2fe 100644 --- a/Tests/SwiftDriverTests/IncrementalCompilationTests.swift +++ b/Tests/SwiftDriverTests/IncrementalCompilationTests.swift @@ -340,9 +340,13 @@ final class IncrementalCompilationTests: XCTestCase { try? localFileSystem.removeFileTree(tempDir) } - func prepare(line: Int = #line) { - // ensure tempDir is unique by using line prefix - self.tempDir = try! withTemporaryDirectory(prefix: line.description, removeTreeOnDeinit: false) {$0} + override func setUp() { + // Prefix directory with test name to ensure directory name is unique when + // testing in parallel. + // name returns e.g. "[SwiftDriverTests.IncrementalCompilationTests testIncremental] + // but we just want "testIncremental" + let testName = name.split(separator: " ").last!.dropLast() + self.tempDir = try! withTemporaryDirectory(prefix: String(testName), removeTreeOnDeinit: false) {$0} try! localFileSystem.createDirectory(derivedDataPath) writeOutputFileMapData(module: module, inputPaths: inputPathsAndContents.map {$0.0}, @@ -356,14 +360,11 @@ final class IncrementalCompilationTests: XCTestCase { } } - // FIXME: why does it fail on Linux in CI? func testIncrementalDiagnostics() throws { - prepare() try testIncremental(checkDiagnostics: true) } func testIncremental() throws { - prepare() try testIncremental(checkDiagnostics: false) } @@ -554,7 +555,6 @@ final class IncrementalCompilationTests: XCTestCase { /// autolink job. /// Much of the code below is taking from testLinking(), but uses the output file map code here. func testAutolinkOutputPath() { - prepare() var env = ProcessEnv.vars env["SWIFT_DRIVER_TESTS_ENABLE_EXEC_PATH_FALLBACK"] = "1" env["SWIFT_DRIVER_SWIFT_AUTOLINK_EXTRACT_EXEC"] = "/garbage/swift-autolink-extract" From 97d94042d625734c9486d37d405bcced80c7e601 Mon Sep 17 00:00:00 2001 From: David Ungar Date: Tue, 17 Nov 2020 18:02:00 -0800 Subject: [PATCH 4/5] make tempDir constant --- .../IncrementalCompilationTests.swift | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Tests/SwiftDriverTests/IncrementalCompilationTests.swift b/Tests/SwiftDriverTests/IncrementalCompilationTests.swift index 31965d2fe..a3b61d46f 100644 --- a/Tests/SwiftDriverTests/IncrementalCompilationTests.swift +++ b/Tests/SwiftDriverTests/IncrementalCompilationTests.swift @@ -289,7 +289,7 @@ final class NonincrementalCompilationTests: XCTestCase { final class IncrementalCompilationTests: XCTestCase { - var tempDir: AbsolutePath = AbsolutePath("/tmp") + let tempDir: AbsolutePath let module = "theModule" var OFM: AbsolutePath { @@ -336,17 +336,19 @@ final class IncrementalCompilationTests: XCTestCase { ] + inputPathsAndContents.map {$0.0.pathString} .sorted() } + + override init(selector: Selector) { + // Prefix directory with test name to ensure directory name is unique when + // testing in parallel. + self.tempDir = try! withTemporaryDirectory(prefix: selector.description, removeTreeOnDeinit: false) {$0} + super.init(selector: selector) + } + deinit { try? localFileSystem.removeFileTree(tempDir) } override func setUp() { - // Prefix directory with test name to ensure directory name is unique when - // testing in parallel. - // name returns e.g. "[SwiftDriverTests.IncrementalCompilationTests testIncremental] - // but we just want "testIncremental" - let testName = name.split(separator: " ").last!.dropLast() - self.tempDir = try! withTemporaryDirectory(prefix: String(testName), removeTreeOnDeinit: false) {$0} try! localFileSystem.createDirectory(derivedDataPath) writeOutputFileMapData(module: module, inputPaths: inputPathsAndContents.map {$0.0}, From ce861eea8e9a9c3faa8b3f382b9cb18b78e3e52f Mon Sep 17 00:00:00 2001 From: David Ungar Date: Wed, 18 Nov 2020 10:04:45 -0800 Subject: [PATCH 5/5] Cannot intercept construction --- .../IncrementalCompilationTests.swift | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Tests/SwiftDriverTests/IncrementalCompilationTests.swift b/Tests/SwiftDriverTests/IncrementalCompilationTests.swift index a3b61d46f..31965d2fe 100644 --- a/Tests/SwiftDriverTests/IncrementalCompilationTests.swift +++ b/Tests/SwiftDriverTests/IncrementalCompilationTests.swift @@ -289,7 +289,7 @@ final class NonincrementalCompilationTests: XCTestCase { final class IncrementalCompilationTests: XCTestCase { - let tempDir: AbsolutePath + var tempDir: AbsolutePath = AbsolutePath("/tmp") let module = "theModule" var OFM: AbsolutePath { @@ -336,19 +336,17 @@ final class IncrementalCompilationTests: XCTestCase { ] + inputPathsAndContents.map {$0.0.pathString} .sorted() } - - override init(selector: Selector) { - // Prefix directory with test name to ensure directory name is unique when - // testing in parallel. - self.tempDir = try! withTemporaryDirectory(prefix: selector.description, removeTreeOnDeinit: false) {$0} - super.init(selector: selector) - } - deinit { try? localFileSystem.removeFileTree(tempDir) } override func setUp() { + // Prefix directory with test name to ensure directory name is unique when + // testing in parallel. + // name returns e.g. "[SwiftDriverTests.IncrementalCompilationTests testIncremental] + // but we just want "testIncremental" + let testName = name.split(separator: " ").last!.dropLast() + self.tempDir = try! withTemporaryDirectory(prefix: String(testName), removeTreeOnDeinit: false) {$0} try! localFileSystem.createDirectory(derivedDataPath) writeOutputFileMapData(module: module, inputPaths: inputPathsAndContents.map {$0.0},