diff --git a/web/lib/test/probe-install.test.ts b/web/lib/test/probe-install.test.ts new file mode 100644 index 0000000..a547145 --- /dev/null +++ b/web/lib/test/probe-install.test.ts @@ -0,0 +1,27 @@ +import { spawnSync } from 'node:child_process'; +import { readFileSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; +import { describe, expect, it } from 'vitest'; + +const installer = fileURLToPath(new URL('../../public/install.sh', import.meta.url)); + +describe('Relay Probe installer', () => { + it('parses under sh and exposes help without starting installation', () => { + expect(spawnSync('/bin/sh', ['-n', installer], { encoding: 'utf8' }).status).toBe(0); + const help = spawnSync('/bin/sh', [installer, '--help'], { encoding: 'utf8' }); + expect(help.status).toBe(0); + expect(help.stdout).toContain('agent-relay-probe'); + }); + + it('prints the platform under set -u without treating the ellipsis as part of its name', () => { + const source = readFileSync(installer, 'utf8'); + const progressLine = source.split('\n').find((line) => line.includes('Downloading Agent Relay Probe for')); + expect(progressLine).toBeDefined(); + + const result = spawnSync('/bin/sh', ['-c', `set -u; platform=darwin-arm64; ${progressLine}`], { + encoding: 'utf8', + }); + expect(result.status).toBe(0); + expect(result.stdout).toBe('Downloading Agent Relay Probe for darwin-arm64…\n'); + }); +}); diff --git a/web/public/install.sh b/web/public/install.sh index 345b308..105a696 100644 --- a/web/public/install.sh +++ b/web/public/install.sh @@ -53,7 +53,7 @@ else fail "A SHA-256 tool (sha256sum or shasum) is required."; fi probe_tmp=$(mktemp -d "${TMPDIR:-/tmp}/agent-relay-probe.XXXXXX") trap 'rm -rf "$probe_tmp"' EXIT HUP INT TERM download="$SITE_URL/downloads/agent-relay-probe/$platform/agent-relay-probe" -printf '%s\n' "Downloading Agent Relay Probe for $platform…" +printf '%s\n' "Downloading Agent Relay Probe for ${platform}…" curl --proto "$CURL_PROTOCOL" --max-time 120 --max-filesize 104857600 -fsS "$download" -o "$probe_tmp/agent-relay-probe" || fail "The native probe build is not available on this site for your platform." curl --proto "$CURL_PROTOCOL" --max-time 30 --max-filesize 1024 -fsS "$download.sha256" -o "$probe_tmp/checksum" || fail "Could not download the probe checksum." expected=$(awk 'NR == 1 { print $1 }' "$probe_tmp/checksum")