test: add independent P1.1 acceptance and manual tooling

This commit is contained in:
2026-08-11 16:04:44 +02:00
parent 930335a804
commit a22d232aa2
11 changed files with 1923 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
#!/usr/bin/env -S -i PATH=/usr/bin:/bin /bin/bash
set -euo pipefail
script_path=${BASH_SOURCE[0]}
script_dir=${script_path%/*}
[[ "$script_dir" != "$script_path" ]] || script_dir=.
repo_root="$(cd -P -- "$script_dir/.." && pwd)"
if [[ $# -lt 1 || "$1" != "integration" || $# -gt 2 || ( $# -eq 2 && "$2" != "--keep" ) ]]; then
printf 'usage: %s integration [--keep]\n' "$0" >&2
exit 2
fi
canonical_file() {
local path=$1 target parent leaf
[[ "$path" = /* ]] || return 1
while [[ -L "$path" ]]; do
target=$(/usr/bin/readlink "$path") || return 1
if [[ "$target" = /* ]]; then path=$target; else path="${path%/*}/$target"; fi
done
parent=${path%/*}; leaf=${path##*/}
parent=$(cd -P -- "$parent" && pwd) || return 1
printf '%s/%s\n' "$parent" "$leaf"
}
node_path= npm_path= toolchain_prefix=
for pair in \
"/usr/bin/node|/usr/bin/npm|/usr" \
"/opt/homebrew/bin/node|/opt/homebrew/bin/npm|/opt/homebrew" \
"/usr/local/bin/node|/usr/local/bin/npm|/usr/local"; do
node_candidate=${pair%%|*}; remainder=${pair#*|}; npm_candidate=${remainder%%|*}; prefix=${remainder##*|}
[[ -e "$node_candidate" && -e "$npm_candidate" ]] || continue
resolved_node=$(canonical_file "$node_candidate") || continue
resolved_npm=$(canonical_file "$npm_candidate") || continue
[[ -f "$resolved_node" && ! -L "$resolved_node" && -x "$resolved_node" ]] || continue
[[ -f "$resolved_npm" && ! -L "$resolved_npm" ]] || continue
[[ "${resolved_npm##*/}" = "npm-cli.js" ]] || continue
node_path=$resolved_node; npm_path=$resolved_npm; toolchain_prefix=$prefix
break
done
[[ -n "$node_path" && -n "$npm_path" && -n "$toolchain_prefix" ]] || {
printf 'trusted fixed Node/npm toolchain is unavailable\n' >&2
exit 127
}
wrapper_root=$(/usr/bin/mktemp -d /tmp/thoth-p11-wrapper.XXXXXXXX)
trap '/bin/rm -rf -- "$wrapper_root"' EXIT HUP INT TERM
/bin/mkdir -m 700 "$wrapper_root/home" "$wrapper_root/tmp"
owned_path="${node_path%/*}:/usr/bin:/bin"
build_env=(/usr/bin/env -i "PATH=$owned_path" "HOME=$wrapper_root/home" "TMPDIR=$wrapper_root/tmp")
/bin/rm -rf -- "$repo_root/backend/dist"
"${build_env[@]}" "$node_path" "$npm_path" --prefix "$repo_root/backend" run build
safe_env=(/usr/bin/env -i "PATH=$owned_path" "HOME=$wrapper_root/home" "TMPDIR=$wrapper_root/tmp"
"THT_BIN=$repo_root/harness/.venv/bin/tht" "P11_ACCEPTANCE_NODE_PATH=$node_path" "P11_ACCEPTANCE_NPM_PATH=$npm_path")
set +e
"${safe_env[@]}" "$node_path" "$repo_root/backend/scripts/p11-acceptance.mjs" "$@"
status=$?
set -e
exit "$status"
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
if [[ $# -ne 1 || ! "$1" =~ ^(prepare|serve|stop|cleanup)$ ]]; then
printf 'usage: %s prepare|serve|stop|cleanup\n' "$0" >&2
exit 2
fi
exec node "$repo_root/backend/scripts/p11-manual-acceptance.mjs" "$1"
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
bash -n "$repo_root/scripts/p11-acceptance.sh" "$repo_root/scripts/test-p11-acceptance.sh"
node --check "$repo_root/backend/scripts/p11-acceptance.mjs"
node --check "$repo_root/backend/scripts/p11-acceptance.test.mjs"
npm --prefix "$repo_root/backend" run build
node --test "$repo_root/backend/scripts/p11-acceptance.test.mjs"
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
bash -n "$repo_root/scripts/p11-manual-acceptance.sh" "$repo_root/scripts/test-p11-manual-acceptance.sh"
node --check "$repo_root/backend/scripts/p11-manual-acceptance.mjs"
node --check "$repo_root/backend/scripts/p11-render-snapshot.mjs"
node --check "$repo_root/backend/scripts/p11-manual-acceptance.test.mjs"
node --check "$repo_root/backend/scripts/p11-render-snapshot.test.mjs"
npm --prefix "$repo_root/backend" run build
npm --prefix "$repo_root/frontend" run build
node --test "$repo_root/backend/scripts/p11-manual-acceptance.test.mjs"
node --test "$repo_root/backend/scripts/p11-render-snapshot.test.mjs"