Skip to content

Commit d6cb3a6

Browse files
chrisd8088hswong3i
authored andcommitted
t/t-checkout.sh: test exit code from checkout
In commit 8e9fbf4 of PR git-lfs#2626 we updated several commands, including "git lfs checkout" and "git lfs pull", to report an error if the Git LFS "clean" filter is not installed, and we added tests to validate this new behaviour in the same commit. Two of these tests, the "clone (without clean filter)" and "pull without clean filter" tests in our t/t-clone.sh and t/t-pull.sh test scripts, respectively, perform the appropriate Git LFS command and log its output to a file. They next confirm that the command's exit code was zero by checking the first element of the PIPESTATUS shell array variable. Next, they run a grep(1) command to confirm that the string "Git LFS is not installed" appears the output captured from Git LFS command. However, the third of these tests, the "checkout: without clean filter" test in our t/t-checkout.sh test script, reverses the order of its two checks, which means that the value in the PIPESTATUS shell array variable is only the exit code from the grep(1) command, and not the exit code from the preceding "git lfs checkout" command. Since we expect the "git lfs checkout" command to return a zero exit code (despite the warning message), the test inadvertently passes because the grep(2) command also runs successfully and returns zero. We therefore move the grep(2) command in the "checkout: without clean filter" test to follow the check of the PIPESTATUS array variable, matching the design of the other two related tests.
1 parent 47ccbff commit d6cb3a6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

t/t-checkout.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ begin_test "checkout: without clean filter"
178178
ls -al
179179

180180
git lfs checkout | tee checkout.txt
181-
grep "Git LFS is not installed" checkout.txt
182181
if [ "0" -ne "${PIPESTATUS[0]}" ]; then
183182
echo >&2 "fatal: expected checkout to succeed ..."
184183
exit 1
185184
fi
185+
grep "Git LFS is not installed" checkout.txt
186186

187187
contentsize=19
188188
contents_oid=$(calc_oid "something something")

0 commit comments

Comments
 (0)