Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bin/omarchy-audio-tuning
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

set -uo pipefail

: "${OMARCHY_PATH:=/usr/share/omarchy}"

tunings_dir="$OMARCHY_PATH/default/audio/tunings"
config_home="${XDG_CONFIG_HOME:-$HOME/.config}"

Expand Down
2 changes: 2 additions & 0 deletions bin/omarchy-channel-current
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

set -euo pipefail

: "${OMARCHY_PATH:=/usr/share/omarchy}"

# Dev is a linked source checkout: OMARCHY_PATH points somewhere other than
# the package-backed install at /usr/share/omarchy. This takes precedence over
# the package channels, since the checkout overrides whatever is installed.
Expand Down
40 changes: 40 additions & 0 deletions test/shell.d/env-robustness-test.sh
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Audio failures can pass The test discards the audio command’s exit status. Because status prints Installed: no before 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.

Suggested change
out=$(bare_env "$ROOT/bin/omarchy-audio-tuning" status 2>&1) || true
out=$(bare_env "$ROOT/bin/omarchy-audio-tuning" status 2>&1) ||
fail "omarchy-audio-tuning status exits successfully" "$out"

Copy link
Copy Markdown
Author

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 variable crash, which is asserted on directly. A non-zero exit from other causes is out of scope here.

Copy link
Copy Markdown
Contributor

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_PATH crash, the explicit unbound variable assertion 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.md and .greptile/config.json.

[[ $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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Class-wide check is missing The new test runs only two commands; it never classifies the other bin/omarchy-* scripts that reference OMARCHY_PATH. As a result, adding another unguarded script will not fail this test, so the intended class-wide regression check is still absent.

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!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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