Skip to content

Make stateful regression tests self-contained - #7402

Open
mdenesfe wants to merge 3 commits into
basecamp:quattrofrom
mdenesfe:fix/7121-strengthen-stateful-tests
Open

Make stateful regression tests self-contained#7402
mdenesfe wants to merge 3 commits into
basecamp:quattrofrom
mdenesfe:fix/7121-strengthen-stateful-tests

Conversation

@mdenesfe

Copy link
Copy Markdown

Fixes #7121.

Two stateful regression checks could pass using output produced by an earlier test case.

The monitor scaling test now clears the previous Hyprland evaluation output, verifies that exactly one command was emitted, and checks the relevant output and scale fields without depending on exact formatting.

The power profile tests now reset their call log through a shared helper before each command under test, ensuring every assertion observes a call produced by that specific scenario.

Tested with:

  • bash test/shell.d/monitor-scaling-test.sh
  • Bash syntax checks for both changed tests
  • git diff --check

The power profile test requires the project's Bash 5/GNU environment and cannot run fully under macOS's system Bash 3.2.

Copilot AI balanced review requested due to automatic review settings August 18, 2026 17:06

Copilot AI left a comment

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Improves shell test reliability by resetting captured command logs between calls and tightening monitor-scaling assertions to prevent false positives from accumulated output.

Changes:

  • Add a helper to clear the powerprofiles “calls” log and invoke it between test phases.
  • Clear Hyprctl eval output before running a scaling action, then assert exactly one command was emitted.
  • Replace a loose substring match with a more structured regex for the monitor scaling command output.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
test/shell.d/powerprofiles-set-test.sh Clears the calls log between invocations to make tail -n 1 assertions deterministic.
test/shell.d/monitor-scaling-test.sh Resets eval output and strengthens assertions about emitted monitor commands.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/shell.d/powerprofiles-set-test.sh Outdated
reset_calls_log
"$ROOT/bin/omarchy-powerprofiles-set" ac balanced
[[ $(<"$tmp_dir/state/ac") == "balanced" ]] || fail "power profile stores AC preference"
[[ $(tail -n 1 "$tmp_dir/calls") == "balanced" ]] || fail "power profile applies selected AC preference"
Comment thread test/shell.d/powerprofiles-set-test.sh Outdated

reset_calls_log
"$ROOT/bin/omarchy-powerprofiles-set" ac
[[ $(tail -n 1 "$tmp_dir/calls") == "balanced" ]] || fail "power profile restores AC preference"
Comment thread test/shell.d/powerprofiles-set-test.sh Outdated

reset_calls_log
"$ROOT/bin/omarchy-powerprofiles-set" ac
[[ $(tail -n 1 "$tmp_dir/calls") == "balanced" ]] || fail "battery preference does not replace AC preference"
Comment thread test/shell.d/powerprofiles-set-test.sh Outdated

reset_calls_log
ON_BATTERY=1 "$ROOT/bin/omarchy-powerprofiles-set"
[[ $(tail -n 1 "$tmp_dir/calls") == "performance" ]] || fail "autodetect restores battery preference"
Comment thread test/shell.d/powerprofiles-set-test.sh Outdated
rm "$tmp_dir/state/ac"
reset_calls_log
ON_BATTERY=0 "$ROOT/bin/omarchy-powerprofiles-set"
[[ $(tail -n 1 "$tmp_dir/calls") == "performance" ]] || fail "power profile uses performance as AC default"
Comment thread test/shell.d/powerprofiles-set-test.sh Outdated
"$ROOT/bin/omarchy-powerprofiles-set" ac power-saver
reset_calls_log
"$ROOT/bin/omarchy-powerprofiles-init"
[[ $(tail -n 1 "$tmp_dir/calls") == "power-saver" ]] || fail "init restores the autodetected preference"
Comment on lines +64 to +66
(( $(wc -l <"$eval_out") == 1 )) || fail "monitor scaling down emits exactly one monitor command"
grep -Eq 'output[[:space:]]*=[[:space:]]*"eDP-1".*scale[[:space:]]*=[[:space:]]*2[[:space:]]*}' "$eval_out" ||
fail "monitor scaling down snaps floating point 3x to 2x"
Copilot AI review requested due to automatic review settings August 18, 2026 17:11

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (2)

test/shell.d/monitor-scaling-test.sh:64

  • wc -l counts newline characters, not logical lines; if the stub writes a single command without a trailing newline, this will return 0 and incorrectly fail. Prefer a line-counting approach based on records (e.g., awk NR/END, or grep-based counting) that counts the last line even without a trailing newline.
(( $(wc -l <"$eval_out") == 1 )) || fail "monitor scaling down emits exactly one monitor command"

test/shell.d/monitor-scaling-test.sh:65

  • The regex can match scale as a substring of a longer identifier (e.g., rescale = 2), which can produce false positives. Tighten the pattern to require scale as its own token (e.g., start-of-line / delimiter before scale, or include expected command structure).
grep -Eq 'scale[[:space:]]*=[[:space:]]*2([[:space:],}]|$)' "$eval_out" ||
  fail "monitor scaling down snaps floating point 3x to 2x"

Copilot AI review requested due to automatic review settings August 18, 2026 17:13

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (1)

test/shell.d/monitor-scaling-test.sh:64

  • wc -l counts newline characters, not logical lines; if the stub writes a single command without a trailing newline, this will report 0 and fail even though exactly one command was emitted. Consider counting records in a way that treats a non-newline-terminated last line as a line (e.g., using awk 'END{print NR}' or a non-empty-line counter) to make the test robust.
(( $(wc -l <"$eval_out") == 1 )) || fail "monitor scaling down emits exactly one monitor command"

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.

Two test assertions read state they did not produce, so a no-op passes

2 participants