Skip to content

Commit 680e9ea

Browse files
committed
skip signal tests on linux / docker
1 parent 133385d commit 680e9ea

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

Sources/Basics/Archiver+Zip.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,6 @@ public struct ZipArchiver: Archiver, Cancellable {
6262
} catch {
6363
return completion(.failure(error))
6464
}
65-
66-
/*
67-
Process.popen(arguments: ["unzip", archivePath.pathString, "-d", destinationPath.pathString], queue: .sharedConcurrent) { result in
68-
completion(result.tryMap { processResult in
69-
guard processResult.exitStatus == .terminated(code: 0) else {
70-
throw try StringError(processResult.utf8stderrOutput())
71-
}
72-
})
73-
}*/
7465
}
7566

7667
public func validate(path: AbsolutePath, completion: @escaping (Result<Bool, Error>) -> Void) {
@@ -95,13 +86,6 @@ public struct ZipArchiver: Archiver, Cancellable {
9586
} catch {
9687
return completion(.failure(error))
9788
}
98-
99-
/*
100-
Process.popen(arguments: ["unzip", "-t", path.pathString], queue: .sharedConcurrent) { result in
101-
completion(result.tryMap { processResult in
102-
return processResult.exitStatus == .terminated(code: 0)
103-
})
104-
}*/
10589
}
10690

10791
public func cancel(deadline: DispatchTime) throws {

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)