Repository navigation
Drive bootstrap.ps1's Kept-Tree Functions from the Test Suite, and Move a Tree Whole - #2496
Conversation
…ve a Tree Whole Extract the PowerShell loader's tree functions by AST and run them against a scratch directory, holding an entry with a real open handle on Windows, so the ownership check, marker-last removal, the swap and its rollback, cleanup's restore, and a kept-tree fetch are each exercised. The bash loader's two uncovered rollback paths get tests too. Driving the swap natively showed Move-Item does not fail whole where a file in the tree is held: it falls back to moving entry by entry, so the marker and every free entry left the live tree. Every tree move now goes through Move-Tree, a [IO.Directory]::Move rename that happens whole or not at all. Closes #1791 Closes #2492 Co-Authored-By: Claude Opus 5.5 <[email protected]>
… They Name Move-Tree renames through [IO.Directory]::Move, which resolves a path against the process directory rather than PowerShell's location, so a rooted but drive-relative -Dir such as C:hs would land the staging tree in one place and look for it in another. Resolve-Directory now requires a fully qualified path. The marker-last removal test now holds a file sorting after the marker, so a plain recursive removal fails it, the staging-removal cleanup test asserts the removal actually failed, and new tests cover the exception unwrap and the -Dir refusal. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Unix has no path that is rooted but not fully qualified, so IsPathRooted already refuses both inputs there and the test could not tell the fix from the code it replaced. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review issues remain.
0 open findings
What changed in this PR
Adds automated kept-tree coverage and makes bootstrap.ps1 tree moves atomic on Windows.
Changes:
- Adds PowerShell and Bash rollback tests.
- Replaces partial moves with whole-tree directory renames.
- Requires fully qualified
-Dirpaths.
| File | Description |
|---|---|
tests/test_bootstrap.py |
Adds PowerShell and rollback test coverage. |
host-setup/bootstrap.ps1 |
Implements atomic moves and stricter path validation. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2496 +/- ##
========================================
Coverage 58.50% 58.50%
========================================
Files 16 16
Lines 8066 8066
========================================
Hits 4719 4719
Misses 3347 3347
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…2497) ## Summary Promotes one change to `main`, from the Windows-host lane, verified on a native Windows 11 host. - [#2496](#2496): `tests/test_bootstrap.py` now drives `bootstrap.ps1`'s kept-tree functions, extracted by AST, holding an entry with a real open handle on Windows. Running them natively exposed a defect, and the loader is fixed: - **Tree moves:** they now go through `[IO.Directory]::Move`, so a move happens whole or not at all. PowerShell 7's `Move-Item` moved a tree holding an open file entry by entry, which emptied the live `skills-tree` and moved its ownership marker away. - **`-Dir`:** it must now be fully qualified, since that rename resolves a drive-relative path against the process directory. - **Bash rollback:** two tests cover the two `swap_in` rollback paths that had none. Closes #1791 Closes #2492 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
bootstrap.ps1's kept-tree handling had no automated test. Its ownership check, marker-last removal, swap and rollback, and cleanup's restore had only been checked by scratch probes on Linux. This change drives them fromtests/test_bootstrap.pythrough the loader's own functions, extracted by AST, astests/test_install_tools.pyalready does forinstall-tools.ps1.Running those functions natively on Windows exposed #2492, which this change also fixes:
Move-Tree: every tree move now goes through one helper that renames with[IO.Directory]::Move, so a move happens whole or not at all. When a held file stops the directory rename, PowerShell 7'sMove-Iteminstead moves the tree entry by entry. That moves the ownership marker and every free entry out of the liveskills-treeand leaves only the held file behind. The loader's swap ordering assumes a rename either completes or does nothing, andMove-Itembreaks that.Resolve-Directory: it now requires a fully qualified-Dir.[IO.Directory]::Moveresolves a path against the process directory rather than PowerShell's location, so a rooted but drive-relative-Dirsuch asC:hswould be read in two places. Every form the old check accepted, UNC and\?\included, is still accepted.TestPowerShellKeptTreeHandling: 19 cases, each against a scratch directory. An entry a case locks is held by a realFileShare.Nonehandle on Windows and a read-only directory elsewhere. The download and thetarare stubbed for the fetch cases. Four cases depend on Windows behavior and skip elsewhere: a held file blocking a rename, a lone held file beside the marker, and a path that is rooted but not fully qualified.TestKeptTreeHandling: two new cases coverswap_in's rollback succeeding and failing, the two bash paths Drive the PowerShell Loader's Kept-Tree Functions from the Test Suite #1791 names as uncovered.Closes #1791 and #2492 once promoted.
Verification
python3 -m unittest tests.test_bootstrapruns 58 tests, OK, 21 skipped (the Linux-only bash cases).TestKeptTreeHandling, the two new cases included, runs 12 tests, OK.Move-Itemrestored, the two held-file swap and cleanup cases fail on a split tree. Removing the marker-last removal, the exception unwrap, or the fully-qualified check each fails its own case.ruff,mypyand PSScriptAnalyzer are clean.commentslabel is on this PR for theMove-Treeheader comment. CI is Linux-only, so that comment is what keeps a later edit from going back toMove-Item.local-strict-reviewran three rounds:-Dir, a marker test that passed vacuously, a cleanup test missing its assertion, and the untested unwrap. All four are fixed in 9d10170.-Dirtest was vacuous on Linux. It is fixed in 47ba386.-Dirvalidation gaps outside this diff are filed as Canonicalize -Dir in bootstrap.ps1 Before Refusing a Drive or Share Root #2495.🤖 Generated with Claude Code