Skip to content

Commit

Permalink
t/t-clone.sh: assert clean status when appropriate
Browse files Browse the repository at this point in the history
In commit caaa0f9 of PR git-lfs#2647 and
number of tests of the "git lfs clone" and "git lfs pull" commands
were enhanced so as check that after those commands are invoked,
a "git status" command returns a "working tree clean" message.
To perform these checks, a call to our assert_clean_status() shell
function was added to the tests.

In the case of the "cloneSSL" test, an assert_clean_status() call
was added, but left commented out; it was then uncommented in commit
e0eede1 of the same PR.  Unfortunately,
the call is made when the current working directory has not yet been
changed to that of the newly cloned repository's working tree, and
so will fail as it stands now.

However, as described in git-lfs#5658, the "cloneSSL" test and the "clone
ClientCert" tests in our t/t-clone.sh test script do not actually
run to completion, as a consequence of an improper check of the TRAVIS
variable (which is no longer used since we migrated our test suite to
GitHub Actions in PR git-lfs#3808).  This bug was already in place at the time
of PR git-lfs#2647, and so the assertions are never actually performed in
these tests.

We expect to address this problem in a subsequent commit in this PR,
and when we do so, the test "cloneSSL" test will fail because the
assert_clean_status() call is made without having changed the current
working directory to that of the cloned repository's working tree.

Therefore we move the assertion to the end of the block of checks
performed after the "pushd" shell command is used to change the
directory to that of the new clone's working tree.

We also take the opportunity to add the assert_clean_status() calls
to a number of other tests in the t/t-clone.sh script, so they are
all performing similar sets of checks.  This will help keep our
tests in closer aligment with each other.
  • Loading branch information
chrisd8088 committed Oct 7, 2024
1 parent 8e79b03 commit bed479e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion t/t-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ begin_test "cloneSSL"

newclonedir="testcloneSSL1"
git lfs clone "$SSLGITSERVER/$reponame" "$newclonedir" 2>&1 | tee lfsclone.log
assert_clean_status
grep "Cloning into" lfsclone.log
grep "Downloading LFS objects:" lfsclone.log
# should be no filter errors
Expand All @@ -157,6 +156,7 @@ begin_test "cloneSSL"
[ $(wc -c < "file2.dat") -eq 75 ]
[ $(wc -c < "file3.dat") -eq 30 ]
assert_hooks "$(dot_git_dir)"
assert_clean_status
popd


Expand Down Expand Up @@ -368,6 +368,7 @@ begin_test "clone with flags"
# confirm remote is called differentorigin
git remote get-url differentorigin
assert_hooks "$(dot_git_dir)"
assert_clean_status
popd
rm -rf "$newclonedir"

Expand All @@ -381,6 +382,9 @@ begin_test "clone with flags"
[ -e "$newclonedir/.git" ]
[ -d "$gitdir/objects" ]
assert_hooks "$gitdir"
pushd "$newclonedir"
assert_clean_status
popd
rm -rf "$newclonedir"
rm -rf "$gitdir"

Expand Down Expand Up @@ -442,6 +446,7 @@ begin_test "clone (with include/exclude args)"
[ "$(pointer $contents_a_oid 1)" = "$(cat dupe-a.dat)" ]
[ "$(pointer $contents_b_oid 1)" = "$(cat b.dat)" ]
assert_hooks "$(dot_git_dir)"
assert_clean_status
popd

local_reponame="clone_with_excludes"
Expand All @@ -452,6 +457,7 @@ begin_test "clone (with include/exclude args)"
[ "$(pointer $contents_a_oid 1)" = "$(cat a.dat)" ]
[ "b" = "$(cat b.dat)" ]
assert_hooks "$(dot_git_dir)"
assert_clean_status
popd
)
end_test
Expand Down Expand Up @@ -514,6 +520,7 @@ begin_test "clone (with .lfsconfig)"
assert_local_object "$contents_a_oid" 1
refute_local_object "$contents_b_oid"
assert_hooks "$(dot_git_dir)"
assert_clean_status
popd

echo "test: clone with lfs.fetchinclude in .lfsconfig, and args"
Expand All @@ -523,6 +530,7 @@ begin_test "clone (with .lfsconfig)"
refute_local_object "$contents_a_oid"
assert_local_object "$contents_b_oid" 1
assert_hooks "$(dot_git_dir)"
assert_clean_status
popd

popd
Expand All @@ -546,6 +554,7 @@ begin_test "clone (with .lfsconfig)"
assert_local_object "$contents_b_oid" 1
refute_local_object "$contents_a_oid"
assert_hooks "$(dot_git_dir)"
assert_clean_status
popd

echo "test: clone with lfs.fetchexclude in .lfsconfig, and args"
Expand All @@ -555,6 +564,7 @@ begin_test "clone (with .lfsconfig)"
assert_local_object "$contents_a_oid" 1
refute_local_object "$contents_b_oid"
assert_hooks "$(dot_git_dir)"
assert_clean_status
popd

popd
Expand Down Expand Up @@ -668,6 +678,7 @@ begin_test "clone with submodules"
# check everything is where it should be
cd $local_reponame
assert_hooks "$(dot_git_dir)"
assert_clean_status
# check LFS store and working copy
assert_local_object "$contents_root_oid" "${#contents_root}"
[ $(wc -c < "root.dat") -eq ${#contents_root} ]
Expand Down Expand Up @@ -719,6 +730,7 @@ begin_test "clone in current directory"
assert_local_object "$contents_oid" 8
assert_hooks "$(dot_git_dir)"
[ ! -f ./lfs ]
assert_clean_status
popd
)
end_test
Expand Down

0 comments on commit bed479e

Please sign in to comment.