Skip to content

Fix shell tests that read the developer's session, and add testing rules for agents - #16229

Merged
ryanrhughes merged 7 commits into
quattrofrom
test-housekeeping
Oct 22, 2026
Merged

ryanrhughes merged 7 commits into
quattrofrom
test-housekeeping

Conversation

@ryanrhughes

@ryanrhughes ryanrhughes commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

./test/shell had 10 failing files on a working desktop, and none of the failures came from code. Agents would run the suite, see red, rerun to find out why, and rerun again to check that the failures weren't theirs. Each failure turned out to be a test reading the developer's real session:

  • XDG directories: tests point HOME at a scratch directory, but a desktop session exports XDG_CONFIG_HOME, XDG_CACHE_HOME, XDG_DATA_HOME and XDG_STATE_HOME to the real home. The Elsewhen migration test ran rm -rf on the real ~/.cache/omacom-elsewhen, and provision-user and default-apps read and wrote the real config. base-test.sh now unsets all four.
  • Startup cursor: the test's fake environment fell through to the real one for variables it leaves unset, so a session's OMARCHY_STARTUP_CURSOR_THEME=default beat the GSettings theme the test expects. The fake environment now owns every cursor variable.
  • Remote session: the fixture captured grim -g "0,0 1x1" to raise a screencast event. With outputs placed away from the origin, nothing is at 0,0, so grim failed and no event came. It now captures a pixel at the first output's origin.
  • Background pixel tests: background-instant-reload and background-intro-clone sample the background layer off the first output, and on a working desktop they sample whatever window covers it. CI never runs them because they need a compositor. A new require_uncovered_background skips them, saying why, unless that output's workspace is empty.
  • i18n: every gate runs the test with I18N_STRUCTURAL=1, so the strict default only ran locally, where it fails whenever translations are waiting on the sync workflow. That is the normal state, 32 menu entries in 49 languages right now. The structural check is now the default, and I18N_STRICT=1 asks for the strict one. The workflows still set I18N_STRUCTURAL=1, which is now unused but harmless. Changing workflow files needs a token with the workflow scope, so removing it is left for a follow-up.

To stop the reruns:

  • Logs are kept: ./test/shell now leaves every file's log in a fresh omarchy-test-shell.* directory under $TMPDIR. It prints that directory at the end and each failed file's log next to it, so a failure can be read without running the suite again.

  • AGENTS.md rules: run your area's files directly, and the full suite at most once, at the end, and only for shared code. Write output to a log file instead of piping it through grep, head or tail. Rerun only after changing something. Check a failure in an untouched file once against the base branch, then report it. A live-session test that fails in a full run and passes alone is session noise.

  • When to add a test: AGENTS.md now says a test must catch a regression nothing else would and must fail without the change. Small declarative changes (a menu row, a config value, a string) get no test file of their own. It rules out tests that restate the implementation, test their own stubs or detect unrelated changes, and asks for tests in proportion to the change. This is the author's side of the review skill's test-bloat rubric.

docs/testing.md and docs/i18n.md describe the kept logs, the XDG reset, the background gate and the i18n modes.

Verified on this desktop, with windows open and outputs placed away from 0,0. Each previously failing file was run once with its log kept, and then one full ./test/shell run: 471 files completed without failures, 15 with skipped checks. The two background tests are among the 15. The cursor test also passes with the session's cursor variables unset.

🤖 Generated by Opus 5.5 in Claude Code.

@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge, with the existing non-blocking scratchpad issue still open.

Findings

  1. P2 Open scratchpad escapes background check ▶

Summary

The PR keeps shell-test logs and reduces interference from the developer’s desktop session.

  • Shell tests stay inside their scratch home and fake cursor session.
  • Compositor tests capture the display and skip covered background pixels.
  • Shell test runs keep logs and limit unnecessary reruns.
  • Translation checks use structural mode unless strict mode is requested.

Since the previous review, only the test-writing guidance in AGENTS.md changed. No new actionable issues were found.

Reviews (2) · Last reviewed commit: "Tell agents when a test is worth adding" · Reviewed by Greptile

Comment thread test/shell.d/base-test.sh
Comment on lines +110 to +111
workspace=$(hyprctl -j monitors | jq '.[0].activeWorkspace.id')
if (( $(hyprctl -j clients | jq --argjson ws "$workspace" '[.[] | select(.workspace.id == $ws)] | length') == 0 )); then

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 Open scratchpad escapes background check

When the first monitor's regular workspace is empty but special:scratchpad is open, this filter counts zero windows because the scratchpad has a different workspace ID. Both background tests then run against covered or dimmed pixels and can report false failures. Also check the monitor's specialWorkspace before allowing these tests to run.

@ryanrhughes ryanrhughes changed the title Stop shell tests from reading the developer's session, and stop agents rerunning them Fix shell tests that read the developer's session, and add testing rules for agents Oct 22, 2026
@ryanrhughes
ryanrhughes merged commit be54892 into quattro Oct 22, 2026
2 checks passed
@emirb emirb added this to the 4.5 milestone Nov 5, 2026
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.

2 participants