Skip to content

fork-kit/cleaner: tests use their own home folder, never the runner's - #1458

Merged
scuttletoby merged 1 commit into
mainfrom
test/cleaner-report-hermetic-home
Nov 30, 2026
Merged

scuttletoby merged 1 commit into
mainfrom
test/cleaner-report-hermetic-home

Conversation

@scuttletoby

Copy link
Copy Markdown
Owner

Command.test_the_command_reads_the_machine_file (report.test.py) ran fork-cleaner report against the real home folder of the user running the tests. The command reads its config from the machine file, and Config then took the home folder from the password database, ignoring the fixture's HOME. On a machine with less free disk than report.warnFreeGB (60 GB by default) the report walks the whole home for its LOW DISK line, so the test hung for many minutes.

Change

  • config.HOME: a tests-only hook like MACHINE_FILE. When set, Config uses it as the home folder. Production leaves it None, so nothing changes there.
  • cleaner_fixture.Case.setUp sets it to the test's own temp home for every cleaner test. That covers the report test above and the other command tests that go through the machine file (engine plan/run, daily compare/daily/plan). Those read cfg.home too, though they don't walk it. No cleaner test reads the runner's real home now. (facts.read_units already used ~, which honours the fixture's HOME.)
  • New failing-first test, Command.test_the_command_measures_the_tests_own_home_and_not_the_runners. It sets warnFreeGB very high so the LOW DISK walk always runs, then checks that config.load().home and the folder the report names are the test's own home.

Before / after

The existing command test was timed with its machine file set to warnFreeGB: 100000, which acts like a low-disk runner:

  • before: still running when the 10-minute timeout killed it (exit 124)
  • after: that test and the new one together take 0.015 s

Without the fix, the new test fails at once: '<real home>' != '<temp>/home'.

report.test.py (40 tests), engine.test.py (55) and daily.test.py (28) all pass locally. I did not add a red-check mutation for the hook on purpose: the mutated copy would walk the runner's real home, which is the hang this PR removes.

🤖 Generated with Claude Code

A command reads its config from the machine file, and Config then took the
home folder from the password database, not the test's HOME. So the report
command tests measured the runner's real home, and on a machine with less
free disk than report.warnFreeGB (60 GB) walked all of it for many minutes.

config.HOME (tests only, like MACHINE_FILE) names the home instead; the
shared fixture sets it to the test's own temp home for every cleaner test.
A new report test checks the command's home is the test's own.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby scuttletoby added the fork:merge-ready Merge conveyor: lenses done, merge when green (PRs) label Nov 30, 2026
@scuttletoby
scuttletoby merged commit 637b339 into main Nov 30, 2026
27 checks passed
@scuttletoby
scuttletoby deleted the test/cleaner-report-hermetic-home branch November 30, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork:merge-ready Merge conveyor: lenses done, merge when green (PRs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant