Repository navigation
test: log fake tool arguments with printf instead of echo - #22
Merged
Merged
Conversation
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.
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.
Test-only portability fix.
The bug
Several fake tools in the bats tests write their argv with
echo "$@":Where
/bin/shis bash (Arch, and most developer machines),echoparses its first argument: the fake terminal is called with-eas its first argument (TERMARGS="-e"), soecho -e ...consumes it as an option and it never reachesterm.call.tgSgdbResolveTerminal: launches the resolver in the configured terminalthen fails itsgrep -q -- "-e"assertion. CI is unaffected because there/bin/shis dash.The fix
Use
printf '%s\n' "$*". It writes the same single, space-joined line for ordinary arguments, so the exact-match assertions inwatch.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 usedprintf.Testing
tests/run.shgreen on a machine where/bin/shis bash: 325 bats tests plus smoke, data and consistency checks. Before the change,tgSgdbResolveTerminalfailed locally while passing in CI.No version bump: test-only change, per CONTRIBUTING.