tstest/tailmac: fix Host.app path generation (#13953)

updates tailscale/corp#24197

Generation of the Host.app path was erroneous and tailmac run
would not work unless the pwd was tailmac/bin.  Now you can
be able to invoke tailmac from anywhere.

Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
pull/13959/head
Jonathan Nobels 4 weeks ago committed by GitHub
parent 9545e36007
commit 0f9a054cba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -100,7 +100,10 @@ extension Tailmac {
mutating func run() { mutating func run() {
let process = Process() let process = Process()
let stdOutPipe = Pipe() let stdOutPipe = Pipe()
let appPath = "./Host.app/Contents/MacOS/Host"
let executablePath = CommandLine.arguments[0]
let executableDirectory = (executablePath as NSString).deletingLastPathComponent
let appPath = executableDirectory + "/Host.app/Contents/MacOS/Host"
process.executableURL = URL( process.executableURL = URL(
fileURLWithPath: appPath, fileURLWithPath: appPath,
@ -109,7 +112,7 @@ extension Tailmac {
) )
if !FileManager.default.fileExists(atPath: appPath) { if !FileManager.default.fileExists(atPath: appPath) {
fatalError("Could not find Host.app. This must be co-located with the tailmac utility") fatalError("Could not find Host.app at \(appPath). This must be co-located with the tailmac utility")
} }
process.arguments = ["run", "--id", id] process.arguments = ["run", "--id", id]

Loading…
Cancel
Save