]> git.ipfire.org Git - thirdparty/git.git/commitdiff
add -i tests: mark "TODO" depending on GIT_TEST_ADD_I_USE_BUILTIN
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 14 Jun 2022 15:40:07 +0000 (17:40 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Jun 2022 17:30:30 +0000 (10:30 -0700)
Fix an issue that existed before 0527ccb1b55 (add -i: default to the
built-in implementation, 2021-11-30), but which became the default
with that change, we should not be marking tests that are known to
pass as "TODO" tests.

When GIT_TEST_ADD_I_USE_BUILTIN=1 was made the default we started
passing the tests added in 0f0fba2cc87 (t3701: add a test for advanced
split-hunk editing, 2019-12-06) and 1bf01040f0c (add -p: demonstrate
failure when running 'edit' after a split, 2015-04-16).

Thus we've been emitting this sort of output:

$ prove ./t3701-add-interactive.sh
./t3701-add-interactive.sh .. ok
All tests successful.

Test Summary Report
-------------------
./t3701-add-interactive.sh (Wstat: 0 Tests: 70 Failed: 0)
  TODO passed:   45, 47
Files=1, Tests=70,  2 wallclock secs ( 0.03 usr  0.00 sys +  0.86 cusr  0.33 csys =  1.22 CPU)
Result: PASS

Which isn't just cosmetic, but due to issues with
test_expect_failure (see [1]) we could e.g. be hiding something as bad
as a segfault in the new implementation. It makes sense catch that,
especially before we put out a release with the built-in "add -i", so
let's generalize the check we were already doing in 0527ccb1b55 with a
new "ADD_I_USE_BUILTIN" prerequisite.

1. https://lore.kernel.org/git/patch-1.7-4624abc2591-20220318T002951Z-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t2016-checkout-patch.sh
t/t3701-add-interactive.sh
t/test-lib.sh

index bc3f69b4b1d2fdbb942498a3f4826655de22a1ee..a5822e41af28112d44f8a2076804a5dd7d197904 100755 (executable)
@@ -4,7 +4,7 @@ test_description='git checkout --patch'
 
 . ./lib-patch-mode.sh
 
-if ! test_bool_env GIT_TEST_ADD_I_USE_BUILTIN true && ! test_have_prereq PERL
+if ! test_have_prereq ADD_I_USE_BUILTIN && ! test_have_prereq PERL
 then
        skip_all='skipping interactive add tests, PERL not set'
        test_done
index 94537a6b40a136f71d52a3e34552c1f1f7a298ac..fc26cb8bae8d93d49219bd2553ba83e1820b6b43 100755 (executable)
@@ -538,7 +538,15 @@ test_expect_success 'split hunk "add -p (edit)"' '
        ! grep "^+15" actual
 '
 
-test_expect_failure 'split hunk "add -p (no, yes, edit)"' '
+test_expect_success 'setup ADD_I_USE_BUILTIN check' '
+       result=success &&
+       if ! test_have_prereq ADD_I_USE_BUILTIN
+       then
+               result=failure
+       fi
+'
+
+test_expect_$result 'split hunk "add -p (no, yes, edit)"' '
        test_write_lines 5 10 20 21 30 31 40 50 60 >test &&
        git reset &&
        # test sequence is s(plit), n(o), y(es), e(dit)
@@ -562,7 +570,7 @@ test_expect_success 'split hunk with incomplete line at end' '
        test_must_fail git grep --cached before
 '
 
-test_expect_failure 'edit, adding lines to the first hunk' '
+test_expect_$result 'edit, adding lines to the first hunk' '
        test_write_lines 10 11 20 30 40 50 51 60 >test &&
        git reset &&
        tr _ " " >patch <<-EOF &&
index 736c6447ecfa9b20cd83a5f6c082512c5ef8d9d5..f5291ef56ef0aa7032396df368765ddbb0273bc7 100644 (file)
@@ -1759,6 +1759,10 @@ test_lazy_prereq SHA1 '
        esac
 '
 
+test_lazy_prereq ADD_I_USE_BUILTIN '
+       test_bool_env GIT_TEST_ADD_I_USE_BUILTIN true
+'
+
 # Ensure that no test accidentally triggers a Git command
 # that runs the actual maintenance scheduler, affecting a user's
 # system permanently.