Skip to content

Commit a322bf7

Browse files
committed
skip signal tests on linux / docker
1 parent 91f2ab9 commit a322bf7

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

Sources/Basics/DispatchTimeInterval+Extensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ extension DispatchTimeInterval {
9696
#if os(Linux) || os(Windows) || os(Android) || os(OpenBSD)
9797
extension DispatchTime {
9898
public func distance(to: DispatchTime) -> DispatchTimeInterval {
99-
let duration = to.uptimeNanoseconds - self.uptimeNanoseconds
99+
let duration = to.uptimeNanoseconds.subtractingReportingOverflow(self.uptimeNanoseconds).partialValue
100100
return .nanoseconds(duration >= Int.max ? Int.max : Int(duration))
101101
}
102102
}

Tests/BasicsTests/CancellatorTests.swift

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ final class CancellatorTests: XCTestCase {
4242
}
4343

4444
func testProcess() throws {
45+
#if !os(macOS)
46+
try XCTSkipIf(true, "skipping on non-macOS, signal traps do not work well on docker")
47+
#endif
4548
try withTemporaryDirectory { temporaryDirectory in
4649
let scriptPath = temporaryDirectory.appending(component: "script")
4750
try localFileSystem.writeFileContents(scriptPath) {
@@ -59,10 +62,13 @@ final class CancellatorTests: XCTestCase {
5962

6063
// outputRedirection used to signal that the process SIGINT traps have been set up
6164
let startSemaphore = ProcessStartedSemaphore(term: "process started")
62-
let process = TSCBasic.Process(arguments: ["bash", scriptPath.pathString], outputRedirection: .stream(
63-
stdout: startSemaphore.handleOutput,
64-
stderr: startSemaphore.handleOutput
65-
))
65+
let process = TSCBasic.Process(
66+
arguments: ["bash", scriptPath.pathString],
67+
outputRedirection: .stream(
68+
stdout: startSemaphore.handleOutput,
69+
stderr: startSemaphore.handleOutput
70+
)
71+
)
6672

6773
let registrationKey = cancellator.register(process)
6874
XCTAssertNotNil(registrationKey)
@@ -93,6 +99,9 @@ final class CancellatorTests: XCTestCase {
9399
}
94100

95101
func testProcessForceKill() throws {
102+
#if !os(macOS)
103+
try XCTSkipIf(true, "skipping on non-macOS, signal traps do not work well on docker")
104+
#endif
96105
try withTemporaryDirectory { temporaryDirectory in
97106
let scriptPath = temporaryDirectory.appending(component: "script")
98107
try localFileSystem.writeFileContents(scriptPath) {
@@ -119,10 +128,13 @@ final class CancellatorTests: XCTestCase {
119128

120129
// outputRedirection used to signal that the process SIGINT traps have been set up
121130
let startSemaphore = ProcessStartedSemaphore(term: "trap installed")
122-
let process = TSCBasic.Process(arguments: ["bash", scriptPath.pathString], outputRedirection: .stream(
123-
stdout: startSemaphore.handleOutput,
124-
stderr: startSemaphore.handleOutput
125-
))
131+
let process = TSCBasic.Process(
132+
arguments: ["bash", scriptPath.pathString],
133+
outputRedirection: .stream(
134+
stdout: startSemaphore.handleOutput,
135+
stderr: startSemaphore.handleOutput
136+
)
137+
)
126138
let registrationKey = cancellator.register(process)
127139
XCTAssertNotNil(registrationKey)
128140

0 commit comments

Comments
 (0)