Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465import Foundationimport Testing
@Suite("Remote runner routing", .serialized)struct RemoteRunnerTests { private var root: URL { URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent() .deletingLastPathComponent() }
@Test(arguments: [[], ["--help"], ["example.local", "--unknown"], ["example.local", "--e2e", "extra"]]) func rejectsInvalidArguments(_ arguments: [String]) throws { let process = Process() process.executableURL = URL(fileURLWithPath: "/bin/bash") process.arguments = [root.appendingPathComponent("Scripts/test-remote.sh").path] + arguments let output = Pipe() process.standardOutput = output process.standardError = output try process.run() process.waitUntilExit() #expect(process.terminationStatus == 2) let message = String(decoding: output.fileHandleForReading.readDataToEndOfFile(), as: UTF8.self) #expect(message.contains("[--e2e]")) }
@Test(arguments: [false, true]) func selectsTheRequestedRemoteRunner(_ e2e: Bool) throws { let directory = FileManager.default.temporaryDirectory.appendingPathComponent("parcel-remote-test-\(UUID())") try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: false) defer { do { try FileManager.default.removeItem(at: directory) } catch { Issue.record(error) } } let log = directory.appendingPathComponent("calls.log") let scripts = [ "git": "#!/bin/bash\nprintf 'AGENTS.md\\0'\n", "ssh": "#!/bin/bash\nprintf '%s\\n' \"$*\" >> \"$PARCEL_REMOTE_TEST_LOG\"\nif [[ $2 == *mktemp* ]]; then printf 'run.TEST1234\\n'; fi\n", "rsync": "#!/bin/bash\nprintf 'rsync %s\\n' \"$*\" >> \"$PARCEL_REMOTE_TEST_LOG\"\n", ] for (name, script) in scripts { let file = directory.appendingPathComponent(name) try Data(script.utf8).write(to: file) try FileManager.default.setAttributes([.posixPermissions: 0o700], ofItemAtPath: file.path) } let process = Process() process.executableURL = URL(fileURLWithPath: "/bin/bash") process.arguments = [root.appendingPathComponent("Scripts/test-remote.sh").path, "example.local"] + (e2e ? ["--e2e"] : []) var environment = ProcessInfo.processInfo.environment environment["PATH"] = directory.path + ":/usr/bin:/bin" environment["TMPDIR"] = directory.path + "/" environment["PARCEL_REMOTE_TEST_LOG"] = log.path process.environment = environment let output = Pipe() process.standardOutput = output process.standardError = output try process.run() process.waitUntilExit() #expect(process.terminationStatus == 0) let calls = try String(contentsOf: log, encoding: .utf8) let expected = e2e ? "Scripts/test-e2e.sh" : "Scripts/test.sh" #expect(calls.contains("example.local cd ~/parcel-ci/run.TEST1234 && \(expected)")) #expect(calls.contains("rsync")) #expect(!calls.contains("--delete")) }}