Skip to content

test: log fake tool arguments with printf instead of echo - #22

Merged
360900 merged 1 commit into
mainfrom
test-portable-echo-stubs
Oct 5, 2026
Merged

360900 merged 1 commit into
mainfrom
test-portable-echo-stubs

Conversation

@360900

@360900 360900 commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Test-only portability fix.

The bug

Several fake tools in the bats tests write their argv with echo "$@":

printf 'echo "$@" >> "%s"\n' "$LOG" > "$TOOL"

Where /bin/sh is bash (Arch, and most developer machines), echo parses its first argument: the fake terminal is called with -e as its first argument (TERMARGS="-e"), so echo -e ... consumes it as an option and it never reaches term.call. tgSgdbResolveTerminal: launches the resolver in the configured terminal then fails its grep -q -- "-e" assertion. CI is unaffected because there /bin/sh is dash.

The fix

Use printf '%s\n' "$*". It writes the same single, space-joined line for ordinary arguments, so the exact-match assertions in watch.bats (grep -qxF -e "--user daemon-reload") keep working, and it never interprets the arguments.

Touched: sgdbnames.bats (the fake terminal, both tests), sgdbart.bats (fake wget), watch.bats (fake systemctl). The other fakes already used printf.

Testing

tests/run.sh green on a machine where /bin/sh is bash: 325 bats tests plus smoke, data and consistency checks. Before the change, tgSgdbResolveTerminal failed locally while passing in CI.

No version bump: test-only change, per CONTRIBUTING.

The stubs write their argv with 'echo "$@"'. Where /bin/sh is bash
(Arch, and most developer machines), a first argument that looks like an
option is consumed by echo: the fake terminal is called with '-e' as its
first argument, so 'echo -e ...' treats it as an option and the argument
never reaches the log. The 'tgSgdbResolveTerminal' test then fails on its
grep for '-e', while CI (dash) passes.

printf '%s\n' "$*" writes the same single line for ordinary arguments,
keeps the exact-match assertions in watch.bats working, and never
interprets the arguments.

Test-only change, no version bump per CONTRIBUTING.
@360900
360900 merged commit 3aaabfc into main Oct 5, 2026
8 checks passed
@360900
360900 deleted the test-portable-echo-stubs branch October 26, 2026 12:30
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