()
| 55 | }; |
| 56 | |
| 57 | const provisionMac = async (): Promise<ProvisionedGuest> => { |
| 58 | ensureBundle(); |
| 59 | const { exe, executor } = hostBundle(); |
| 60 | const vm = await tartVm("macos", "arm64").provision(); |
| 61 | try { |
| 62 | // Push the bundle (tar-stream, robust over the just-booted link) and clear |
| 63 | // the scp quarantine so it can run. |
| 64 | await vm.ssh(`rm -rf ${GUEST_DIR} ${GUEST_HOME} && mkdir -p ${GUEST_HOME}/.executor`); |
| 65 | await pushDirAsTar(vm.host, hostBundle().app, GUEST_DIR); |
| 66 | await vm.ssh(`xattr -dr com.apple.quarantine ${GUEST_DIR} 2>/dev/null || true`); |
| 67 | // The e2e build is unsigned; an arm64 app needs at least an ad-hoc signature |
| 68 | // to execute, and the host build's signature isn't trusted on another Mac. |
| 69 | await vm.ssh( |
| 70 | `codesign --force --deep --sign - ${GUEST_DIR}/Executor.app 2>&1 | tail -2 || true`, |
| 71 | ); |
| 72 | |
| 73 | const guestExe = `${GUEST_DIR}/Executor.app/${exe.split("/Executor.app/")[1]}`; |
| 74 | const guestExecutor = `${GUEST_DIR}/Executor.app/${executor.split("/Executor.app/")[1]}`; |
| 75 | const env = `HOME=${GUEST_HOME} EXECUTOR_DATA_DIR=${GUEST_HOME}/.executor`; |
| 76 | |
| 77 | // 1) the bundled daemon, supervised — the app attaches to this. |
| 78 | await vm.ssh( |
| 79 | `nohup env ${env} EXECUTOR_SUPERVISED=1 EXECUTOR_AUTH_TOKEN=desktop-macos-e2e EXECUTOR_CLIENT=desktop ` + |
| 80 | `'${guestExecutor}' daemon run --foreground --port ${DAEMON_PORT} --hostname 127.0.0.1 ` + |
| 81 | `--auth-token desktop-macos-e2e ` + |
| 82 | `>/tmp/executor-daemon.log 2>&1 &`, |
| 83 | ); |
| 84 | if (!(await waitGuestHttp(vm, `http://127.0.0.1:${DAEMON_PORT}/`))) { |
| 85 | throw new Error( |
| 86 | "supervised daemon never came up in the guest (see /tmp/executor-daemon.log)", |
| 87 | ); |
| 88 | } |
| 89 | |
| 90 | // 2) the packaged app, launched INTO the Aqua session with CDP enabled. |
| 91 | await vm.ssh( |
| 92 | `U=$(id -u); sudo launchctl asuser $U bash -lc ` + |
| 93 | `'nohup env HOME=${GUEST_HOME} "${guestExe}" --remote-debugging-port=${CDP_GUEST_PORT} --remote-allow-origins="*" ` + |
| 94 | `>/tmp/executor-app.log 2>&1 &'`, |
| 95 | ); |
| 96 | if (!(await waitGuestPageTarget(vm, CDP_GUEST_PORT))) { |
| 97 | const log = (await vm.ssh("tail -40 /tmp/executor-app.log 2>/dev/null").catch(() => null)) |
| 98 | ?.stdout; |
| 99 | throw new Error(`the app's CDP page target never appeared:\n${log ?? "(no app log)"}`); |
| 100 | } |
| 101 | |
| 102 | return { ip: vm.host, teardown: async () => void (await vm.discard()) }; |
| 103 | } catch (error) { |
| 104 | await vm.discard(); |
| 105 | throw error; |
| 106 | } |
| 107 | }; |
| 108 | |
| 109 | export default (): Promise<(() => Promise<void>) | void> => attachOrProvision(provisionMac); |
nothing calls this directly
no test coverage detected