t2016: require the PERL prereq only when necessary

The scripted version of the interactive mode of `git add` still requires Perl, but the built-in version does not. Let's only require the PERL prereq if testing the scripted version. This addresses a long-standing NEEDSWORK added in 35166b1fb54 (t2016: add a NEEDSWORK about the PERL prerequisite, 2020-10-07). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Nov 30, 2021 at 14:14 UTC ed922dcab6ac3e2cc0a53f06e9044ba180ea0675
1 file changed +22 -20
t/t2016-checkout-patch.sh
+22 -20
@@ -4,7 +4,13 @@ test_description='git checkout --patch'
4
5 . ./lib-patch-mode.sh
6
7 -test_expect_success PERL 'setup' '
7 +if ! test_bool_env GIT_TEST_ADD_I_USE_BUILTIN false && ! test_have_prereq PERL
8 +then
9 + skip_all='skipping interactive add tests, PERL not set'
10 + test_done
11 +fi
12 +
13 +test_expect_success 'setup' '
14 mkdir dir &&
15 echo parent > dir/foo &&
16 echo dummy > bar &&
@@ -18,44 +24,40 @@ test_expect_success PERL 'setup' '
24
25 # note: bar sorts before dir/foo, so the first 'n' is always to skip 'bar'
26
21 -# NEEDSWORK: Since the builtin add-p is used when $GIT_TEST_ADD_I_USE_BUILTIN
22 -# is given, we should replace the PERL prerequisite with an ADD_I prerequisite
23 -# which first checks if $GIT_TEST_ADD_I_USE_BUILTIN is defined before checking
24 -# PERL.
25 -test_expect_success PERL 'saying "n" does nothing' '
27 +test_expect_success 'saying "n" does nothing' '
28 set_and_save_state dir/foo work head &&
29 test_write_lines n n | git checkout -p &&
30 verify_saved_state bar &&
31 verify_saved_state dir/foo
32 '
33
32 -test_expect_success PERL 'git checkout -p' '
34 +test_expect_success 'git checkout -p' '
35 test_write_lines n y | git checkout -p &&
36 verify_saved_state bar &&
37 verify_state dir/foo head head
38 '
39
38 -test_expect_success PERL 'git checkout -p with staged changes' '
40 +test_expect_success 'git checkout -p with staged changes' '
41 set_state dir/foo work index &&
42 test_write_lines n y | git checkout -p &&
43 verify_saved_state bar &&
44 verify_state dir/foo index index
45 '
46
45 -test_expect_success PERL 'git checkout -p HEAD with NO staged changes: abort' '
47 +test_expect_success 'git checkout -p HEAD with NO staged changes: abort' '
48 set_and_save_state dir/foo work head &&
49 test_write_lines n y n | git checkout -p HEAD &&
50 verify_saved_state bar &&
51 verify_saved_state dir/foo
52 '
53
52 -test_expect_success PERL 'git checkout -p HEAD with NO staged changes: apply' '
54 +test_expect_success 'git checkout -p HEAD with NO staged changes: apply' '
55 test_write_lines n y y | git checkout -p HEAD &&
56 verify_saved_state bar &&
57 verify_state dir/foo head head
58 '
59
58 -test_expect_success PERL 'git checkout -p HEAD with change already staged' '
60 +test_expect_success 'git checkout -p HEAD with change already staged' '
61 set_state dir/foo index index &&
62 # the third n is to get out in case it mistakenly does not apply
63 test_write_lines n y n | git checkout -p HEAD &&
@@ -63,21 +65,21 @@ test_expect_success PERL 'git checkout -p HEAD with change already staged' '
65 verify_state dir/foo head head
66 '
67
66 -test_expect_success PERL 'git checkout -p HEAD^...' '
68 +test_expect_success 'git checkout -p HEAD^...' '
69 # the third n is to get out in case it mistakenly does not apply
70 test_write_lines n y n | git checkout -p HEAD^... &&
71 verify_saved_state bar &&
72 verify_state dir/foo parent parent
73 '
74
73 -test_expect_success PERL 'git checkout -p HEAD^' '
75 +test_expect_success 'git checkout -p HEAD^' '
76 # the third n is to get out in case it mistakenly does not apply
77 test_write_lines n y n | git checkout -p HEAD^ &&
78 verify_saved_state bar &&
79 verify_state dir/foo parent parent
80 '
81
80 -test_expect_success PERL 'git checkout -p handles deletion' '
82 +test_expect_success 'git checkout -p handles deletion' '
83 set_state dir/foo work index &&
84 rm dir/foo &&
85 test_write_lines n y | git checkout -p &&
@@ -90,28 +92,28 @@ test_expect_success PERL 'git checkout -p handles deletion' '
92 # dir/foo. There's always an extra 'n' to reject edits to dir/foo in
93 # the failure case (and thus get out of the loop).
94
93 -test_expect_success PERL 'path limiting works: dir' '
95 +test_expect_success 'path limiting works: dir' '
96 set_state dir/foo work head &&
97 test_write_lines y n | git checkout -p dir &&
98 verify_saved_state bar &&
99 verify_state dir/foo head head
100 '
101
100 -test_expect_success PERL 'path limiting works: -- dir' '
102 +test_expect_success 'path limiting works: -- dir' '
103 set_state dir/foo work head &&
104 test_write_lines y n | git checkout -p -- dir &&
105 verify_saved_state bar &&
106 verify_state dir/foo head head
107 '
108
107 -test_expect_success PERL 'path limiting works: HEAD^ -- dir' '
109 +test_expect_success 'path limiting works: HEAD^ -- dir' '
110 # the third n is to get out in case it mistakenly does not apply
111 test_write_lines y n n | git checkout -p HEAD^ -- dir &&
112 verify_saved_state bar &&
113 verify_state dir/foo parent parent
114 '
115
114 -test_expect_success PERL 'path limiting works: foo inside dir' '
116 +test_expect_success 'path limiting works: foo inside dir' '
117 set_state dir/foo work head &&
118 # the third n is to get out in case it mistakenly does not apply
119 test_write_lines y n n | (cd dir && git checkout -p foo) &&
@@ -119,11 +121,11 @@ test_expect_success PERL 'path limiting works: foo inside dir' '
121 verify_state dir/foo head head
122 '
123
122 -test_expect_success PERL 'none of this moved HEAD' '
124 +test_expect_success 'none of this moved HEAD' '
125 verify_saved_head
126 '
127
126 -test_expect_success PERL 'empty tree can be handled' '
128 +test_expect_success 'empty tree can be handled' '
129 test_when_finished "git reset --hard" &&
130 git checkout -p $(test_oid empty_tree) --
131 '