Skip to content

omamobile-settings: core tests refuse to run with the real home - #930

Open
Somnius wants to merge 1 commit into
derekross:mainfrom
Somnius:settings-tests-home-guard-1119
Open

Somnius wants to merge 1 commit into
derekross:mainfrom
Somnius:settings-tests-home-guard-1119

Conversation

@Somnius

@Somnius Somnius commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@derekross the settings core tests write theme files under QDir::homePath() (tests/core_tests.cpp, the look tests write ~/.local/state/omarchy/current/theme). test/all points HOME at a temp fixture, so that's fine through the runner, but running the built settings-core-tests binary by hand uses your real home. I did that on my desktop on 11-18 and it overwrote my real theme with the test values ([font] base-size=18, the test colours), which I only noticed after the next reboot when the bar and icons came up bigger.

While fixing it I also found test/all passes the caller's XDG_STATE_HOME and XDG_DATA_HOME through, so even the runner isn't sealed when those are set.

What this does:

  • tests/home_guard.h runs before main() and exits 2 with a message pointing at packages/omamobile-settings/test/all (or tests/all) if HOME is unset, is your real home (from passwd), contains it, or isn't inside $TMPDIR (/tmp when unset). A fixture inside your home is fine as long as it's under TMPDIR, so CI with TMPDIR=$RUNNER_TEMP still works.
  • The same check for XDG_STATE_HOME, XDG_CONFIG_HOME, XDG_DATA_HOME and XDG_CACHE_HOME.
  • test/all now sets XDG_STATE_HOME and XDG_DATA_HOME to fixture paths too.

Tested: test/all passes, tools/pr-check origin/main is clean, and the path decision is two small functions I checked with a probe on made-up paths (11 cases, including equal, parent, inside home but in TMPDIR, outside TMPDIR). I never ran the binary against a real home to "prove" it. Not tested: your CI, it should pass since it uses mktemp -d under /tmp.

I didn't bump the version, leaving that to you.

Running settings-core-tests directly used the real HOME and overwrote
~/.local/state/omarchy/current/theme. A static guard now exits before
main() unless HOME is inside the temp dir and is not the user's home.
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.

1 participant