test: adopt Bats, port bind and cwd tests as a proof of concept - #441
Merged
Merged
Conversation
Per proposal #439: adopt Bats instead of a bespoke assertion/TAP layer, starting small. bind.bats ports directly from proot-rs's own tests/bind.bats: same tool, same behavior, no rootfs needed. cwd.bats covers the same -w/--cwd plus in-process chdir(2) ground, using this project's own pwd.c/chdir_getcwd.c instead of /bin/sh, since the minimal test/rootfs has no shell, unlike proot-rs's fuller test rootfs.
Runs both seccomp configurations, matching the existing test-suite matrix. Unlike the existing make -C test job, this doesn't get continue-on-error: it's new infrastructure, verified clean before merging, so a failure here is real.
SC2145: "command: $@" mixes a string prefix with array expansion inside one quoted string, which doesn't join args the way it looks like it does. Use $* instead, the correct form for a single joined string. SC2128: $BASH_SOURCE is an array; index it explicitly. status and output are set by bats' own run(), invisible to shellcheck, so disable SC2154 there with a comment explaining why.
oxr463
force-pushed
the
bats-proof-of-concept
branch
from
September 18, 2026 18:41
94a1558 to
fef8653
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Implements step 2 of #439's proposal: a small proof of concept before committing to adopting Bats project-wide.
`test/bind.bats` ports directly from proot-rs's own `tests/bind.bats`: same tool, same behavior, no custom rootfs needed. `test/cwd.bats` covers the same `-w`/`--cwd` and in-process `chdir(2)` ground as proot-rs's `tests/cwd.bats`, but uses this project's own `pwd.c`/`chdir_getcwd.c` instead of `/bin/sh`, since the minimal `test/rootfs` has no shell (proot-rs's is built from a fuller image).
`test/helper.bash` mirrors proot-rs's own helper: a `runp()` wrapper that echoes command/status/output to stderr on failure, plus `compile_c_static`/`compile_c_dynamic`/`check_if_command_exists`. Picks up the same `$PROOT`/`$ROOTFS` conventions `test/GNUmakefile` already uses.
Porting surfaced one real difference from proot-rs: proot(C)'s CLI doesn't support `--` as an end-of-options separator (proot-rs, via clap, does). Options end and the command begins at the first unrecognized argument.
Wired into `.github/workflows/pull-request.yml`, running under both seccomp configurations to match the existing test-suite matrix. Unlike the existing `make -C test` step, this one doesn't get `continue-on-error`: it's new, verified clean locally (both a Docker `gcc:13` build and a bare `ubuntu:24.04` image matching the actual GitHub-hosted runner), so a failure here is real.
`.gitignore` needed a couple of new exceptions to its blanket `test/*` rule for `.bats` files and `helper.bash`.