-
Notifications
You must be signed in to change notification settings - Fork 473
Add functional regression tests for reset --mixed skip-worktree on hydrated placeholders #2018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,10 @@ | |
| namespace GVFS.FunctionalTests.Tests.GitCommands | ||
| { | ||
| /// <summary> | ||
| /// This class is used to reproduce corruption scenarios in the GVFS virtual projection. | ||
| /// Reproduces reported scenarios that corrupted the GVFS virtual projection or | ||
| /// gave results that did not match a normal git repo. Each test is a black-box | ||
| /// regression test: it runs the command sequence that exposed the problem and | ||
| /// compares the results with the control repo. | ||
| /// </summary> | ||
| [Category(Categories.GitCommands)] | ||
| [TestFixtureSource(typeof(GitRepoTests), nameof(GitRepoTests.ValidateWorkingTree))] | ||
|
|
@@ -76,6 +79,32 @@ public void ReproCherryPickRestoreCorruption() | |
| this.FilesShouldMatchCheckoutOfSourceBranch(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Regression test for a sequence of commands that a user ran and that | ||
| /// showed incorrect behavior: after "git blame" and "git reset --mixed", | ||
| /// GVFS did not report a changed file as modified. The control repo did. | ||
| /// | ||
| /// This is a black-box test. It does not assert why the behavior was wrong. | ||
| /// It only runs the same commands and compares the results with the | ||
| /// control repo. ResetMixedTests.ResetMixedClearsSkipWorktreeOnHydratedPlaceholder | ||
| /// asserts the conditions that cause the problem. | ||
| /// | ||
| /// The fix requires microsoft/git v2.55.0.vfs.0.3 or later. | ||
| /// | ||
| /// On the FunctionalTests/20201014 branch, Readme.md is the only file that | ||
| /// differs between HEAD and HEAD~1. | ||
| /// </summary> | ||
| [TestCase] | ||
| public void ReproResetMixedSkipWorktree() | ||
| { | ||
| this.ValidateGitCommand("blame Readme.md"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the deeper version of my finding 1 last round, and the one thing I'd still like changed. You've now documented the version dependency, but the precondition the test relies on is never asserted — so the test can go quietly toothless without ever going red. Per the root cause in microsoft/git#935, the pre-fix code only left Two one-liners pin both halves of the state the doc comment claims, and both have precedent in this suite: // Guarantee hydration rather than relying on blame's internals, and pin the
// "hydrated but not in ModifiedPaths" precondition the reset depends on.
this.Enlistment.GetVirtualPathTo("Readme.md").ShouldBeAFile(this.FileSystem).WithContents();
GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.FileSystem, "Readme.md");
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note This comment was drafted by an AI assistant and reviewed by Tyrie Vella (@tyrielv) before posting. Agreed, but I made this change in the new white-box test and left the repro unchanged.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verified, and this is the outcome I was after.
The key improvement is that hydration is now an explicit read rather than an incidental side effect of |
||
| this.ValidateGitCommand("checkout -b tests/functional/ReproResetMixedSkipWorktree"); | ||
|
|
||
| // Both repos must report Readme.md as modified. | ||
| this.ValidateGitCommand("reset HEAD~1"); | ||
| this.ValidateGitCommand("ls-files -v Readme.md"); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Reproduction of a reported issue: | ||
| /// Restoring a file after its parent directory was deleted fails with | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving this to
ResetMixedTests.cs— and could you say how it differs fromResetMixedAfterPrefetch?On placement:
ResetMixedTestsis configured identically to this fixture (enlistmentPerTest: true, sameTestFixtureSource(GitRepoTests.ValidateWorkingTree), sameCategories.GitCommands) and already holds sevenreset --mixedtests.CorruptionReproTestsis documented as "reproduce corruption scenarios in the GVFS virtual projection", and both of its existing tests link a VFSForGit projection-corruption issue (#1855, #1901). This one is areset --mixedbehavior guard for a git-side fix, so it reads like it belongs next to its siblings.The part I care more about:
ResetMixedTests.ResetMixedAfterPrefetch(lines 25-31) already doeswhich is hydrate-then-mixed-reset with the same output-and-status comparison against the control repo. From the outside that looks like the same scenario this PR is adding. Either it doesn't actually reach the buggy path — in which case knowing why is valuable, because it may be a hole worth closing in that test too — or there's real overlap here. I couldn't check it myself: the fixture branches live in the
ForTestsrepo, not this one, so I can't diffFunctionalTests/20201014_Conflict_TargetHEAD against HEAD~1. You can.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
This comment was drafted by an AI assistant and reviewed by Tyrie Vella (@tyrielv) before posting.
I kept this test in
CorruptionReproTestsbecause that class is for black-box regression tests. Each test runs a command sequence that exposed a real problem, without assumptions about the cause. The class doc comment now says this. I also addedResetMixedTests.ResetMixedClearsSkipWorktreeOnHydratedPlaceholder, a white-box test next to its siblings.About
ResetMixedAfterPrefetch: onFunctionalTests/20201014_Conflict_Target,HEADonly deletes 9 files fromHEAD~1(allDunderGVFlt_MoveFileTest/LongFileName). The reset adds index entries for files that are not on disk, which is the!file_exists()path that git already handled. So it never reaches the hydrated-placeholder case. The new white-box test uses a real content change (ChangeInTarget.txt, Target → Source).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified — and splitting this into a black-box repro plus a white-box test is a better answer than the one I asked for.
The class doc rewrite addresses my premise directly: I was reading the old "reproduce corruption scenarios in the GVFS virtual projection" wording, which is what made the placement look wrong. Defining the fixture as black-box regression tests makes the division of labour explicit, and the new test sits next to its siblings where I wanted it.
The
ResetMixedAfterPrefetchexplanation is exactly the distinction I was fishing for —HEADonly deleting files relative toHEAD~1means the reset adds index entries for files that aren't on disk, which is the!file_exists()path git already handled, so it never reaches the hydrated case. That's a real gap in the old test, now covered by using an actual content change. I couldn't check any of this myself: the fixture branches live in theForTestsrepo rather than this one. Thanks for running it down.