thebrowsercompany / swift-webdriver

A Swift library for communicating with WebDriver (Appium/WinAppDriver) endpoints
BSD 3-Clause "New" or "Revised" License
105 stars 3 forks source link

Use CreateProcessW directly when starting WinAppDriver to avoid CI hangs #48

Closed tristanlabelle closed 1 year ago

tristanlabelle commented 1 year ago

Foundation.Process uses CreateProcessW with bInheritHandles = true, which has the side effect of making swift test wait until both the test process AND WinAppDriver.exe exit before returning. If the test process crashes, this is problematic because WinAppDriver.exe will run amok with no one to terminate it, so swift test will wait forever.

Illustrating the issue: run swift test on this and see it never return until closing msinfo32.exe.

import Foundation
import XCTest

class Tests: XCTestCase {
    func testFoo() throws {
        let process = Process()
        process.executableURL = URL(fileURLWithPath: #"C:\windows\system32\msinfo32.exe"#)
        try process.run()
    }
}
jeffdav commented 1 year ago

Done in https://github.com/thebrowsercompany/webdriver-swift/commit/a029de866ac3ae73c549b8bb1bdb3af73c1bb44a