From 0481abf8de3b21ce8481e81291c3df1b430cb225 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 4 May 2022 11:35:39 -0700 Subject: [PATCH] Tests: don't try to compile un-executed code (#4874) This avoids compiling code which is not run as it makes assumptions about the environment. --- Tests/BasicsTests/CancellatorTests.swift | 28 ++++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Tests/BasicsTests/CancellatorTests.swift b/Tests/BasicsTests/CancellatorTests.swift index 7bc5698f826..2e228d07d4f 100644 --- a/Tests/BasicsTests/CancellatorTests.swift +++ b/Tests/BasicsTests/CancellatorTests.swift @@ -44,9 +44,7 @@ final class CancellatorTests: XCTestCase { } func testTSCProcess() throws { - #if !os(macOS) - try XCTSkipIf(true, "skipping on non-macOS, signal traps do not work well on docker") - #endif +#if os(macOS) try withTemporaryDirectory { temporaryDirectory in let scriptPath = temporaryDirectory.appending(component: "script") try localFileSystem.writeFileContents(scriptPath) { @@ -98,12 +96,13 @@ final class CancellatorTests: XCTestCase { XCTAssertNoDiagnostics(observability.diagnostics) } +#else + try XCTSkipIf(true, "skipping on non-macOS, signal traps do not work well on docker") +#endif } func testTSCProcessForceKill() throws { - #if !os(macOS) - try XCTSkipIf(true, "skipping on non-macOS, signal traps do not work well on docker") - #endif +#if os(macOS) try withTemporaryDirectory { temporaryDirectory in let scriptPath = temporaryDirectory.appending(component: "script") try localFileSystem.writeFileContents(scriptPath) { @@ -163,12 +162,13 @@ final class CancellatorTests: XCTestCase { XCTAssertNoDiagnostics(observability.diagnostics) } +#else + try XCTSkipIf(true, "skipping on non-macOS, signal traps do not work well on docker") +#endif } func testFoundationProcess() throws { - #if !os(macOS) - try XCTSkipIf(true, "skipping on non-macOS, signal traps do not work well on docker") - #endif +#if os(macOS) try withTemporaryDirectory { temporaryDirectory in let scriptPath = temporaryDirectory.appending(component: "script") try localFileSystem.writeFileContents(scriptPath) { @@ -224,12 +224,13 @@ final class CancellatorTests: XCTestCase { XCTAssertNoDiagnostics(observability.diagnostics) } +#else + try XCTSkipIf(true, "skipping on non-macOS, signal traps do not work well on docker") +#endif } func testFoundationProcessForceKill() throws { - #if !os(macOS) - try XCTSkipIf(true, "skipping on non-macOS, signal traps do not work well on docker") - #endif +#if os(macOS) try withTemporaryDirectory { temporaryDirectory in let scriptPath = temporaryDirectory.appending(component: "script") try localFileSystem.writeFileContents(scriptPath) { @@ -293,6 +294,9 @@ final class CancellatorTests: XCTestCase { XCTAssertNoDiagnostics(observability.diagnostics) } +#else + try XCTSkipIf(true, "skipping on non-macOS, signal traps do not work well on docker") +#endif } func testConcurrency() throws {