fix: context leak

This commit is contained in:
eric
2026-03-15 11:50:25 +01:00
parent 683de60603
commit f317a618b8
11 changed files with 115 additions and 67 deletions

View File

@@ -202,6 +202,7 @@ sh_test(
"//:repo_runtime_files",
"//bun:repo_runtime_files",
"//internal:repo_runtime_files",
"//tests:nested_bazel_test.sh",
"//tests/bundle_test/sourcemap_case:BUILD.bazel",
"//tests/bundle_test/sourcemap_case:entry.ts",
],
@@ -246,6 +247,7 @@ sh_test(
"//:repo_runtime_files",
"//bun:repo_runtime_files",
"//internal:repo_runtime_files",
"//tests:nested_bazel_test.sh",
],
env_inherit = ["PATH"],
)

View File

@@ -1,19 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail
if command -v bazel >/dev/null 2>&1; then
bazel_cmd=(bazel)
elif command -v bazelisk >/dev/null 2>&1; then
bazel_cmd=(bazelisk)
else
echo "bazel or bazelisk is required on PATH" >&2
exit 1
fi
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
# shellcheck source=../nested_bazel_test.sh
source "${script_dir}/../nested_bazel_test.sh"
setup_nested_bazel_cmd
find_workspace_root() {
local candidate
local module_path
local script_dir
local search_dir
for candidate in \
"${TEST_SRCDIR:-}/${TEST_WORKSPACE:-}" \
@@ -32,8 +28,8 @@ find_workspace_root() {
fi
fi
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
candidate="$(cd "${script_dir}/../.." && pwd -P)"
search_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
candidate="$(cd "${search_dir}/../.." && pwd -P)"
if [[ -f "${candidate}/MODULE.bazel" ]]; then
printf '%s\n' "${candidate}"
return 0
@@ -45,6 +41,14 @@ find_workspace_root() {
rules_bun_root="$(find_workspace_root)"
cleanup() {
local status="$1"
trap - EXIT
shutdown_nested_bazel_workspace "${rules_bun_root}"
exit "${status}"
}
trap 'cleanup $?' EXIT
run_aquery() {
local mnemonic="$1"
local target="$2"

View File

@@ -1,19 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail
if command -v bazel >/dev/null 2>&1; then
bazel_cmd=(bazel)
elif command -v bazelisk >/dev/null 2>&1; then
bazel_cmd=(bazelisk)
else
echo "bazel or bazelisk is required on PATH" >&2
exit 1
fi
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
# shellcheck source=../nested_bazel_test.sh
source "${script_dir}/../nested_bazel_test.sh"
setup_nested_bazel_cmd
find_workspace_root() {
local candidate
local module_path
local script_dir
local search_dir
for candidate in \
"${TEST_SRCDIR:-}/${TEST_WORKSPACE:-}" \
@@ -32,8 +28,8 @@ find_workspace_root() {
fi
fi
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
candidate="$(cd "${script_dir}/../.." && pwd -P)"
search_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
candidate="$(cd "${search_dir}/../.." && pwd -P)"
if [[ -f "${candidate}/MODULE.bazel" ]]; then
printf '%s\n' "${candidate}"
return 0
@@ -45,6 +41,14 @@ find_workspace_root() {
rules_bun_root="$(find_workspace_root)"
cleanup() {
local status="$1"
trap - EXIT
shutdown_nested_bazel_workspace "${rules_bun_root}"
exit "${status}"
}
trap 'cleanup $?' EXIT
bundle_output="$(
cd "${rules_bun_root}" &&
"${bazel_cmd[@]}" aquery 'mnemonic("BunBundle", //tests/bundle_test/sourcemap_case:sourcemap_bundle)' --output=textproto