Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions web/lib/test/probe-install.test.ts
Original file line number Diff line number Diff line change
@@ -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');
});
});
2 changes: 1 addition & 1 deletion web/public/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading