fix: harden bun_test launcher args and test metadata
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
"""Rule for running test suites with Bun."""
|
||||
|
||||
|
||||
def _shell_quote(value):
|
||||
return "'" + value.replace("'", "'\"'\"'") + "'"
|
||||
|
||||
|
||||
def _bun_test_impl(ctx):
|
||||
toolchain = ctx.toolchains["//bun:toolchain_type"]
|
||||
bun_bin = toolchain.bun.bun_bin
|
||||
|
||||
src_args = " ".join(["\"{}\"".format(src.path) for src in ctx.files.srcs])
|
||||
src_args = " ".join([_shell_quote(src.path) for src in ctx.files.srcs])
|
||||
launcher = ctx.actions.declare_file(ctx.label.name)
|
||||
ctx.actions.write(
|
||||
output = launcher,
|
||||
@@ -20,9 +24,11 @@ fi
|
||||
if [[ -n "${{COVERAGE_DIR:-}}" ]]; then
|
||||
extra_args+=("--coverage")
|
||||
fi
|
||||
|
||||
exec "{}" test {} "${{extra_args[@]}}" "$@"
|
||||
""".format(bun_bin.path, src_args),
|
||||
exec "{bun_bin}" test {src_args} "${{extra_args[@]}}" "$@"
|
||||
""".format(
|
||||
bun_bin = bun_bin.path,
|
||||
src_args = src_args,
|
||||
),
|
||||
)
|
||||
|
||||
transitive_files = []
|
||||
|
||||
@@ -12,6 +12,7 @@ bun_test(
|
||||
bun_test(
|
||||
name = "failing_suite",
|
||||
srcs = ["failing.test.ts"],
|
||||
tags = ["manual"],
|
||||
target_compatible_with = [
|
||||
"@platforms//cpu:x86_64",
|
||||
"@platforms//os:linux",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { expect, test } from "bun:test";
|
||||
|
||||
test("failing suite", () => {
|
||||
test("intentionally fails for manual validation", () => {
|
||||
expect(1 + 1).toBe(3);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { expect, test } from "bun:test";
|
||||
|
||||
test("passing suite", () => {
|
||||
test("adds two numbers correctly", () => {
|
||||
expect(1 + 1).toBe(2);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user