ci: fix dependencies

This commit is contained in:
eric
2026-03-15 13:54:18 +01:00
parent 54109136ab
commit f975f12553
37 changed files with 522 additions and 148 deletions

View File

@@ -44,8 +44,8 @@ sh_test(
size = "small",
srcs = ["verify_data_shape.sh"],
args = [
"$(location //internal:bun_binary.bzl)",
"$(location //tests/binary_test:BUILD.bazel)",
"$(rlocationpath //internal:bun_binary.bzl)",
"$(rlocationpath //tests/binary_test:BUILD.bazel)",
],
data = [
"//internal:bun_binary.bzl",

View File

@@ -1,5 +1,18 @@
import { spawnSync } from "node:child_process";
const pathValue = process.env.PATH ?? "";
function commandSucceeds(command: string, args: string[]): boolean {
const result = spawnSync(command, args, {
encoding: "utf8",
env: process.env,
});
return result.status === 0;
}
console.log(JSON.stringify({
hasHostSentinel: pathValue.includes("rules_bun_host_path_sentinel"),
canRunBun: commandSucceeds("bun", ["-e", "process.exit(0)"]),
canRunBunx: commandSucceeds("bunx", ["--version"]),
canRunNode: commandSucceeds("node", ["-e", "process.exit(0)"]),
}));

View File

@@ -8,12 +8,7 @@ run_launcher() {
local launcher="$1"
shift
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
cmd.exe /c "${command}" | tr -d '\r'
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
return 0
fi
"${launcher}" "$@"

View File

@@ -7,12 +7,7 @@ run_launcher() {
local launcher="$1"
shift
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
cmd.exe /c "${command}" | tr -d '\r'
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
return 0
fi
"${launcher}" "$@"

View File

@@ -7,12 +7,7 @@ run_launcher() {
local launcher="$1"
shift
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
cmd.exe /c "${command}" | tr -d '\r'
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
return 0
fi
"${launcher}" "$@"

View File

@@ -7,12 +7,7 @@ run_launcher() {
local launcher="$1"
shift
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
cmd.exe /c "${command}" | tr -d '\r'
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
return 0
fi
"${launcher}" "$@"

View File

@@ -8,12 +8,7 @@ run_launcher() {
local launcher="$1"
shift
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
env PATH="rules_bun_host_path_sentinel:${PATH:-}" cmd.exe /c "${command}" | tr -d '\r'
env PATH="rules_bun_host_path_sentinel:${PATH:-}" cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
return 0
fi
env PATH="rules_bun_host_path_sentinel:${PATH:-}" "${launcher}" "$@"
@@ -22,12 +17,12 @@ run_launcher() {
default_output="$(run_launcher "${default_binary}")"
inherit_output="$(run_launcher "${inherit_binary}")"
if [[ ${default_output} != '{"hasHostSentinel":false}' ]]; then
if [[ ${default_output} != '{"hasHostSentinel":false,"canRunBun":true,"canRunBunx":true,"canRunNode":true}' ]]; then
echo "Expected default launcher to hide host PATH, got: ${default_output}" >&2
exit 1
fi
if [[ ${inherit_output} != '{"hasHostSentinel":true}' ]]; then
if [[ ${inherit_output} != '{"hasHostSentinel":true,"canRunBun":true,"canRunBunx":true,"canRunNode":true}' ]]; then
echo "Expected inherit_host_path launcher to preserve host PATH, got: ${inherit_output}" >&2
exit 1
fi

View File

@@ -1,8 +1,64 @@
#!/usr/bin/env bash
set -euo pipefail
rule_file="$1"
build_file="$2"
if [[ -z ${RUNFILES_DIR:-} && -n ${TEST_SRCDIR:-} && -d ${TEST_SRCDIR} ]]; then
RUNFILES_DIR="${TEST_SRCDIR}"
fi
if [[ -z ${RUNFILES_DIR:-} && -z ${RUNFILES_MANIFEST_FILE:-} ]]; then
if [[ -d "$0.runfiles" ]]; then
RUNFILES_DIR="$0.runfiles"
elif [[ -f "$0.runfiles_manifest" ]]; then
RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
elif [[ -f "$0.exe.runfiles_manifest" ]]; then
RUNFILES_MANIFEST_FILE="$0.exe.runfiles_manifest"
fi
fi
resolve_runfile() {
local path="${1:-}"
local candidate
local resolved
if [[ -z ${path} ]]; then
echo "Error: missing runfile path" >&2
exit 1
fi
if [[ ${path} == /* || ${path} =~ ^[A-Za-z]:[\\/] ]]; then
printf '%s\n' "${path}"
return 0
fi
if [[ -e ${path} ]]; then
printf '%s\n' "${path}"
return 0
fi
for candidate in \
"${path}" \
"${TEST_WORKSPACE:-}/${path}" \
"_main/${path}"; do
[[ -z ${candidate} ]] && continue
if [[ -n ${RUNFILES_DIR:-} && -e "${RUNFILES_DIR}/${candidate}" ]]; then
printf '%s\n' "${RUNFILES_DIR}/${candidate}"
return 0
fi
if [[ -n ${RUNFILES_MANIFEST_FILE:-} ]]; then
resolved="$(
awk -v key="${candidate}" 'index($0, key " ") == 1 { print substr($0, length(key) + 2); exit }' \
"${RUNFILES_MANIFEST_FILE}"
)"
if [[ -n ${resolved} ]]; then
printf '%s\n' "${resolved}"
return 0
fi
fi
done
echo "Error: unable to resolve runfile: ${path}" >&2
exit 1
}
rule_file="$(resolve_runfile "${1:-}")"
build_file="$(resolve_runfile "${2:-}")"
grep -Eq 'extra_files = ctx\.files\.data \+ ctx\.files\.preload \+ ctx\.files\.env_files \+ \[bun_bin\]' "${rule_file}"
grep -Eq 'name = "hello_js_with_data_bin"' "${build_file}"

View File

@@ -60,7 +60,7 @@ sh_test(
name = "bun_test_failing_suite_test",
size = "small",
srcs = ["failing_suite_shape.sh"],
args = ["$(location //tests/bun_test_test:BUILD.bazel)"],
args = ["$(rlocationpath //tests/bun_test_test:BUILD.bazel)"],
data = ["//tests/bun_test_test:BUILD.bazel"],
)

View File

@@ -1,7 +1,63 @@
#!/usr/bin/env bash
set -euo pipefail
build_file="$1"
if [[ -z ${RUNFILES_DIR:-} && -n ${TEST_SRCDIR:-} && -d ${TEST_SRCDIR} ]]; then
RUNFILES_DIR="${TEST_SRCDIR}"
fi
if [[ -z ${RUNFILES_DIR:-} && -z ${RUNFILES_MANIFEST_FILE:-} ]]; then
if [[ -d "$0.runfiles" ]]; then
RUNFILES_DIR="$0.runfiles"
elif [[ -f "$0.runfiles_manifest" ]]; then
RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
elif [[ -f "$0.exe.runfiles_manifest" ]]; then
RUNFILES_MANIFEST_FILE="$0.exe.runfiles_manifest"
fi
fi
resolve_runfile() {
local path="${1:-}"
local candidate
local resolved
if [[ -z ${path} ]]; then
echo "Error: missing runfile path" >&2
exit 1
fi
if [[ ${path} == /* || ${path} =~ ^[A-Za-z]:[\\/] ]]; then
printf '%s\n' "${path}"
return 0
fi
if [[ -e ${path} ]]; then
printf '%s\n' "${path}"
return 0
fi
for candidate in \
"${path}" \
"${TEST_WORKSPACE:-}/${path}" \
"_main/${path}"; do
[[ -z ${candidate} ]] && continue
if [[ -n ${RUNFILES_DIR:-} && -e "${RUNFILES_DIR}/${candidate}" ]]; then
printf '%s\n' "${RUNFILES_DIR}/${candidate}"
return 0
fi
if [[ -n ${RUNFILES_MANIFEST_FILE:-} ]]; then
resolved="$(
awk -v key="${candidate}" 'index($0, key " ") == 1 { print substr($0, length(key) + 2); exit }' \
"${RUNFILES_MANIFEST_FILE}"
)"
if [[ -n ${resolved} ]]; then
printf '%s\n' "${resolved}"
return 0
fi
fi
done
echo "Error: unable to resolve runfile: ${path}" >&2
exit 1
}
build_file="$(resolve_runfile "${1:-}")"
grep -Eq 'name = "failing_suite"' "${build_file}"
if grep -Eq 'tags = \["manual"\]' "${build_file}"; then

View File

@@ -4,7 +4,7 @@ sh_test(
name = "phase8_ci_matrix_shape_test",
size = "small",
srcs = ["phase8_ci_matrix_shape_test.sh"],
args = ["$(location //.github/workflows:ci.yml)"],
args = ["$(rlocationpath //.github/workflows:ci.yml)"],
data = ["//.github/workflows:ci.yml"],
)
@@ -12,7 +12,7 @@ sh_test(
name = "phase8_ci_targets_test",
size = "small",
srcs = ["phase8_ci_targets_test.sh"],
args = ["$(location :phase8_ci_targets.sh)"],
args = ["$(rlocationpath :phase8_ci_targets.sh)"],
data = [":phase8_ci_targets.sh"],
)

View File

@@ -1,7 +1,63 @@
#!/usr/bin/env bash
set -euo pipefail
workflow_file="$1"
if [[ -z ${RUNFILES_DIR:-} && -n ${TEST_SRCDIR:-} && -d ${TEST_SRCDIR} ]]; then
RUNFILES_DIR="${TEST_SRCDIR}"
fi
if [[ -z ${RUNFILES_DIR:-} && -z ${RUNFILES_MANIFEST_FILE:-} ]]; then
if [[ -d "$0.runfiles" ]]; then
RUNFILES_DIR="$0.runfiles"
elif [[ -f "$0.runfiles_manifest" ]]; then
RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
elif [[ -f "$0.exe.runfiles_manifest" ]]; then
RUNFILES_MANIFEST_FILE="$0.exe.runfiles_manifest"
fi
fi
resolve_runfile() {
local path="${1:-}"
local candidate
local resolved
if [[ -z ${path} ]]; then
echo "Error: missing runfile path" >&2
exit 1
fi
if [[ ${path} == /* || ${path} =~ ^[A-Za-z]:[\\/] ]]; then
printf '%s\n' "${path}"
return 0
fi
if [[ -e ${path} ]]; then
printf '%s\n' "${path}"
return 0
fi
for candidate in \
"${path}" \
"${TEST_WORKSPACE:-}/${path}" \
"_main/${path}"; do
[[ -z ${candidate} ]] && continue
if [[ -n ${RUNFILES_DIR:-} && -e "${RUNFILES_DIR}/${candidate}" ]]; then
printf '%s\n' "${RUNFILES_DIR}/${candidate}"
return 0
fi
if [[ -n ${RUNFILES_MANIFEST_FILE:-} ]]; then
resolved="$(
awk -v key="${candidate}" 'index($0, key " ") == 1 { print substr($0, length(key) + 2); exit }' \
"${RUNFILES_MANIFEST_FILE}"
)"
if [[ -n ${resolved} ]]; then
printf '%s\n' "${resolved}"
return 0
fi
fi
done
echo "Error: unable to resolve runfile: ${path}" >&2
exit 1
}
workflow_file="$(resolve_runfile "${1:-}")"
if [ -z "${workflow_file}" ]; then
echo "Error: workflow file path required as first argument" >&2
exit 1

View File

@@ -1,7 +1,63 @@
#!/usr/bin/env bash
set -euo pipefail
resolver="${1:-}"
if [[ -z ${RUNFILES_DIR:-} && -n ${TEST_SRCDIR:-} && -d ${TEST_SRCDIR} ]]; then
RUNFILES_DIR="${TEST_SRCDIR}"
fi
if [[ -z ${RUNFILES_DIR:-} && -z ${RUNFILES_MANIFEST_FILE:-} ]]; then
if [[ -d "$0.runfiles" ]]; then
RUNFILES_DIR="$0.runfiles"
elif [[ -f "$0.runfiles_manifest" ]]; then
RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
elif [[ -f "$0.exe.runfiles_manifest" ]]; then
RUNFILES_MANIFEST_FILE="$0.exe.runfiles_manifest"
fi
fi
resolve_runfile() {
local path="${1:-}"
local candidate
local resolved
if [[ -z ${path} ]]; then
echo "Error: missing runfile path" >&2
exit 1
fi
if [[ ${path} == /* || ${path} =~ ^[A-Za-z]:[\\/] ]]; then
printf '%s\n' "${path}"
return 0
fi
if [[ -e ${path} ]]; then
printf '%s\n' "${path}"
return 0
fi
for candidate in \
"${path}" \
"${TEST_WORKSPACE:-}/${path}" \
"_main/${path}"; do
[[ -z ${candidate} ]] && continue
if [[ -n ${RUNFILES_DIR:-} && -e "${RUNFILES_DIR}/${candidate}" ]]; then
printf '%s\n' "${RUNFILES_DIR}/${candidate}"
return 0
fi
if [[ -n ${RUNFILES_MANIFEST_FILE:-} ]]; then
resolved="$(
awk -v key="${candidate}" 'index($0, key " ") == 1 { print substr($0, length(key) + 2); exit }' \
"${RUNFILES_MANIFEST_FILE}"
)"
if [[ -n ${resolved} ]]; then
printf '%s\n' "${resolved}"
return 0
fi
fi
done
echo "Error: unable to resolve runfile: ${path}" >&2
exit 1
}
resolver="$(resolve_runfile "${1:-}")"
if [[ -z ${resolver} ]]; then
echo "Error: resolver path required as first argument" >&2
exit 1

View File

@@ -19,12 +19,7 @@ start_launcher() {
local log_target="$2"
shift 2
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
cmd.exe /c "${command}" >"${log_target}" 2>&1 &
cmd.exe /c call "${launcher}" "$@" >"${log_target}" 2>&1 &
else
"${launcher}" "$@" >"${log_target}" 2>&1 &
fi

View File

@@ -22,12 +22,7 @@ start_launcher() {
local log_target="$2"
shift 2
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
cmd.exe /c "${command}" >"${log_target}" 2>&1 &
cmd.exe /c call "${launcher}" "$@" >"${log_target}" 2>&1 &
else
"${launcher}" "$@" >"${log_target}" 2>&1 &
fi

View File

@@ -7,12 +7,7 @@ run_launcher() {
local launcher="$1"
shift
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
cmd.exe /c "${command}" | tr -d '\r'
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
return 0
fi
"${launcher}" "$@"

View File

@@ -7,12 +7,7 @@ run_launcher() {
local launcher="$1"
shift
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
cmd.exe /c "${command}" | tr -d '\r'
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
return 0
fi
"${launcher}" "$@"

View File

@@ -7,12 +7,7 @@ run_launcher() {
local launcher="$1"
shift
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
cmd.exe /c "${command}" | tr -d '\r'
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
return 0
fi
"${launcher}" "$@"

View File

@@ -14,12 +14,7 @@ run_launcher() {
local launcher="$1"
shift
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
cmd.exe /c "${command}" | tr -d '\r'
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
return 0
fi
"${launcher}" "$@"

View File

@@ -8,12 +8,7 @@ run_launcher() {
local launcher="$1"
shift
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
cmd.exe /c "${command}" | tr -d '\r'
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
return 0
fi
"${launcher}" "$@"

View File

@@ -19,12 +19,7 @@ start_launcher() {
local log_target="$2"
shift 2
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
cmd.exe /c "${command}" >"${log_target}" 2>&1 &
cmd.exe /c call "${launcher}" "$@" >"${log_target}" 2>&1 &
else
"${launcher}" "$@" >"${log_target}" 2>&1 &
fi

View File

@@ -22,12 +22,7 @@ start_launcher() {
local log_target="$2"
shift 2
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
cmd.exe /c "${command}" >"${log_target}" 2>&1 &
cmd.exe /c call "${launcher}" "$@" >"${log_target}" 2>&1 &
else
"${launcher}" "$@" >"${log_target}" 2>&1 &
fi

View File

@@ -7,12 +7,7 @@ run_launcher() {
local launcher="$1"
shift
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
cmd.exe /c "${command}" | tr -d '\r'
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
return 0
fi
"${launcher}" "$@"

View File

@@ -7,12 +7,7 @@ run_launcher() {
local launcher="$1"
shift
if [[ ${launcher} == *.cmd ]]; then
local command
printf -v command '"%s"' "${launcher}"
for arg in "$@"; do
printf -v command '%s "%s"' "${command}" "${arg}"
done
cmd.exe /c "${command}" | tr -d '\r'
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
return 0
fi
"${launcher}" "$@"

View File

@@ -45,12 +45,12 @@ sh_test(
size = "small",
srcs = ["toolchain_version.sh"],
args = select({
":linux_x86_64": ["$(location @bun_linux_x64//:bun)"],
":linux_aarch64": ["$(location @bun_linux_aarch64//:bun)"],
":darwin_x86_64": ["$(location @bun_darwin_x64//:bun)"],
":darwin_aarch64": ["$(location @bun_darwin_aarch64//:bun)"],
":windows_x86_64": ["$(location @bun_windows_x64//:bun)"],
"//conditions:default": ["$(location @bun_linux_x64//:bun)"],
":linux_x86_64": ["$(rlocationpath @bun_linux_x64//:bun)"],
":linux_aarch64": ["$(rlocationpath @bun_linux_aarch64//:bun)"],
":darwin_x86_64": ["$(rlocationpath @bun_darwin_x64//:bun)"],
":darwin_aarch64": ["$(rlocationpath @bun_darwin_aarch64//:bun)"],
":windows_x86_64": ["$(rlocationpath @bun_windows_x64//:bun)"],
"//conditions:default": ["$(rlocationpath @bun_linux_x64//:bun)"],
}),
data = select({
":linux_x86_64": ["@bun_linux_x64//:bun"],
@@ -66,6 +66,6 @@ sh_test(
name = "toolchain_resolution_matrix_test",
size = "small",
srcs = ["toolchain_resolution_matrix.sh"],
args = ["$(location //tests/toolchain_test:BUILD.bazel)"],
args = ["$(rlocationpath //tests/toolchain_test:BUILD.bazel)"],
data = ["//tests/toolchain_test:BUILD.bazel"],
)

View File

@@ -1,7 +1,63 @@
#!/usr/bin/env bash
set -euo pipefail
build_file="$1"
if [[ -z ${RUNFILES_DIR:-} && -n ${TEST_SRCDIR:-} && -d ${TEST_SRCDIR} ]]; then
RUNFILES_DIR="${TEST_SRCDIR}"
fi
if [[ -z ${RUNFILES_DIR:-} && -z ${RUNFILES_MANIFEST_FILE:-} ]]; then
if [[ -d "$0.runfiles" ]]; then
RUNFILES_DIR="$0.runfiles"
elif [[ -f "$0.runfiles_manifest" ]]; then
RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
elif [[ -f "$0.exe.runfiles_manifest" ]]; then
RUNFILES_MANIFEST_FILE="$0.exe.runfiles_manifest"
fi
fi
resolve_runfile() {
local path="${1:-}"
local candidate
local resolved
if [[ -z ${path} ]]; then
echo "Error: missing runfile path" >&2
exit 1
fi
if [[ ${path} == /* || ${path} =~ ^[A-Za-z]:[\\/] ]]; then
printf '%s\n' "${path}"
return 0
fi
if [[ -e ${path} ]]; then
printf '%s\n' "${path}"
return 0
fi
for candidate in \
"${path}" \
"${TEST_WORKSPACE:-}/${path}" \
"_main/${path}"; do
[[ -z ${candidate} ]] && continue
if [[ -n ${RUNFILES_DIR:-} && -e "${RUNFILES_DIR}/${candidate}" ]]; then
printf '%s\n' "${RUNFILES_DIR}/${candidate}"
return 0
fi
if [[ -n ${RUNFILES_MANIFEST_FILE:-} ]]; then
resolved="$(
awk -v key="${candidate}" 'index($0, key " ") == 1 { print substr($0, length(key) + 2); exit }' \
"${RUNFILES_MANIFEST_FILE}"
)"
if [[ -n ${resolved} ]]; then
printf '%s\n' "${resolved}"
return 0
fi
fi
done
echo "Error: unable to resolve runfile: ${path}" >&2
exit 1
}
build_file="$(resolve_runfile "${1:-}")"
grep -Eq 'name = "linux_x86_64"' "${build_file}"
grep -Eq 'name = "linux_aarch64"' "${build_file}"

View File

@@ -1,8 +1,64 @@
#!/usr/bin/env bash
set -euo pipefail
bun_path="$1"
version="$(${bun_path} --version)"
if [[ -z ${RUNFILES_DIR:-} && -n ${TEST_SRCDIR:-} && -d ${TEST_SRCDIR} ]]; then
RUNFILES_DIR="${TEST_SRCDIR}"
fi
if [[ -z ${RUNFILES_DIR:-} && -z ${RUNFILES_MANIFEST_FILE:-} ]]; then
if [[ -d "$0.runfiles" ]]; then
RUNFILES_DIR="$0.runfiles"
elif [[ -f "$0.runfiles_manifest" ]]; then
RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
elif [[ -f "$0.exe.runfiles_manifest" ]]; then
RUNFILES_MANIFEST_FILE="$0.exe.runfiles_manifest"
fi
fi
resolve_runfile() {
local path="${1:-}"
local candidate
local resolved
if [[ -z ${path} ]]; then
echo "Error: missing runfile path" >&2
exit 1
fi
if [[ ${path} == /* || ${path} =~ ^[A-Za-z]:[\\/] ]]; then
printf '%s\n' "${path}"
return 0
fi
if [[ -e ${path} ]]; then
printf '%s\n' "${path}"
return 0
fi
for candidate in \
"${path}" \
"${TEST_WORKSPACE:-}/${path}" \
"_main/${path}"; do
[[ -z ${candidate} ]] && continue
if [[ -n ${RUNFILES_DIR:-} && -e "${RUNFILES_DIR}/${candidate}" ]]; then
printf '%s\n' "${RUNFILES_DIR}/${candidate}"
return 0
fi
if [[ -n ${RUNFILES_MANIFEST_FILE:-} ]]; then
resolved="$(
awk -v key="${candidate}" 'index($0, key " ") == 1 { print substr($0, length(key) + 2); exit }' \
"${RUNFILES_MANIFEST_FILE}"
)"
if [[ -n ${resolved} ]]; then
printf '%s\n' "${resolved}"
return 0
fi
fi
done
echo "Error: unable to resolve runfile: ${path}" >&2
exit 1
}
bun_path="$(resolve_runfile "${1:-}")"
version="$("${bun_path}" --version)"
if [[ ! ${version} =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "Unexpected bun version output: ${version}" >&2