Skip to content

test(cli): remove the delegation, discussion, skill and plugin test directories when each test ends - #795

Merged
ajianaz merged 6 commits into
developfrom
test/testdir-cli-unit-a
Nov 15, 2026
Merged

ajianaz merged 6 commits into
developfrom
test/testdir-cli-unit-a

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What

The tole-cli unit tests of delegation/, discuss/, skill/ and plugin/ use TestDir (from #789) instead of leaking their directories. No production code changes.

Why

Refs #781: tole-ddecide-*, tole-dhost-*, tole-discuss-*, tole-delegate-*, tole-dapprover-*, tole-aowner-*, tole-sdeleg-*, tole-plugin-cmd-*, tole-drafts-cli-*, tole-curator-cli-* and friends.

Changes

  • 18 files under crates/tole-cli/src/{delegation,discuss,skill,plugin}. Fixtures that return a value built over a scratch directory (a DiscussionLog, a Driver, a draft store, a Delegator) now return the guard with it, or hold it in a field; a guard dropped on return would have removed the directory and the code under test recreated it, which is the leak again.
  • delegation/approver_tests.rs: the fixture's nap hook holds a clone of the fixture (a reference cycle that never drops); the clone does not own the directory, the original does.
  • delegation/delegate_tests.rs: the tests start detached fake tole shells. The workspace root is a Root guard that kills them (pkill -9 -f <root>) before the directory goes, and the fake script no longer recreates a removed root. The data dir shared by all tests of the process is named shared-delegate-data-* and swept when older than six hours (a per-test guard cannot own it; it holds one small directory per recent run and is not tole-*).
  • 18 files, 216 added and 157 removed lines.

Testing

  • cargo test -p tole-cli --lib with a private TMPDIR (564 tests): no tole-*/cora-* left from these tests. The delegation tests were run three times in a row to check the child handling is stable.
  • Before (baseline run on develop, entries matched by prefix): about 249 entries (33.9 MB) of these families.
  • cargo fmt --all, cargo clippy --workspace --all-targets -- -D warnings: clean.

Refs #781

Refs #781. Adds TestDir (unique scratch directory removed on drop, also on panic, robust to read-only trees, TOLE_KEEP_TEST_DIRS=1 and keep() escape hatches) and ChildGuard (kill and reap a child before its directory goes) to tole-core and tole-cli, for integration tests and unit tests. No test is converted yet.
Refs #781. WorkDir creates <root>/w inside a TestDir, so work.with_extension("home") lands in the same removed root.
…irectories when each test ends

Refs #781. Fixtures that hand a path-derived value to the code under test now own their directory (a guard field or a returned guard). The delegation tests kill the detached fake tole shells before the root goes. The data dir shared by all delegate tests is named shared-delegate-data-* and swept when older than six hours.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

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