#!/usr/bin/env bash # # test-install.sh — regression tests for scripts/install.sh. # # install.sh is the largest script in the repo and every install bug so far has # been a silent one: agents land in the wrong directory, a path with a space is # split into two, a filter installs everything. These tests pin the observable # contract — where files land and how many — so those regressions fail loudly. # # Design constraints (same as the rest of scripts/): # * bash 3.2 + BSD userland, no jq, no GNU-only flags. # * Never touches the real $HOME. Every case runs with HOME set to a fresh # sandbox, so a broken default path writes into the sandbox, not your config. # * Only exercises the two source tools (claude-code, copilot) so no case # depends on convert.sh output being present or fresh. # # Usage: ./scripts/test-install.sh [-v] # -v echo the installer's own output for failing cases set -uo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" INSTALL="$SCRIPT_DIR/install.sh" # shellcheck source=scripts/lib.sh . "$SCRIPT_DIR/lib.sh" VERBOSE=false [[ "${1:-}" == "-v" ]] && VERBOSE=true passed=0 failed=0 xfailed=0 SANDBOX_ROOT="$(mktemp -d "${TMPDIR:-/tmp}/agency-install-tests.XXXXXX")" trap 'rm -rf "$SANDBOX_ROOT"' EXIT pass() { printf ' ok %s\n' "$1"; passed=$((passed + 1)); } fail() { printf ' FAIL %s\n' "$1" [[ -n "${2:-}" ]] && printf ' %s\n' "$2" failed=$((failed + 1)) } # assert_eq