Skip to content

fix: run every busted test file and find main repo modules outside bazel run - #6

Merged
michaelboulton merged 2 commits into
mainfrom
fix/busted
Oct 25, 2026
Merged

michaelboulton merged 2 commits into
mainfrom
fix/busted

Conversation

@michaelboulton

Copy link
Copy Markdown
Owner

Fixes busted_test running only its first file, and lua_binary/fennel_binary failing to find their own modules when run directly from bazel-bin.

Click for implementation details
  • Resolve each busted test file with its own rlocation call; rlocation looks up only its first argument.
  • Resolve main repo modules in binary_wrapper.lua from the runfiles manifest when there is no runfiles tree, which is what a plain bazel build produces on Linux with Bazel 9. With a runfiles tree, add $RUNFILES_DIR/_main/?.lua and ?/init.lua so the working directory does not matter.
  • Start BASH_RLOCATION_FUNCTION with #!/usr/bin/env bash. The launchers had no shebang, so a launcher started by a program other than bash (e.g. env) ran under /bin/sh and exited 1 with no message. A #! line later in a script is a comment, so external users of the exported constant are unaffected.
  • Quote "$@" in all four launchers.
  • Add rules_shell 0.8.0 to examples/MODULE.bazel (already in the resolved graph) for two regression tests:
    • //lua/busted_test:test_maths_runs_all_files checks busted's TAP output reports both spec files.
    • //fennel/basic:main_outside_runfiles_test runs a fennel_binary from outside the runfiles tree, once with a runfiles tree and once with only a manifest. The test sandbox has no manifest, so the test builds one from the runfiles tree.
  • Both tests fail without the fixes (1..1, and module 'fennel.basic.example' not found).
  • Tested on Linux with Bazel 9.3.1 only; the Bazel 8 check was not run.
  • Both wrapper fixes assume the binary's own modules live in _main, as the wrapper's rlocation already does.

Resolves each test file with its own rlocation call, because rlocation looks up only its first argument and busted dropped every file after the first.

- Quote "$@" so arguments with spaces reach busted intact.

- Add a second spec to //lua/busted_test:test_maths and an sh_test that checks busted reports both.
Changes binary_wrapper.lua to resolve main repo modules from the runfiles manifest, and from $RUNFILES_DIR/_main with a runfiles tree, instead of only from paths relative to the working directory.

- Start every launcher with a bash shebang, so a launcher run by a program other than bash no longer falls back to /bin/sh and exits 1 silently.

- Quote "$@" in the lua_binary, fennel_binary and luaunit launchers.

- Add a fennel_binary example and an sh_test that runs it outside the runfiles tree, with a runfiles tree and with only a manifest.
@michaelboulton
michaelboulton merged commit a69ea4c into main Oct 25, 2026
1 check passed
@michaelboulton
michaelboulton deleted the fix/busted branch October 25, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant