From 22d86fc22d8da7943732626413b884c90f61bdc3 Mon Sep 17 00:00:00 2001 From: Mihaela Mihaljevic Date: Fri, 26 Jun 2026 11:23:08 +0200 Subject: [PATCH] Revert "fix(test): bound the xmllint subprocess in the XSTS differential (#325)" (#327) This reverts commit e99319b02c177c57a74f3bca476f6ed0668b9fb3. --- Tests/XSTSDifferentialTests.swift | 42 ------------------------------- 1 file changed, 42 deletions(-) diff --git a/Tests/XSTSDifferentialTests.swift b/Tests/XSTSDifferentialTests.swift index 0cefd66..47f29f4 100644 --- a/Tests/XSTSDifferentialTests.swift +++ b/Tests/XSTSDifferentialTests.swift @@ -100,11 +100,6 @@ struct XSTSDifferentialTests { process.standardError = pipe process.standardOutput = Pipe() do { try process.run() } catch { return nil } - // xmllint infinite-loops on a few pathological schemas (particlesZ012); - // an unbounded wait would block forever and leave the child as a zombie. - // Bound it, then skip the case (it cannot be compared against a hung - // reference) rather than hang the harness. - guard Self.boundedExit(process, seconds: 15) else { return nil } let data = pipe.fileHandleForReading.readDataToEndOfFile() process.waitUntilExit() let output = String(decoding: data, as: UTF8.self) @@ -113,43 +108,6 @@ struct XSTSDifferentialTests { #endif } - /// Waits for `process` to exit, but no longer than `seconds`. On timeout it - /// terminates the child and reaps it, returning false; returns true when the - /// process exited on its own. Single-threaded polling, so there is no shared - /// mutable state to race under strict concurrency. - private static func boundedExit(_ process: Process, seconds: Double) -> Bool { - let deadline = Date().addingTimeInterval(seconds) - while process.isRunning, Date() < deadline { - Thread.sleep(forTimeInterval: 0.02) - } - if process.isRunning { - process.terminate() - process.waitUntilExit() - return false - } - return true - } - - @Test("a hung subprocess is bounded and reaped, not waited out") - func test_boundedExitTerminatesHungProcess() throws { - #if !os(WASI) - let candidates = ["/bin/sleep", "/usr/bin/sleep"] - guard let sleepPath = candidates.first(where: { FileManager.default.isExecutableFile(atPath: $0) }) else { - return // no `sleep` on this platform; skip. - } - let sleeper = Process() - sleeper.executableURL = URL(fileURLWithPath: sleepPath) - sleeper.arguments = ["30"] - try sleeper.run() - let start = Date() - let exitedOnOwn = Self.boundedExit(sleeper, seconds: 1) - let elapsed = Date().timeIntervalSince(start) - #expect(!exitedOnOwn) // terminated at the deadline, did not finish - #expect(elapsed < 10) // bounded near 1s, not the full 30s - #expect(!sleeper.isRunning) // reaped, no zombie - #endif - } - private func xsdFiles(under directory: String) -> [String] { guard let enumerator = FileManager.default.enumerator(atPath: directory) else { return [] } var result: [String] = []