Skip to content

Commit

Permalink
Eliminate deprecated Process method calls.
Browse files Browse the repository at this point in the history
Fixes apple#84.
  • Loading branch information
natecook1000 committed Mar 31, 2020
1 parent 31799bc commit 0b8a819
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Sources/ArgumentParserTestHelpers/TestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,31 @@ extension XCTest {
let commandURL = debugURL.appendingPathComponent(commandName)
guard (try? commandURL.checkResourceIsReachable()) ?? false else {
XCTFail("No executable at '\(commandURL.standardizedFileURL.path)'.",
file: file, line: line);
file: file, line: line)
return
}

let process = Process()
process.launchPath = commandURL.path
if #available(macOS 10.13, *) {
process.executableURL = commandURL
} else {
process.launchPath = commandURL.path
}
process.arguments = arguments

let output = Pipe()
process.standardOutput = output
let error = Pipe()
process.standardError = error

process.launch()
if #available(macOS 10.13, *) {
guard (try? process.run()) != nil else {
XCTFail("Couldn't run command process.", file: file, line: line)
return
}
} else {
process.launch()
}
process.waitUntilExit()

let outputData = output.fileHandleForReading.readDataToEndOfFile()
Expand Down

0 comments on commit 0b8a819

Please sign in to comment.