fix: context leak
This commit is contained in:
@@ -1 +1,3 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
package(default_visibility = ["//visibility:public"])
|
||||||
|
|
||||||
|
exports_files(["nested_bazel_test.sh"])
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ sh_test(
|
|||||||
"//:repo_runtime_files",
|
"//:repo_runtime_files",
|
||||||
"//bun:repo_runtime_files",
|
"//bun:repo_runtime_files",
|
||||||
"//internal:repo_runtime_files",
|
"//internal:repo_runtime_files",
|
||||||
|
"//tests:nested_bazel_test.sh",
|
||||||
"//tests/bundle_test/sourcemap_case:BUILD.bazel",
|
"//tests/bundle_test/sourcemap_case:BUILD.bazel",
|
||||||
"//tests/bundle_test/sourcemap_case:entry.ts",
|
"//tests/bundle_test/sourcemap_case:entry.ts",
|
||||||
],
|
],
|
||||||
@@ -246,6 +247,7 @@ sh_test(
|
|||||||
"//:repo_runtime_files",
|
"//:repo_runtime_files",
|
||||||
"//bun:repo_runtime_files",
|
"//bun:repo_runtime_files",
|
||||||
"//internal:repo_runtime_files",
|
"//internal:repo_runtime_files",
|
||||||
|
"//tests:nested_bazel_test.sh",
|
||||||
],
|
],
|
||||||
env_inherit = ["PATH"],
|
env_inherit = ["PATH"],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,19 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
if command -v bazel >/dev/null 2>&1; then
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
bazel_cmd=(bazel)
|
# shellcheck source=../nested_bazel_test.sh
|
||||||
elif command -v bazelisk >/dev/null 2>&1; then
|
source "${script_dir}/../nested_bazel_test.sh"
|
||||||
bazel_cmd=(bazelisk)
|
setup_nested_bazel_cmd
|
||||||
else
|
|
||||||
echo "bazel or bazelisk is required on PATH" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
find_workspace_root() {
|
find_workspace_root() {
|
||||||
local candidate
|
local candidate
|
||||||
local module_path
|
local module_path
|
||||||
local script_dir
|
local search_dir
|
||||||
|
|
||||||
for candidate in \
|
for candidate in \
|
||||||
"${TEST_SRCDIR:-}/${TEST_WORKSPACE:-}" \
|
"${TEST_SRCDIR:-}/${TEST_WORKSPACE:-}" \
|
||||||
@@ -32,8 +28,8 @@ find_workspace_root() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
search_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
candidate="$(cd "${script_dir}/../.." && pwd -P)"
|
candidate="$(cd "${search_dir}/../.." && pwd -P)"
|
||||||
if [[ -f "${candidate}/MODULE.bazel" ]]; then
|
if [[ -f "${candidate}/MODULE.bazel" ]]; then
|
||||||
printf '%s\n' "${candidate}"
|
printf '%s\n' "${candidate}"
|
||||||
return 0
|
return 0
|
||||||
@@ -45,6 +41,14 @@ find_workspace_root() {
|
|||||||
|
|
||||||
rules_bun_root="$(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() {
|
run_aquery() {
|
||||||
local mnemonic="$1"
|
local mnemonic="$1"
|
||||||
local target="$2"
|
local target="$2"
|
||||||
|
|||||||
@@ -1,19 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
if command -v bazel >/dev/null 2>&1; then
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
bazel_cmd=(bazel)
|
# shellcheck source=../nested_bazel_test.sh
|
||||||
elif command -v bazelisk >/dev/null 2>&1; then
|
source "${script_dir}/../nested_bazel_test.sh"
|
||||||
bazel_cmd=(bazelisk)
|
setup_nested_bazel_cmd
|
||||||
else
|
|
||||||
echo "bazel or bazelisk is required on PATH" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
find_workspace_root() {
|
find_workspace_root() {
|
||||||
local candidate
|
local candidate
|
||||||
local module_path
|
local module_path
|
||||||
local script_dir
|
local search_dir
|
||||||
|
|
||||||
for candidate in \
|
for candidate in \
|
||||||
"${TEST_SRCDIR:-}/${TEST_WORKSPACE:-}" \
|
"${TEST_SRCDIR:-}/${TEST_WORKSPACE:-}" \
|
||||||
@@ -32,8 +28,8 @@ find_workspace_root() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
search_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
candidate="$(cd "${script_dir}/../.." && pwd -P)"
|
candidate="$(cd "${search_dir}/../.." && pwd -P)"
|
||||||
if [[ -f "${candidate}/MODULE.bazel" ]]; then
|
if [[ -f "${candidate}/MODULE.bazel" ]]; then
|
||||||
printf '%s\n' "${candidate}"
|
printf '%s\n' "${candidate}"
|
||||||
return 0
|
return 0
|
||||||
@@ -45,6 +41,14 @@ find_workspace_root() {
|
|||||||
|
|
||||||
rules_bun_root="$(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="$(
|
bundle_output="$(
|
||||||
cd "${rules_bun_root}" &&
|
cd "${rules_bun_root}" &&
|
||||||
"${bazel_cmd[@]}" aquery 'mnemonic("BunBundle", //tests/bundle_test/sourcemap_case:sourcemap_bundle)' --output=textproto
|
"${bazel_cmd[@]}" aquery 'mnemonic("BunBundle", //tests/bundle_test/sourcemap_case:sourcemap_bundle)' --output=textproto
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ sh_test(
|
|||||||
"//:repo_runtime_files",
|
"//:repo_runtime_files",
|
||||||
"//bun:repo_runtime_files",
|
"//bun:repo_runtime_files",
|
||||||
"//internal:repo_runtime_files",
|
"//internal:repo_runtime_files",
|
||||||
|
"//tests:nested_bazel_test.sh",
|
||||||
],
|
],
|
||||||
env_inherit = ["PATH"],
|
env_inherit = ["PATH"],
|
||||||
)
|
)
|
||||||
@@ -201,6 +202,7 @@ sh_test(
|
|||||||
"//:repo_runtime_files",
|
"//:repo_runtime_files",
|
||||||
"//bun:repo_runtime_files",
|
"//bun:repo_runtime_files",
|
||||||
"//internal:repo_runtime_files",
|
"//internal:repo_runtime_files",
|
||||||
|
"//tests:nested_bazel_test.sh",
|
||||||
],
|
],
|
||||||
env_inherit = ["PATH"],
|
env_inherit = ["PATH"],
|
||||||
)
|
)
|
||||||
@@ -228,6 +230,7 @@ sh_test(
|
|||||||
"//:repo_runtime_files",
|
"//:repo_runtime_files",
|
||||||
"//bun:repo_runtime_files",
|
"//bun:repo_runtime_files",
|
||||||
"//internal:repo_runtime_files",
|
"//internal:repo_runtime_files",
|
||||||
|
"//tests:nested_bazel_test.sh",
|
||||||
],
|
],
|
||||||
env_inherit = ["PATH"],
|
env_inherit = ["PATH"],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
bun_path="$1"
|
bun_path="$1"
|
||||||
|
|
||||||
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)"
|
|
||||||
rules_bun_root="$(cd "${script_dir}/../.." && pwd -P)"
|
rules_bun_root="$(cd "${script_dir}/../.." && pwd -P)"
|
||||||
|
|
||||||
workdir="$(mktemp -d)"
|
workdir="$(mktemp -d)"
|
||||||
trap 'rm -rf "${workdir}"' EXIT
|
cleanup() {
|
||||||
|
local status="$1"
|
||||||
|
trap - EXIT
|
||||||
|
shutdown_nested_bazel_workspace "${fixture_dir:-}"
|
||||||
|
rm -rf "${workdir}"
|
||||||
|
exit "${status}"
|
||||||
|
}
|
||||||
|
trap 'cleanup $?' EXIT
|
||||||
|
|
||||||
fixture_dir="${workdir}/fixture"
|
fixture_dir="${workdir}/fixture"
|
||||||
mkdir -p "${fixture_dir}"
|
mkdir -p "${fixture_dir}"
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
bun_path="$1"
|
bun_path="$1"
|
||||||
|
|
||||||
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)"
|
|
||||||
rules_bun_root="$(cd "${script_dir}/../.." && pwd -P)"
|
rules_bun_root="$(cd "${script_dir}/../.." && pwd -P)"
|
||||||
|
|
||||||
workdir="$(mktemp -d)"
|
workdir="$(mktemp -d)"
|
||||||
trap 'rm -rf "${workdir}"' EXIT
|
cleanup() {
|
||||||
|
local status="$1"
|
||||||
|
trap - EXIT
|
||||||
|
shutdown_nested_bazel_workspace "${fixture_dir:-}"
|
||||||
|
rm -rf "${workdir}"
|
||||||
|
exit "${status}"
|
||||||
|
}
|
||||||
|
trap 'cleanup $?' EXIT
|
||||||
|
|
||||||
fixture_dir="${workdir}/fixture"
|
fixture_dir="${workdir}/fixture"
|
||||||
mkdir -p "${fixture_dir}"
|
mkdir -p "${fixture_dir}"
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
bun_path="${1:-bun}"
|
bun_path="${1:-bun}"
|
||||||
|
|
||||||
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)"
|
|
||||||
rules_bun_root="$(cd "${script_dir}/../.." && pwd -P)"
|
rules_bun_root="$(cd "${script_dir}/../.." && pwd -P)"
|
||||||
|
|
||||||
workdir="$(mktemp -d)"
|
workdir="$(mktemp -d)"
|
||||||
trap 'rm -rf "${workdir}"' EXIT
|
cleanup() {
|
||||||
|
local status="$1"
|
||||||
|
trap - EXIT
|
||||||
|
shutdown_nested_bazel_workspace "${bazel_dir:-}"
|
||||||
|
rm -rf "${workdir}"
|
||||||
|
exit "${status}"
|
||||||
|
}
|
||||||
|
trap 'cleanup $?' EXIT
|
||||||
|
|
||||||
fixture_dir="${workdir}/fixture"
|
fixture_dir="${workdir}/fixture"
|
||||||
plain_dir="${workdir}/plain"
|
plain_dir="${workdir}/plain"
|
||||||
|
|||||||
24
tests/nested_bazel_test.sh
Normal file
24
tests/nested_bazel_test.sh
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
setup_nested_bazel_cmd() {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
shutdown_nested_bazel_workspace() {
|
||||||
|
local workspace_dir="${1:-}"
|
||||||
|
if [[ -z ${workspace_dir} || ! -d ${workspace_dir} ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
(
|
||||||
|
cd "${workspace_dir}"
|
||||||
|
"${bazel_cmd[@]}" shutdown >/dev/null 2>&1
|
||||||
|
) || true
|
||||||
|
}
|
||||||
@@ -65,6 +65,7 @@ sh_test(
|
|||||||
"//internal:repo_runtime_files",
|
"//internal:repo_runtime_files",
|
||||||
"//js:repo_runtime_files",
|
"//js:repo_runtime_files",
|
||||||
"//npm:repo_runtime_files",
|
"//npm:repo_runtime_files",
|
||||||
|
"//tests:nested_bazel_test.sh",
|
||||||
],
|
],
|
||||||
env_inherit = ["PATH"],
|
env_inherit = ["PATH"],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
if command -v bazel >/dev/null 2>&1; then
|
|
||||||
bazel_bin="$(command -v bazel)"
|
|
||||||
elif command -v bazelisk >/dev/null 2>&1; then
|
|
||||||
bazel_bin="$(command -v bazelisk)"
|
|
||||||
else
|
|
||||||
echo "bazel or bazelisk is required on PATH" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
bun_path="${1:-bun}"
|
bun_path="${1:-bun}"
|
||||||
|
|
||||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
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
|
||||||
|
|
||||||
rules_bun_root="$(cd "${script_dir}/../.." && pwd -P)"
|
rules_bun_root="$(cd "${script_dir}/../.." && pwd -P)"
|
||||||
|
|
||||||
workdir="$(mktemp -d)"
|
workdir="$(mktemp -d)"
|
||||||
trap 'rm -rf "${workdir}"' EXIT
|
cleanup() {
|
||||||
|
local status="$1"
|
||||||
|
trap - EXIT
|
||||||
|
shutdown_nested_bazel_workspace "${fixture_dir:-}"
|
||||||
|
rm -rf "${workdir}"
|
||||||
|
exit "${status}"
|
||||||
|
}
|
||||||
|
trap 'cleanup $?' EXIT
|
||||||
|
|
||||||
fixture_dir="${workdir}/fixture"
|
fixture_dir="${workdir}/fixture"
|
||||||
mkdir -p "${fixture_dir}"
|
mkdir -p "${fixture_dir}"
|
||||||
@@ -100,7 +102,7 @@ EOF
|
|||||||
|
|
||||||
output="$(
|
output="$(
|
||||||
cd "${fixture_dir}" &&
|
cd "${fixture_dir}" &&
|
||||||
"${bazel_bin}" run //:app
|
"${bazel_cmd[@]}" run //:app
|
||||||
)"
|
)"
|
||||||
|
|
||||||
if [[ ${output} != *"compat:true"* ]]; then
|
if [[ ${output} != *"compat:true"* ]]; then
|
||||||
@@ -110,7 +112,7 @@ fi
|
|||||||
|
|
||||||
query_output="$(
|
query_output="$(
|
||||||
cd "${fixture_dir}" &&
|
cd "${fixture_dir}" &&
|
||||||
"${bazel_bin}" query //:npm__is_number
|
"${bazel_cmd[@]}" query //:npm__is_number
|
||||||
)"
|
)"
|
||||||
if ! grep -Fxq "//:npm__is_number" <<<"${query_output}"; then
|
if ! grep -Fxq "//:npm__is_number" <<<"${query_output}"; then
|
||||||
echo "expected npm_link_all_packages to create //:npm__is_number" >&2
|
echo "expected npm_link_all_packages to create //:npm__is_number" >&2
|
||||||
|
|||||||
Reference in New Issue
Block a user