Repository navigation
Make NuGet walk tests ignore the host package cache - #2037
Mikola Lysenko (mikolalysenko) wants to merge 2 commits into
Conversation
Two project-mode crawl tests that check an unscoped walk (solution_roots_and_unrestored_projects_keep_the_walk and an_uncovered_sub_project_keeps_the_walk) also crawl search root 3, the global packages folder from NUGET_PACKAGES / DOTNET_CLI_HOME / ~/.nuget/packages. They failed on any machine with a package in ~/.nuget/packages (#2023). They weren't #[serial] either, so they raced the serial tests that point NUGET_PACKAGES and HOME at their own warm folders: with a host package planted, the walk test passed or failed depending on which serial test ran alongside it. Run both crawls through a crawl_local helper. It points NUGET_PACKAGES at an empty tempdir under EnvGuard, and both tests are now #[serial]. Also move the two nuget_home env tests from bare set_var/remove_var onto EnvGuard, so a failed assertion can't leak the variable into later tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeRytjzpRh8AHn2i5Qh
|
bugbot run Generated by Claude Code |
Review follow-up. An empty global packages folder made the two walk tests stop checking that search root 3 is walked. crawl_local now seeds it with one package, global.only@1.0.0: unscoped walks must list it, and scoped crawls must leave it out. Dropping root 3 from crawl_roots now fails three tests. The four scoped crawl tests now also go through crawl_local and are #[serial]. They were still reading the host or a parallel test's global folder, and passed only because `seen` dedups by purl. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeRytjzpRh8AHn2i5Qh
|
bugbot run Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit d089d69. Configure here.
|
Labeled Ready for review by the burn-down agent.
Generated by Claude Code |
Final review briefWhat it does. A test-only fix for #2023. The project-mode NuGet crawl tests now point Risk: low. Only the Look here
Verified
Changes I made: none. Open questions: none. Auto-merge is armed, so approving sends this PR straight to the merge queue. Generated by Claude Code |
Fixes #2023.
Problem
crawlers::nuget_crawler::tests::solution_roots_and_unrestored_projects_keep_the_walkfails every time on a machine with any package in~/.nuget/packages. It passes in CI only because the runners' NuGet cache is empty. Issue #2023 has the repro.While reproducing it I found a second test with the same dependence,
an_uncovered_sub_project_keeps_the_walk. That one is also order-dependent: neither test was#[serial], so both ran alongside the serial tests in the same module that pointNUGET_PACKAGESandHOMEat their own warm folders. With one host package planted (~/.nuget/packages/zz.hostpkg/9.9.9), 30 loops ofcargo test -p socket-patch-core --lib nuget_crawleron the partial fix gave:solution_roots_…(left had an extrapkg:nuget/zz.hostpkg@9.9.9)an_uncovered_…, which passed only in runs where a concurrent serial test happened to haveNUGET_PACKAGESsetRoot cause
An unscoped project-mode crawl (a solution root, or a project with no parsed restore) always adds the global packages folder NuGet would restore into as search root 3 (
crawl_roots, viaglobal_packages_folder→nuget_home()). The tests built their packages in a tempshared-cachebut left that folder pointing at the process env and home, which belong to the host and to whichever serial test is running at the time.Fix (test-only)
The crawler itself doesn't change. The unscoped walk the tests pin (#427 / #1183) stays the same.
Not fixed here, left as follow-ups from `/code-review high`:
Proof
~/.nuget/packagesholdszz.hostpkg/9.9.9andnewtonsoft.json/13.0.3solution_roots_…FAILED every run,an_uncovered_…intermittent~/.nuget(CI-like)So in CI this is latent: no failure reproduced in 150 CI-like runs. The fix makes the tests hermetic for dev machines and removes the cross-test env race.
cargo clippy -p socket-patch-core --all-features -D warnings(CI's command) is clean, and rustfmt shows no diff on the touched file. With--all-targets, my local clippy reports 39 lints that main has too; none are in this file.Tests moved or removed
None. Every test still runs where it ran before (
testjobs, PR and merge queue).https://claude.ai/code/session_011f9aeRytjzpRh8AHn2i5Qh
Generated by Claude Code