Repository navigation
Fix doc-pipeline test repo lookup across worktrees - #1607
PaperHammer (PaperHammer) wants to merge 2 commits into
Conversation
|
While verifying the fix, I noticed a gap in the existing test coverage. The test checks whether the returned directory contains Reactor.csproj, but both worktrees satisfy that check. If the lookup ever falls back to the process working directory, the existing test could still pass. I verified the fix with two worktrees by breaking only the snippet in the checkout that built the test assembly. The fixed test failed as expected and passed again after I restored the snippet. Would you consider it worth adding a process-isolated regression test in this PR, or would you prefer to track it as a follow-up? |
Alexandre Zollinger Chohfi (azchohfi)
left a comment
There was a problem hiding this comment.
Nice cleanup. Reusing RepoRootFinder is the right call and it also gets rid of the race with the FakeRepo fixtures that change the working directory. Two small notes inline.
|
|
||
| internal static class TestRepo | ||
| { | ||
| public static string Root => RepoRootFinder.FindRepoRoot() |
There was a problem hiding this comment.
Nothing in CI would catch a regression back to a working-directory-first lookup, since CI runs from the same checkout it builds in. The CLI does FindRepoRoot(Directory.GetCurrentDirectory()) ?? FindRepoRoot() in PackLocalCommand, so it's an easy copy-paste to undo this.
Could you add a small test that points the working directory at a temp folder containing src/Reactor/Reactor.csproj and checks that TestRepo.Root still resolves to the checkout around AppContext.BaseDirectory? It needs a non-parallel collection because the working directory is process-wide. Then the manual two-worktree steps in doc-pipeline.md could just point at the test.
| - Doc-pipeline tests locate the repository from their test output directory, so | ||
| snippet and documentation checks read the worktree that built them even when | ||
| the process working directory points into a sibling checkout (issue #1031). |
There was a problem hiding this comment.
Minor, this only covers test infra and the file asks for significant changes, so I'd drop it.
|
Thanks for the review and for suggesting the temporary-directory approach. I’ve addressed both comments in ef9391e. The new test runs in a non-parallel collection, points the process working directory at a temporary directory containing src/Reactor/Reactor.csproj, and checks that TestRepo.Root still resolves to the checkout that built the test assembly. I confirmed that it fails with CWD-first lookup and passes with the fix. I also replaced the manual two-worktree steps with a link to the test and removed the changelog entry. |
Summary
SourceSnippetSanityTestscan pass while readingUseMemoCells.csfrom a sibling worktree. This happens when the test assembly is built in one checkout and the process working directory points into another. A valid snippet in the second checkout can hide a broken snippet in the checkout under test.This PR makes the doc-pipeline tests share the existing repository finder so they resolve source files from the worktree that built the test assembly.
Changes
TestRepo.Rootand remove their duplicate directory walks.RepoRootFinder.csintoReactor.DocPipeline.Testsso the tests can reuse the finder without adding a CLI project dependency.TESTING.md, and record the fix inCHANGELOG.md.Repository lookup scope
RepoRootFinderwalks up fromAppContext.BaseDirectoryuntil it findssrc/Reactor/Reactor.csproj. Snippet and documentation checks then resolve their paths relative to that checkout.Linked issue / spec
Fixes #1031.
Test plan
SnapshotItemsfrom A's snippet while leaving B's snippet valid. The original test incorrectly passed. The fixed test failed at the expected assertion and passed after restoring A's snippet.SourceSnippetSanityTeststhrough the standard test runner.mainat7e3d0254.Reactor.Testssuite. 15,967 passed, 18 skipped, and 2 failed. BothCS1503suggestion failures were previously reproduced on cleanmainat4cd63979and documented in Deflake reconcile highlight lifecycle selftests #1503.git diff --check.Commands used for validation
Risk / breaking changes
The code change is scoped to repository lookup in the doc-pipeline test project. Repository-backed tests expect their output directory to sit under a checkout containing
src/Reactor/Reactor.csproj, which is the standard local and CI layout.