Skip to content

test: adopt Bats, port bind and cwd tests as a proof of concept - #441

Merged
oxr463 merged 3 commits into
masterfrom
bats-proof-of-concept
Sep 18, 2026
Merged

oxr463 merged 3 commits into
masterfrom
bats-proof-of-concept

Conversation

@oxr463

@oxr463 oxr463 commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

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`.

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
oxr463 force-pushed the bats-proof-of-concept branch from 94a1558 to fef8653 Compare September 18, 2026 18:41
@sonarqubecloud

Copy link
Copy Markdown

@oxr463
oxr463 merged commit 901fe2f into master Sep 18, 2026
10 checks passed
@oxr463 oxr463 added this to the PRoot v5.5.0 milestone Sep 18, 2026
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