Adjust test helpers and tests related to path filtering#4960
Merged
chrisd8088 merged 7 commits intogit-lfs:mainfrom Apr 25, 2022
Merged
Adjust test helpers and tests related to path filtering#4960chrisd8088 merged 7 commits intogit-lfs:mainfrom
chrisd8088 merged 7 commits intogit-lfs:mainfrom
Conversation
The internal parseLogOutputToPointers() function was used only by logPreviousSHAs() and only until commit d8ca610 of PR git-lfs#1743 in 2016, so we can remove it now.
Prior to making changes in the "git lfs prune" command's implementation in subsequent PRs, we first remove a bit of spurious whitespace, just to improve consistency between similar functions.
The assert_pointer() and refute_pointer() test helper functions use grep to match specific lines of output from "git ls-tree". However, while assert_pointer() matches with fixed patterns by using grep's -F option, refute_pointer() does not. This difference was introduced in commit fc421da of PR git-lfs#3756, so we update refute_pointer() here to match. In a subsequent PR we will also need to ensure that the file paths we provide as arguments to these functions (specifically, to assert_pointer()) do not match just any part of the paths output by "git ls-tree", but only at the start of the path. That is, "a.bin" should match "a.bin" but not "foo/a.bin". Because the output from "git ls-tree" is space-separated, we prepend a space to our fixed patterns so we match against the start of the file path. This has the limitation that if a test has a file named "foo a.bin", and calls one of these functions with just the filename "a.bin", it will incorrectly match the filename with a space. However, at present only one of our tests that calls either of these functions, specifically the "track: escaped glob pattern with spaces in .gitattributes" test in t/t-track.sh, has a filename with a space in it, and does not create any additional files which might be confused by that filename.
In our "fsck detects invalid objects" test of the "git lfs fsck" command we currently only use files in the top-level directory for which we then corrupt or remove the corresponding Git LFS object files. In a subsequent PR we will add a parallel test which checks that the "lfs.fetchexclude" option is supported for this command, specifically by excluding files in a subdirectory. For the primary test, then, we want to demonstrate normal behaviour without path-based exclusions, so we add files in a subdirectory to our existing test and ensure their corruption is detected.
In subsequent PRs we expect to expand and revise our tests of the "git lfs prune" command, so we first remove some spurious whitespace, just to improve consistency between the tests.
We revise some of the comments in the "prune keep unpushed" test to clarify their meaning before we add additional checks to this test. We also drop an unused "git lfs prune --dry-run" invocation since we are not testing its output and therefore it serves no purpose in the test.
9814d7e to
d85d28d
Compare
bk2204
approved these changes
Apr 25, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In preparing a PR to address #4945 and adding tests to ensure that issue does not recur, a number of problems with our tests, test helpers, and the implementation of the
git lfs prunecommand were exposed by the new tests and checks. These will be resolved in a series of forthcoming PRs.As preparation, we first make a number of small adjustments to our test suite, adding additional checks to the
"fsck detects invalid objects"test int/t-fsck.sh, removing whitespace and revising comments for greater clarity, and changing theassert_pointer()andrevise_pointer()test helper functions to be consistent with each other again and to apply a stricter match for file paths. We also remove one unused function from the Go codebase.This PR may be most easily reviewed commit-by-commit, mostly because the individual commit descriptions provide detailed context on each change. The key changes are:
The
assert_pointer()andrefute_pointer()test helper functions usegrepto match specific lines of output fromgit ls-tree. However, whileassert_pointer()matches with fixed patterns by usinggrep's-Foption,refute_pointer()does not. This difference was introduced in commit fc421da of PR Provide an option to track to handle paths literally #3756, so we updaterefute_pointer()to match.In a subsequent PR we will also need to ensure that the file paths we provide as arguments to these functions (specifically, to
assert_pointer()) do not match just any part of the paths output bygit ls-tree, but only at the start of the path. That is,a.binshould matcha.binbut notfoo/a.bin. Because the output fromgit ls-treeis space-separated, we prepend a space to our fixed patterns so we match against the start of the file path.This has the limitation that if a test has a file named
foo a.bin, and calls one of these functions with just the filenamea.bin, it will incorrectly match the filename with a space. However, at present only one of our tests that calls either of these functions, specifically the"track: escaped glob pattern with spaces in .gitattributes"test int/t-track.sh, has a filename with a space in it, and does not create any additional files which might be confused by that filename.In our
"fsck detects invalid objects"test of thegit lfs fsckcommand we currently only use files in the top-level directory for which we then corrupt or remove the corresponding Git LFS object files. In a subsequent PR we will add a parallel test which checks that thelfs.fetchexcludeoption is supported for this command, specifically by excluding files in a subdirectory. For the primary test, then, we want to demonstrate normal behaviour without path-based exclusions, so we add files in a subdirectory to our existing test and ensure their corruption is detected.The internal
parseLogOutputToPointers()function was used only by thelogPreviousSHAs()function and only until commit d8ca610 of PR Gitscanner callbacks master #1743 in 2016, so we remove it now.