core-agent-ide/workspace_root_test_launcher.sh.tpl
Charley Cunningham 7ba1fccfc1
fix(ci): restore guardian coverage and bazel unit tests (#13912)
## Summary
- restore the guardian review request snapshot test and its tracked
snapshot after it was dropped from `main`
- make Bazel Rust unit-test wrappers resolve runfiles correctly on
manifest-only platforms like macOS and point Insta at the real workspace
root
- harden the shell-escalation socket-closure assertion so the musl Bazel
test no longer depends on fd reuse behavior

## Verification
- cargo test -p codex-core
guardian_review_request_layout_matches_model_visible_request_snapshot
- cargo test -p codex-shell-escalation
- bazel test //codex-rs/exec:exec-unit-tests
//codex-rs/shell-escalation:shell-escalation-unit-tests

Supersedes #13894.

---------

Co-authored-by: Ahmed Ibrahim <aibrahim@openai.com>
Co-authored-by: viyatb-oai <viyatb@openai.com>
Co-authored-by: Codex <noreply@openai.com>
2026-03-08 12:05:19 -07:00

53 lines
1.7 KiB
Smarty

#!/usr/bin/env bash
set -euo pipefail
resolve_runfile() {
local logical_path="$1"
local workspace_logical_path="${logical_path}"
if [[ -n "${TEST_WORKSPACE:-}" ]]; then
workspace_logical_path="${TEST_WORKSPACE}/${logical_path}"
fi
for runfiles_root in "${RUNFILES_DIR:-}" "${TEST_SRCDIR:-}"; do
if [[ -n "${runfiles_root}" && -e "${runfiles_root}/${logical_path}" ]]; then
printf '%s\n' "${runfiles_root}/${logical_path}"
return 0
fi
if [[ -n "${runfiles_root}" && -e "${runfiles_root}/${workspace_logical_path}" ]]; then
printf '%s\n' "${runfiles_root}/${workspace_logical_path}"
return 0
fi
done
local manifest="${RUNFILES_MANIFEST_FILE:-}"
if [[ -z "${manifest}" ]]; then
if [[ -f "$0.runfiles_manifest" ]]; then
manifest="$0.runfiles_manifest"
elif [[ -f "$0.exe.runfiles_manifest" ]]; then
manifest="$0.exe.runfiles_manifest"
fi
fi
if [[ -n "${manifest}" && -f "${manifest}" ]]; then
local resolved=""
resolved="$(awk -v key="${logical_path}" '$1 == key { $1 = ""; sub(/^ /, ""); print; exit }' "${manifest}")"
if [[ -z "${resolved}" ]]; then
resolved="$(awk -v key="${workspace_logical_path}" '$1 == key { $1 = ""; sub(/^ /, ""); print; exit }' "${manifest}")"
fi
if [[ -n "${resolved}" ]]; then
printf '%s\n' "${resolved}"
return 0
fi
fi
echo "failed to resolve runfile: $logical_path" >&2
return 1
}
workspace_root_marker="$(resolve_runfile "__WORKSPACE_ROOT_MARKER__")"
workspace_root="$(dirname "$(dirname "$(dirname "${workspace_root_marker}")")")"
test_bin="$(resolve_runfile "__TEST_BIN__")"
export INSTA_WORKSPACE_ROOT="${workspace_root}"
cd "${workspace_root}"
exec "${test_bin}" "$@"