Repository navigation
Default OMARCHY_PATH in channel-current and audio-tuning; add env-robustness test (#8769) #9164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: quattro
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" | ||
|
|
||
| # omarchy-channel-current and omarchy-audio-tuning run under `set -u`, so a bare | ||
| # $OMARCHY_PATH dereference crashes with "unbound variable" when the variable is | ||
| # missing from the environment. Both now default it; run them with `env -i` to | ||
| # keep it that way. | ||
|
|
||
| tmp_dir=$(mktemp -d) | ||
| trap 'rm -rf "$tmp_dir"' EXIT | ||
| mkdir -p "$tmp_dir/bin" "$tmp_dir/home" | ||
|
|
||
| # A stub pacman sends channel detection to its package-backed "unknown" branch | ||
| # deterministically on any machine. | ||
| cat >"$tmp_dir/bin/pacman" <<'STUB' | ||
| #!/bin/bash | ||
| exit 1 | ||
| STUB | ||
| chmod +x "$tmp_dir/bin/pacman" | ||
|
|
||
| bare_env() { | ||
| env -i PATH="$tmp_dir/bin:/usr/bin:/bin" HOME="$tmp_dir/home" "$@" | ||
| } | ||
|
|
||
| out=$(bare_env "$ROOT/bin/omarchy-channel-current" 2>&1) || true | ||
| [[ $out != *"unbound variable"* ]] || | ||
| fail "omarchy-channel-current crashes on unset OMARCHY_PATH" "$out" | ||
| [[ $out == "unknown" ]] || | ||
| fail "omarchy-channel-current answers with the package-backed channel" "$out" | ||
| pass "omarchy-channel-current runs without OMARCHY_PATH in the environment" | ||
|
|
||
| out=$(bare_env "$ROOT/bin/omarchy-audio-tuning" status 2>&1) || true | ||
| [[ $out != *"unbound variable"* ]] || | ||
| fail "omarchy-audio-tuning crashes on unset OMARCHY_PATH" "$out" | ||
| [[ $out == *"Installed: no"* ]] || | ||
| fail "omarchy-audio-tuning status reports its tuning state" "$out" | ||
| pass "omarchy-audio-tuning status runs without OMARCHY_PATH in the environment" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentional. The sweep was removed per review (the list needed updating for every new script); this test only covers the two scripts this PR changes.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. Since the test is intentionally scoped to the two scripts changed by this PR, and the maintained inventory sweep was deliberately removed, the class-wide check I requested isn’t applicable here. I’ll withdraw this finding. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
statusprintsInstalled: nobefore its later checks, an error in those checks can still leave the expected text and make the test pass. Check that the command exits successfully as well as producing the expected output.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The failure this test guards is the
unbound variablecrash, which is asserted on directly. A non-zero exit from other causes is out of scope here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s fair. Since this test specifically guards the missing-
OMARCHY_PATHcrash, the explicitunbound variableassertion is the relevant contract; unrelated non-zero exits are out of scope. I withdraw the suggestion to assert a zero exit status.Tip: You can customize Greptile's behavior for this repo with
.greptile/rules.mdand.greptile/config.json.