Use Subprocess instead of Shwift
Some checks failed
Docs / docs (push) Has been cancelled
Docs / deploy (push) Has been cancelled

Drop Shwift: it is incompatible with musl (used by the Swift static
linking SDK), and its API is not meaningfully more concise than
Subprocess upon closer inspection.
This commit is contained in:
T. R. Bernstein
2026-03-23 19:50:58 +01:00
parent 31ed16c828
commit 6927464d47
6 changed files with 64 additions and 42 deletions

View File

@@ -1,8 +1,9 @@
import ArgumentParser
import Foundation
import Script
import Noora
import Subprocess
struct TestCommand: Script {
struct TestCommand: AsyncParsableCommand {
static let configuration = CommandConfiguration(
commandName: "test",
abstract: "Run swift test in a linux container.",
@@ -17,12 +18,12 @@ struct TestCommand: Script {
let noora = Noora()
let logger = global.makeLogger(labeled: "swift-inotify.cli.task.test")
let currentDirectory = FileManager.default.currentDirectoryPath
let docker = try await executable(named: "docker")
noora.info("Running tests on Linux.")
logger.debug("Current directory", metadata: ["current-directory": "\(currentDirectory)"])
do {
try await docker(
let dockerRunResult = try await Subprocess.run(
.name("docker"),
arguments: [
"run",
"-v", "\(currentDirectory):/code",
"-v", "swift-inotify-build-cache:/code/.build",
@@ -30,9 +31,13 @@ struct TestCommand: Script {
"--platform", Docker.getLinuxPlatformStringWithHostArchitecture(),
"-w", "/code", "swift:latest",
"/bin/bash", "-c", "swift test --skip InotifyLimitTests; swift test --skip-build --filter InotifyLimitTests"
)
],
output: .standardOutput,
error: .standardError
)
if dockerRunResult.terminationStatus.isSuccess {
noora.success("All tests completed successfully.")
} catch {
} else {
noora.error("Not all tests completed successfully.")
}
}