Skip to content

Commit

Permalink
Tests: don't try to compile un-executed code (swiftlang#4874)
Browse files Browse the repository at this point in the history
This avoids compiling code which is not run as it makes assumptions
about the environment.
  • Loading branch information
compnerd authored May 4, 2022
1 parent 8a02981 commit 0481abf
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions Tests/BasicsTests/CancellatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0481abf

Please sign in to comment.