Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2005 Junio C Hamano |
| 4 | # |
| 5 | |
| 6 | test_description='Test the very basics part #1. |
| 7 | |
| 8 | The rest of the test suite does not check the basic operation of git |
| 9 | plumbing commands to work very carefully. Their job is to concentrate |
| 10 | on tricky features that caused bugs in the past to detect regression. |
| 11 | |
| 12 | This test runs very basic features, like registering things in cache, |
| 13 | writing tree, etc. |
| 14 | |
| 15 | Note that this test *deliberately* hard-codes many expected object |
| 16 | IDs. When object ID computation changes, like in the previous case of |
| 17 | swapping compression and hashing order, the person who is making the |
| 18 | modification *should* take notice and update the test vectors here. |
| 19 | ' |
Junio C Hamano | eea4206 | 2005-12-10 20:55:32 -0800 | [diff] [blame] | 20 | |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 21 | . ./test-lib.sh |
Ævar Arnfjörð Bjarmason | 866a301 | 2021-07-22 00:57:40 +0200 | [diff] [blame] | 22 | . "$TEST_DIRECTORY"/lib-subtest.sh |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 23 | |
Denton Liu | 8cb7980 | 2019-11-13 16:52:15 -0800 | [diff] [blame] | 24 | try_local_xy () { |
| 25 | local x="local" y="alsolocal" && |
| 26 | echo "$x $y" |
Michael Haggerty | 01d3a52 | 2017-10-26 10:18:53 +0200 | [diff] [blame] | 27 | } |
| 28 | |
Jeff King | 7f0b590 | 2019-08-08 05:37:33 -0400 | [diff] [blame] | 29 | # Check whether the shell supports the "local" keyword. "local" is not |
Michael Haggerty | 01d3a52 | 2017-10-26 10:18:53 +0200 | [diff] [blame] | 30 | # POSIX-standard, but it is very widely supported by POSIX-compliant |
Jeff King | 7f0b590 | 2019-08-08 05:37:33 -0400 | [diff] [blame] | 31 | # shells, and we rely on it within Git's test framework. |
Michael Haggerty | 01d3a52 | 2017-10-26 10:18:53 +0200 | [diff] [blame] | 32 | # |
Jeff King | 7f0b590 | 2019-08-08 05:37:33 -0400 | [diff] [blame] | 33 | # If your shell fails this test, the results of other tests may be |
| 34 | # unreliable. You may wish to report the problem to the Git mailing |
| 35 | # list <git@vger.kernel.org>, as it could cause us to reconsider |
| 36 | # relying on "local". |
Michael Haggerty | 01d3a52 | 2017-10-26 10:18:53 +0200 | [diff] [blame] | 37 | test_expect_success 'verify that the running shell supports "local"' ' |
| 38 | x="notlocal" && |
Denton Liu | 8cb7980 | 2019-11-13 16:52:15 -0800 | [diff] [blame] | 39 | y="alsonotlocal" && |
| 40 | echo "local alsolocal" >expected1 && |
| 41 | try_local_xy >actual1 && |
Michael Haggerty | 01d3a52 | 2017-10-26 10:18:53 +0200 | [diff] [blame] | 42 | test_cmp expected1 actual1 && |
Denton Liu | 8cb7980 | 2019-11-13 16:52:15 -0800 | [diff] [blame] | 43 | echo "notlocal alsonotlocal" >expected2 && |
| 44 | echo "$x $y" >actual2 && |
Michael Haggerty | 01d3a52 | 2017-10-26 10:18:53 +0200 | [diff] [blame] | 45 | test_cmp expected2 actual2 |
| 46 | ' |
| 47 | |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 48 | ################################################################ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 49 | # git init has been done in an empty repository. |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 50 | # make sure it is empty. |
| 51 | |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 52 | test_expect_success '.git/objects should be empty after git init in an empty repo' ' |
| 53 | find .git/objects -type f -print >should-be-empty && |
| 54 | test_line_count = 0 should-be-empty |
| 55 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 56 | |
Linus Torvalds | 9106c09 | 2005-10-09 02:30:17 -0700 | [diff] [blame] | 57 | # also it should have 2 subdirectories; no fan-out anymore, pack, and info. |
| 58 | # 3 is counting "objects" itself |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 59 | test_expect_success '.git/objects should have 3 subdirectories' ' |
| 60 | find .git/objects -type d -print >full-of-directories && |
| 61 | test_line_count = 3 full-of-directories |
| 62 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 63 | |
| 64 | ################################################################ |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 65 | # Test harness |
| 66 | test_expect_success 'success is reported like this' ' |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 67 | : |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 68 | ' |
Ævar Arnfjörð Bjarmason | 7b90511 | 2010-08-19 16:08:12 +0000 | [diff] [blame] | 69 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 70 | test_expect_success 'subtest: 3 passing tests' ' |
| 71 | write_and_run_sub_test_lib_test full-pass <<-\EOF && |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 72 | for i in 1 2 3 |
| 73 | do |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 74 | test_expect_success "passing test #$i" "true" |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 75 | done |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 76 | test_done |
| 77 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 78 | check_sub_test_lib_test full-pass <<-\EOF |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 79 | > ok 1 - passing test #1 |
| 80 | > ok 2 - passing test #2 |
| 81 | > ok 3 - passing test #3 |
| 82 | > # passed all 3 test(s) |
| 83 | > 1..3 |
| 84 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 85 | ' |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 86 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 87 | test_expect_success 'subtest: 2/3 tests passing' ' |
| 88 | write_and_run_sub_test_lib_test_err partial-pass <<-\EOF && |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 89 | test_expect_success "passing test #1" "true" |
| 90 | test_expect_success "failing test #2" "false" |
| 91 | test_expect_success "passing test #3" "true" |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 92 | test_done |
| 93 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 94 | check_sub_test_lib_test partial-pass <<-\EOF |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 95 | > ok 1 - passing test #1 |
| 96 | > not ok 2 - failing test #2 |
| 97 | # false |
| 98 | > ok 3 - passing test #3 |
| 99 | > # failed 1 among 3 test(s) |
| 100 | > 1..3 |
| 101 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 102 | ' |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 103 | |
Ævar Arnfjörð Bjarmason | bbfbcd2 | 2022-03-23 21:51:31 +0100 | [diff] [blame] | 104 | test_expect_success 'subtest: --immediate' ' |
| 105 | run_sub_test_lib_test_err partial-pass \ |
| 106 | --immediate && |
| 107 | check_sub_test_lib_test_err partial-pass \ |
| 108 | <<-\EOF_OUT 3<<-EOF_ERR |
| 109 | > ok 1 - passing test #1 |
| 110 | > not ok 2 - failing test #2 |
| 111 | > # false |
| 112 | > 1..2 |
| 113 | EOF_OUT |
| 114 | EOF_ERR |
| 115 | ' |
| 116 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 117 | test_expect_success 'subtest: a failing TODO test' ' |
| 118 | write_and_run_sub_test_lib_test failing-todo <<-\EOF && |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 119 | test_expect_success "passing test" "true" |
| 120 | test_expect_failure "pretend we have a known breakage" "false" |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 121 | test_done |
| 122 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 123 | check_sub_test_lib_test failing-todo <<-\EOF |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 124 | > ok 1 - passing test |
| 125 | > not ok 2 - pretend we have a known breakage # TODO known breakage |
| 126 | > # still have 1 known breakage(s) |
| 127 | > # passed all remaining 1 test(s) |
| 128 | > 1..2 |
| 129 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 130 | ' |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 131 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 132 | test_expect_success 'subtest: a passing TODO test' ' |
| 133 | write_and_run_sub_test_lib_test passing-todo <<-\EOF && |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 134 | test_expect_failure "pretend we have fixed a known breakage" "true" |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 135 | test_done |
| 136 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 137 | check_sub_test_lib_test passing-todo <<-\EOF |
Adam Spiers | b73d9a2 | 2012-12-16 18:28:15 +0000 | [diff] [blame] | 138 | > ok 1 - pretend we have fixed a known breakage # TODO known breakage vanished |
| 139 | > # 1 known breakage(s) vanished; please update test(s) |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 140 | > 1..1 |
| 141 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 142 | ' |
Adam Spiers | 565b6fa | 2012-12-16 18:28:13 +0000 | [diff] [blame] | 143 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 144 | test_expect_success 'subtest: 2 TODO tests, one passin' ' |
| 145 | write_and_run_sub_test_lib_test partially-passing-todos <<-\EOF && |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 146 | test_expect_failure "pretend we have a known breakage" "false" |
| 147 | test_expect_success "pretend we have a passing test" "true" |
| 148 | test_expect_failure "pretend we have fixed another known breakage" "true" |
Adam Spiers | b73d9a2 | 2012-12-16 18:28:15 +0000 | [diff] [blame] | 149 | test_done |
| 150 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 151 | check_sub_test_lib_test partially-passing-todos <<-\EOF |
Adam Spiers | b73d9a2 | 2012-12-16 18:28:15 +0000 | [diff] [blame] | 152 | > not ok 1 - pretend we have a known breakage # TODO known breakage |
| 153 | > ok 2 - pretend we have a passing test |
| 154 | > ok 3 - pretend we have fixed another known breakage # TODO known breakage vanished |
| 155 | > # 1 known breakage(s) vanished; please update test(s) |
| 156 | > # still have 1 known breakage(s) |
| 157 | > # passed all remaining 1 test(s) |
| 158 | > 1..3 |
| 159 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 160 | ' |
Adam Spiers | b73d9a2 | 2012-12-16 18:28:15 +0000 | [diff] [blame] | 161 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 162 | test_expect_success 'subtest: mixed results: pass, failure and a TODO test' ' |
| 163 | write_and_run_sub_test_lib_test_err mixed-results1 <<-\EOF && |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 164 | test_expect_success "passing test" "true" |
| 165 | test_expect_success "failing test" "false" |
| 166 | test_expect_failure "pretend we have a known breakage" "false" |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 167 | test_done |
| 168 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 169 | check_sub_test_lib_test mixed-results1 <<-\EOF |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 170 | > ok 1 - passing test |
| 171 | > not ok 2 - failing test |
| 172 | > # false |
| 173 | > not ok 3 - pretend we have a known breakage # TODO known breakage |
| 174 | > # still have 1 known breakage(s) |
| 175 | > # failed 1 among remaining 2 test(s) |
| 176 | > 1..3 |
| 177 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 178 | ' |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 179 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 180 | test_expect_success 'subtest: mixed results: a mixture of all possible results' ' |
| 181 | write_and_run_sub_test_lib_test_err mixed-results2 <<-\EOF && |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 182 | test_expect_success "passing test" "true" |
| 183 | test_expect_success "passing test" "true" |
| 184 | test_expect_success "passing test" "true" |
| 185 | test_expect_success "passing test" "true" |
| 186 | test_expect_success "failing test" "false" |
| 187 | test_expect_success "failing test" "false" |
| 188 | test_expect_success "failing test" "false" |
| 189 | test_expect_failure "pretend we have a known breakage" "false" |
| 190 | test_expect_failure "pretend we have a known breakage" "false" |
| 191 | test_expect_failure "pretend we have fixed a known breakage" "true" |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 192 | test_done |
| 193 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 194 | check_sub_test_lib_test mixed-results2 <<-\EOF |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 195 | > ok 1 - passing test |
| 196 | > ok 2 - passing test |
| 197 | > ok 3 - passing test |
| 198 | > ok 4 - passing test |
| 199 | > not ok 5 - failing test |
| 200 | > # false |
| 201 | > not ok 6 - failing test |
| 202 | > # false |
| 203 | > not ok 7 - failing test |
| 204 | > # false |
| 205 | > not ok 8 - pretend we have a known breakage # TODO known breakage |
| 206 | > not ok 9 - pretend we have a known breakage # TODO known breakage |
Adam Spiers | b73d9a2 | 2012-12-16 18:28:15 +0000 | [diff] [blame] | 207 | > ok 10 - pretend we have fixed a known breakage # TODO known breakage vanished |
| 208 | > # 1 known breakage(s) vanished; please update test(s) |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 209 | > # still have 2 known breakage(s) |
Adam Spiers | b73d9a2 | 2012-12-16 18:28:15 +0000 | [diff] [blame] | 210 | > # failed 3 among remaining 7 test(s) |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 211 | > 1..10 |
| 212 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 213 | ' |
Adam Spiers | 5ebf89e | 2012-12-16 18:28:14 +0000 | [diff] [blame] | 214 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 215 | test_expect_success 'subtest: --verbose option' ' |
| 216 | write_and_run_sub_test_lib_test_err t1234-verbose --verbose <<-\EOF && |
Thomas Rast | 517cd55 | 2013-06-23 20:12:55 +0200 | [diff] [blame] | 217 | test_expect_success "passing test" true |
| 218 | test_expect_success "test with output" "echo foo" |
| 219 | test_expect_success "failing test" false |
| 220 | test_done |
| 221 | EOF |
SZEDER Gábor | 96f3ccc | 2019-08-05 23:04:46 +0200 | [diff] [blame] | 222 | mv t1234-verbose/out t1234-verbose/out+ && |
| 223 | grep -v "^Initialized empty" t1234-verbose/out+ >t1234-verbose/out && |
| 224 | check_sub_test_lib_test t1234-verbose <<-\EOF |
SZEDER Gábor | ffe1afe | 2019-08-05 23:04:47 +0200 | [diff] [blame] | 225 | > expecting success of 1234.1 '\''passing test'\'': true |
Thomas Rast | 517cd55 | 2013-06-23 20:12:55 +0200 | [diff] [blame] | 226 | > ok 1 - passing test |
| 227 | > Z |
SZEDER Gábor | ffe1afe | 2019-08-05 23:04:47 +0200 | [diff] [blame] | 228 | > expecting success of 1234.2 '\''test with output'\'': echo foo |
Thomas Rast | 517cd55 | 2013-06-23 20:12:55 +0200 | [diff] [blame] | 229 | > foo |
Thomas Rast | 517cd55 | 2013-06-23 20:12:55 +0200 | [diff] [blame] | 230 | > ok 2 - test with output |
| 231 | > Z |
SZEDER Gábor | ffe1afe | 2019-08-05 23:04:47 +0200 | [diff] [blame] | 232 | > expecting success of 1234.3 '\''failing test'\'': false |
Thomas Rast | 517cd55 | 2013-06-23 20:12:55 +0200 | [diff] [blame] | 233 | > not ok 3 - failing test |
| 234 | > # false |
| 235 | > Z |
| 236 | > # failed 1 among 3 test(s) |
| 237 | > 1..3 |
| 238 | EOF |
| 239 | ' |
| 240 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 241 | test_expect_success 'subtest: --verbose-only option' ' |
Denton Liu | 7717242 | 2019-12-20 10:15:49 -0800 | [diff] [blame] | 242 | run_sub_test_lib_test_err \ |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 243 | t1234-verbose \ |
| 244 | --verbose-only=2 && |
| 245 | check_sub_test_lib_test t1234-verbose <<-\EOF |
Thomas Rast | ff09af3 | 2013-06-23 20:12:56 +0200 | [diff] [blame] | 246 | > ok 1 - passing test |
| 247 | > Z |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 248 | > expecting success of 1234.2 '\''test with output'\'': echo foo |
Thomas Rast | ff09af3 | 2013-06-23 20:12:56 +0200 | [diff] [blame] | 249 | > foo |
Thomas Rast | ff09af3 | 2013-06-23 20:12:56 +0200 | [diff] [blame] | 250 | > ok 2 - test with output |
| 251 | > Z |
| 252 | > not ok 3 - failing test |
| 253 | > # false |
| 254 | > # failed 1 among 3 test(s) |
| 255 | > 1..3 |
| 256 | EOF |
| 257 | ' |
| 258 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 259 | test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' ' |
Ramsay Jones | 7e28c16 | 2014-05-21 00:33:46 +0100 | [diff] [blame] | 260 | ( |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 261 | run_sub_test_lib_test full-pass \ |
| 262 | --skip="full.2" && |
| 263 | check_sub_test_lib_test full-pass <<-\EOF |
Ramsay Jones | 7e28c16 | 2014-05-21 00:33:46 +0100 | [diff] [blame] | 264 | > ok 1 - passing test #1 |
| 265 | > ok 2 # skip passing test #2 (GIT_SKIP_TESTS) |
| 266 | > ok 3 - passing test #3 |
| 267 | > # passed all 3 test(s) |
| 268 | > 1..3 |
| 269 | EOF |
| 270 | ) |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 271 | ' |
Ilya Bobyr | ef2ac68 | 2014-04-30 02:50:43 -0700 | [diff] [blame] | 272 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 273 | test_expect_success 'subtest: skip several with GIT_SKIP_TESTS' ' |
Ramsay Jones | 7e28c16 | 2014-05-21 00:33:46 +0100 | [diff] [blame] | 274 | ( |
Ævar Arnfjörð Bjarmason | 9f0a452 | 2021-09-22 13:19:48 +0200 | [diff] [blame] | 275 | write_and_run_sub_test_lib_test git-skip-tests-several \ |
Jeff King | ac223c4 | 2021-07-16 14:43:47 -0400 | [diff] [blame] | 276 | --skip="git.2 git.5" <<-\EOF && |
Ramsay Jones | 7e28c16 | 2014-05-21 00:33:46 +0100 | [diff] [blame] | 277 | for i in 1 2 3 4 5 6 |
| 278 | do |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 279 | test_expect_success "passing test #$i" "true" |
Ramsay Jones | 7e28c16 | 2014-05-21 00:33:46 +0100 | [diff] [blame] | 280 | done |
| 281 | test_done |
| 282 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 283 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Ramsay Jones | 7e28c16 | 2014-05-21 00:33:46 +0100 | [diff] [blame] | 284 | > ok 1 - passing test #1 |
| 285 | > ok 2 # skip passing test #2 (GIT_SKIP_TESTS) |
| 286 | > ok 3 - passing test #3 |
| 287 | > ok 4 - passing test #4 |
| 288 | > ok 5 # skip passing test #5 (GIT_SKIP_TESTS) |
| 289 | > ok 6 - passing test #6 |
| 290 | > # passed all 6 test(s) |
| 291 | > 1..6 |
| 292 | EOF |
| 293 | ) |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 294 | ' |
Ilya Bobyr | ef2ac68 | 2014-04-30 02:50:43 -0700 | [diff] [blame] | 295 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 296 | test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' ' |
Ramsay Jones | 7e28c16 | 2014-05-21 00:33:46 +0100 | [diff] [blame] | 297 | ( |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 298 | run_sub_test_lib_test git-skip-tests-several \ |
| 299 | --skip="git.[2-5]" && |
| 300 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Ramsay Jones | 7e28c16 | 2014-05-21 00:33:46 +0100 | [diff] [blame] | 301 | > ok 1 - passing test #1 |
| 302 | > ok 2 # skip passing test #2 (GIT_SKIP_TESTS) |
| 303 | > ok 3 # skip passing test #3 (GIT_SKIP_TESTS) |
| 304 | > ok 4 # skip passing test #4 (GIT_SKIP_TESTS) |
| 305 | > ok 5 # skip passing test #5 (GIT_SKIP_TESTS) |
| 306 | > ok 6 - passing test #6 |
| 307 | > # passed all 6 test(s) |
| 308 | > 1..6 |
| 309 | EOF |
| 310 | ) |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 311 | ' |
Ilya Bobyr | ef2ac68 | 2014-04-30 02:50:43 -0700 | [diff] [blame] | 312 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 313 | test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' ' |
Denton Liu | b05b409 | 2019-10-08 02:22:47 -0700 | [diff] [blame] | 314 | ( |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 315 | GIT_SKIP_TESTS="git" && export GIT_SKIP_TESTS && |
| 316 | run_sub_test_lib_test git-skip-tests-several \ |
| 317 | --skip="git" && |
| 318 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Denton Liu | b05b409 | 2019-10-08 02:22:47 -0700 | [diff] [blame] | 319 | > 1..0 # SKIP skip all tests in git |
| 320 | EOF |
| 321 | ) |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 322 | ' |
Denton Liu | b05b409 | 2019-10-08 02:22:47 -0700 | [diff] [blame] | 323 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 324 | test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' ' |
Denton Liu | b05b409 | 2019-10-08 02:22:47 -0700 | [diff] [blame] | 325 | ( |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 326 | GIT_SKIP_TESTS="notgit" && export GIT_SKIP_TESTS && |
| 327 | run_sub_test_lib_test full-pass \ |
| 328 | --skip="notfull" && |
| 329 | check_sub_test_lib_test full-pass <<-\EOF |
Denton Liu | b05b409 | 2019-10-08 02:22:47 -0700 | [diff] [blame] | 330 | > ok 1 - passing test #1 |
| 331 | > ok 2 - passing test #2 |
| 332 | > ok 3 - passing test #3 |
| 333 | > # passed all 3 test(s) |
| 334 | > 1..3 |
| 335 | EOF |
| 336 | ) |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 337 | ' |
Denton Liu | b05b409 | 2019-10-08 02:22:47 -0700 | [diff] [blame] | 338 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 339 | test_expect_success 'subtest: --run basic' ' |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 340 | run_sub_test_lib_test git-skip-tests-several --run="1,3,5" && |
| 341 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 342 | > ok 1 - passing test #1 |
| 343 | > ok 2 # skip passing test #2 (--run) |
| 344 | > ok 3 - passing test #3 |
| 345 | > ok 4 # skip passing test #4 (--run) |
| 346 | > ok 5 - passing test #5 |
| 347 | > ok 6 # skip passing test #6 (--run) |
| 348 | > # passed all 6 test(s) |
| 349 | > 1..6 |
| 350 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 351 | ' |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 352 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 353 | test_expect_success 'subtest: --run with a range' ' |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 354 | run_sub_test_lib_test git-skip-tests-several \ |
| 355 | --run="1-3" && |
| 356 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 357 | > ok 1 - passing test #1 |
| 358 | > ok 2 - passing test #2 |
| 359 | > ok 3 - passing test #3 |
| 360 | > ok 4 # skip passing test #4 (--run) |
| 361 | > ok 5 # skip passing test #5 (--run) |
| 362 | > ok 6 # skip passing test #6 (--run) |
| 363 | > # passed all 6 test(s) |
| 364 | > 1..6 |
| 365 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 366 | ' |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 367 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 368 | test_expect_success 'subtest: --run with two ranges' ' |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 369 | run_sub_test_lib_test git-skip-tests-several \ |
| 370 | --run="1-2,5-6" && |
| 371 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 372 | > ok 1 - passing test #1 |
| 373 | > ok 2 - passing test #2 |
| 374 | > ok 3 # skip passing test #3 (--run) |
| 375 | > ok 4 # skip passing test #4 (--run) |
| 376 | > ok 5 - passing test #5 |
| 377 | > ok 6 - passing test #6 |
| 378 | > # passed all 6 test(s) |
| 379 | > 1..6 |
| 380 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 381 | ' |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 382 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 383 | test_expect_success 'subtest: --run with a left open range' ' |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 384 | run_sub_test_lib_test git-skip-tests-several \ |
| 385 | --run="-3" && |
| 386 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 387 | > ok 1 - passing test #1 |
| 388 | > ok 2 - passing test #2 |
| 389 | > ok 3 - passing test #3 |
| 390 | > ok 4 # skip passing test #4 (--run) |
| 391 | > ok 5 # skip passing test #5 (--run) |
| 392 | > ok 6 # skip passing test #6 (--run) |
| 393 | > # passed all 6 test(s) |
| 394 | > 1..6 |
| 395 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 396 | ' |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 397 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 398 | test_expect_success 'subtest: --run with a right open range' ' |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 399 | run_sub_test_lib_test git-skip-tests-several \ |
| 400 | --run="4-" && |
| 401 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 402 | > ok 1 # skip passing test #1 (--run) |
| 403 | > ok 2 # skip passing test #2 (--run) |
| 404 | > ok 3 # skip passing test #3 (--run) |
| 405 | > ok 4 - passing test #4 |
| 406 | > ok 5 - passing test #5 |
| 407 | > ok 6 - passing test #6 |
| 408 | > # passed all 6 test(s) |
| 409 | > 1..6 |
| 410 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 411 | ' |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 412 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 413 | test_expect_success 'subtest: --run with basic negation' ' |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 414 | run_sub_test_lib_test git-skip-tests-several \ |
| 415 | --run="!3" && |
| 416 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 417 | > ok 1 - passing test #1 |
| 418 | > ok 2 - passing test #2 |
| 419 | > ok 3 # skip passing test #3 (--run) |
| 420 | > ok 4 - passing test #4 |
| 421 | > ok 5 - passing test #5 |
| 422 | > ok 6 - passing test #6 |
| 423 | > # passed all 6 test(s) |
| 424 | > 1..6 |
| 425 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 426 | ' |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 427 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 428 | test_expect_success 'subtest: --run with two negations' ' |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 429 | run_sub_test_lib_test git-skip-tests-several \ |
| 430 | --run="!3,!6" && |
| 431 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 432 | > ok 1 - passing test #1 |
| 433 | > ok 2 - passing test #2 |
| 434 | > ok 3 # skip passing test #3 (--run) |
| 435 | > ok 4 - passing test #4 |
| 436 | > ok 5 - passing test #5 |
| 437 | > ok 6 # skip passing test #6 (--run) |
| 438 | > # passed all 6 test(s) |
| 439 | > 1..6 |
| 440 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 441 | ' |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 442 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 443 | test_expect_success 'subtest: --run a range and negation' ' |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 444 | run_sub_test_lib_test git-skip-tests-several \ |
| 445 | --run="-4,!2" && |
| 446 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 447 | > ok 1 - passing test #1 |
| 448 | > ok 2 # skip passing test #2 (--run) |
| 449 | > ok 3 - passing test #3 |
| 450 | > ok 4 - passing test #4 |
| 451 | > ok 5 # skip passing test #5 (--run) |
| 452 | > ok 6 # skip passing test #6 (--run) |
| 453 | > # passed all 6 test(s) |
| 454 | > 1..6 |
| 455 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 456 | ' |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 457 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 458 | test_expect_success 'subtest: --run range negation' ' |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 459 | run_sub_test_lib_test git-skip-tests-several \ |
| 460 | --run="!1-3" && |
| 461 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 462 | > ok 1 # skip passing test #1 (--run) |
| 463 | > ok 2 # skip passing test #2 (--run) |
| 464 | > ok 3 # skip passing test #3 (--run) |
| 465 | > ok 4 - passing test #4 |
| 466 | > ok 5 - passing test #5 |
| 467 | > ok 6 - passing test #6 |
| 468 | > # passed all 6 test(s) |
| 469 | > 1..6 |
| 470 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 471 | ' |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 472 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 473 | test_expect_success 'subtest: --run include, exclude and include' ' |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 474 | run_sub_test_lib_test git-skip-tests-several \ |
| 475 | --run="1-5,!1-3,2" && |
| 476 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 477 | > ok 1 # skip passing test #1 (--run) |
| 478 | > ok 2 - passing test #2 |
| 479 | > ok 3 # skip passing test #3 (--run) |
| 480 | > ok 4 - passing test #4 |
| 481 | > ok 5 - passing test #5 |
| 482 | > ok 6 # skip passing test #6 (--run) |
| 483 | > # passed all 6 test(s) |
| 484 | > 1..6 |
| 485 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 486 | ' |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 487 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 488 | test_expect_success 'subtest: --run include, exclude and include, comma separated' ' |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 489 | run_sub_test_lib_test git-skip-tests-several \ |
| 490 | --run=1-5,!1-3,2 && |
| 491 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 492 | > ok 1 # skip passing test #1 (--run) |
| 493 | > ok 2 - passing test #2 |
| 494 | > ok 3 # skip passing test #3 (--run) |
| 495 | > ok 4 - passing test #4 |
| 496 | > ok 5 - passing test #5 |
| 497 | > ok 6 # skip passing test #6 (--run) |
| 498 | > # passed all 6 test(s) |
| 499 | > 1..6 |
| 500 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 501 | ' |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 502 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 503 | test_expect_success 'subtest: --run exclude and include' ' |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 504 | run_sub_test_lib_test git-skip-tests-several \ |
| 505 | --run="!3-,5" && |
| 506 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 507 | > ok 1 - passing test #1 |
| 508 | > ok 2 - passing test #2 |
| 509 | > ok 3 # skip passing test #3 (--run) |
| 510 | > ok 4 # skip passing test #4 (--run) |
| 511 | > ok 5 - passing test #5 |
| 512 | > ok 6 # skip passing test #6 (--run) |
| 513 | > # passed all 6 test(s) |
| 514 | > 1..6 |
| 515 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 516 | ' |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 517 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 518 | test_expect_success 'subtest: --run empty selectors' ' |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 519 | run_sub_test_lib_test git-skip-tests-several \ |
| 520 | --run="1,,3,,,5" && |
| 521 | check_sub_test_lib_test git-skip-tests-several <<-\EOF |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 522 | > ok 1 - passing test #1 |
| 523 | > ok 2 # skip passing test #2 (--run) |
| 524 | > ok 3 - passing test #3 |
| 525 | > ok 4 # skip passing test #4 (--run) |
| 526 | > ok 5 - passing test #5 |
| 527 | > ok 6 # skip passing test #6 (--run) |
| 528 | > # passed all 6 test(s) |
| 529 | > 1..6 |
| 530 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 531 | ' |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 532 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 533 | test_expect_success 'subtest: --run substring selector' ' |
Ævar Arnfjörð Bjarmason | 9f0a452 | 2021-09-22 13:19:48 +0200 | [diff] [blame] | 534 | write_and_run_sub_test_lib_test run-substring-selector \ |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 535 | --run="relevant" <<-\EOF && |
| 536 | test_expect_success "relevant test" "true" |
Elijah Newren | f21ac36 | 2020-10-18 00:23:45 +0000 | [diff] [blame] | 537 | for i in 1 2 3 4 5 6 |
| 538 | do |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 539 | test_expect_success "other test #$i" "true" |
Elijah Newren | f21ac36 | 2020-10-18 00:23:45 +0000 | [diff] [blame] | 540 | done |
| 541 | test_done |
| 542 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 543 | check_sub_test_lib_test run-substring-selector <<-\EOF |
Elijah Newren | f21ac36 | 2020-10-18 00:23:45 +0000 | [diff] [blame] | 544 | > ok 1 - relevant test |
| 545 | > ok 2 # skip other test #1 (--run) |
| 546 | > ok 3 # skip other test #2 (--run) |
| 547 | > ok 4 # skip other test #3 (--run) |
| 548 | > ok 5 # skip other test #4 (--run) |
| 549 | > ok 6 # skip other test #5 (--run) |
| 550 | > ok 7 # skip other test #6 (--run) |
| 551 | > # passed all 7 test(s) |
| 552 | > 1..7 |
| 553 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 554 | ' |
Elijah Newren | f21ac36 | 2020-10-18 00:23:45 +0000 | [diff] [blame] | 555 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 556 | test_expect_success 'subtest: --run keyword selection' ' |
Ævar Arnfjörð Bjarmason | 9f0a452 | 2021-09-22 13:19:48 +0200 | [diff] [blame] | 557 | write_and_run_sub_test_lib_test_err run-inv-range-start \ |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 558 | --run="a-5" <<-\EOF && |
| 559 | test_expect_success "passing test #1" "true" |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 560 | test_done |
| 561 | EOF |
| 562 | check_sub_test_lib_test_err run-inv-range-start \ |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 563 | <<-\EOF_OUT 3<<-EOF_ERR |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 564 | > FATAL: Unexpected exit with code 1 |
| 565 | EOF_OUT |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 566 | > error: --run: invalid non-numeric in range start: ${SQ}a-5${SQ} |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 567 | EOF_ERR |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 568 | ' |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 569 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 570 | test_expect_success 'subtest: --run invalid range end' ' |
Ævar Arnfjörð Bjarmason | 2e54907 | 2021-09-22 13:19:53 +0200 | [diff] [blame] | 571 | run_sub_test_lib_test_err run-inv-range-start \ |
| 572 | --run="1-z" && |
| 573 | check_sub_test_lib_test_err run-inv-range-start \ |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 574 | <<-\EOF_OUT 3<<-EOF_ERR |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 575 | > FATAL: Unexpected exit with code 1 |
| 576 | EOF_OUT |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 577 | > error: --run: invalid non-numeric in range end: ${SQ}1-z${SQ} |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 578 | EOF_ERR |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 579 | ' |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 580 | |
Ævar Arnfjörð Bjarmason | 46fb057 | 2022-07-28 01:13:32 +0200 | [diff] [blame] | 581 | test_expect_success 'subtest: --invert-exit-code without --immediate' ' |
| 582 | run_sub_test_lib_test_err full-pass \ |
| 583 | --invert-exit-code && |
| 584 | check_sub_test_lib_test_err full-pass \ |
| 585 | <<-\EOF_OUT 3<<-EOF_ERR |
| 586 | ok 1 - passing test #1 |
| 587 | ok 2 - passing test #2 |
| 588 | ok 3 - passing test #3 |
| 589 | # passed all 3 test(s) |
| 590 | 1..3 |
| 591 | # faking up non-zero exit with --invert-exit-code |
| 592 | EOF_OUT |
| 593 | EOF_ERR |
| 594 | ' |
| 595 | |
| 596 | test_expect_success 'subtest: --invert-exit-code with --immediate: all passed' ' |
| 597 | run_sub_test_lib_test_err full-pass \ |
| 598 | --invert-exit-code --immediate && |
| 599 | check_sub_test_lib_test_err full-pass \ |
| 600 | <<-\EOF_OUT 3<<-EOF_ERR |
| 601 | ok 1 - passing test #1 |
| 602 | ok 2 - passing test #2 |
| 603 | ok 3 - passing test #3 |
| 604 | # passed all 3 test(s) |
| 605 | 1..3 |
| 606 | # faking up non-zero exit with --invert-exit-code |
| 607 | EOF_OUT |
| 608 | EOF_ERR |
| 609 | ' |
| 610 | |
| 611 | test_expect_success 'subtest: --invert-exit-code without --immediate: partial pass' ' |
| 612 | run_sub_test_lib_test partial-pass \ |
| 613 | --invert-exit-code && |
| 614 | check_sub_test_lib_test partial-pass <<-\EOF |
| 615 | ok 1 - passing test #1 |
| 616 | not ok 2 - # TODO induced breakage (--invert-exit-code): failing test #2 |
| 617 | # false |
| 618 | ok 3 - passing test #3 |
| 619 | # failed 1 among 3 test(s) |
| 620 | 1..3 |
| 621 | # faked up failures as TODO & now exiting with 0 due to --invert-exit-code |
| 622 | EOF |
| 623 | ' |
| 624 | |
| 625 | test_expect_success 'subtest: --invert-exit-code with --immediate: partial pass' ' |
| 626 | run_sub_test_lib_test partial-pass \ |
| 627 | --invert-exit-code --immediate && |
| 628 | check_sub_test_lib_test partial-pass \ |
| 629 | <<-\EOF_OUT 3<<-EOF_ERR |
| 630 | ok 1 - passing test #1 |
| 631 | not ok 2 - # TODO induced breakage (--invert-exit-code): failing test #2 |
| 632 | # false |
| 633 | 1..2 |
| 634 | # faked up failures as TODO & now exiting with 0 due to --invert-exit-code |
| 635 | EOF_OUT |
| 636 | EOF_ERR |
| 637 | ' |
| 638 | |
| 639 | test_expect_success 'subtest: --invert-exit-code --immediate: got a failure' ' |
| 640 | run_sub_test_lib_test partial-pass \ |
| 641 | --invert-exit-code --immediate && |
| 642 | check_sub_test_lib_test_err partial-pass \ |
| 643 | <<-\EOF_OUT 3<<-EOF_ERR |
| 644 | ok 1 - passing test #1 |
| 645 | not ok 2 - # TODO induced breakage (--invert-exit-code): failing test #2 |
| 646 | # false |
| 647 | 1..2 |
| 648 | # faked up failures as TODO & now exiting with 0 due to --invert-exit-code |
| 649 | EOF_OUT |
| 650 | EOF_ERR |
| 651 | ' |
| 652 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 653 | test_expect_success 'subtest: tests respect prerequisites' ' |
| 654 | write_and_run_sub_test_lib_test prereqs <<-\EOF && |
Ilya Bobyr | 0445e6f | 2014-04-30 02:50:44 -0700 | [diff] [blame] | 655 | |
Jeff King | efd2600 | 2021-01-28 01:32:32 -0500 | [diff] [blame] | 656 | test_set_prereq HAVEIT |
| 657 | test_expect_success HAVEIT "prereq is satisfied" "true" |
| 658 | test_expect_success "have_prereq works" " |
| 659 | test_have_prereq HAVEIT |
| 660 | " |
| 661 | test_expect_success DONTHAVEIT "prereq not satisfied" "false" |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 662 | |
Jeff King | efd2600 | 2021-01-28 01:32:32 -0500 | [diff] [blame] | 663 | test_set_prereq HAVETHIS |
| 664 | test_expect_success HAVETHIS,HAVEIT "multiple prereqs" "true" |
| 665 | test_expect_success HAVEIT,DONTHAVEIT "mixed prereqs (yes,no)" "false" |
| 666 | test_expect_success DONTHAVEIT,HAVEIT "mixed prereqs (no,yes)" "false" |
Ævar Arnfjörð Bjarmason | 93a5724 | 2010-08-06 21:19:23 +0000 | [diff] [blame] | 667 | |
Jeff King | efd2600 | 2021-01-28 01:32:32 -0500 | [diff] [blame] | 668 | test_done |
| 669 | EOF |
| 670 | |
| 671 | check_sub_test_lib_test prereqs <<-\EOF |
| 672 | ok 1 - prereq is satisfied |
| 673 | ok 2 - have_prereq works |
| 674 | ok 3 # skip prereq not satisfied (missing DONTHAVEIT) |
| 675 | ok 4 - multiple prereqs |
| 676 | ok 5 # skip mixed prereqs (yes,no) (missing DONTHAVEIT of HAVEIT,DONTHAVEIT) |
| 677 | ok 6 # skip mixed prereqs (no,yes) (missing DONTHAVEIT of DONTHAVEIT,HAVEIT) |
| 678 | # passed all 6 test(s) |
| 679 | 1..6 |
| 680 | EOF |
Jeff King | bdccd3c | 2012-11-14 16:33:25 -0800 | [diff] [blame] | 681 | ' |
| 682 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 683 | test_expect_success 'subtest: tests respect lazy prerequisites' ' |
| 684 | write_and_run_sub_test_lib_test lazy-prereqs <<-\EOF && |
Jeff King | bdccd3c | 2012-11-14 16:33:25 -0800 | [diff] [blame] | 685 | |
Jeff King | efd2600 | 2021-01-28 01:32:32 -0500 | [diff] [blame] | 686 | test_lazy_prereq LAZY_TRUE true |
| 687 | test_expect_success LAZY_TRUE "lazy prereq is satisifed" "true" |
| 688 | test_expect_success !LAZY_TRUE "negative lazy prereq" "false" |
| 689 | |
| 690 | test_lazy_prereq LAZY_FALSE false |
| 691 | test_expect_success LAZY_FALSE "lazy prereq not satisfied" "false" |
| 692 | test_expect_success !LAZY_FALSE "negative false prereq" "true" |
| 693 | |
| 694 | test_done |
| 695 | EOF |
| 696 | |
| 697 | check_sub_test_lib_test lazy-prereqs <<-\EOF |
| 698 | ok 1 - lazy prereq is satisifed |
| 699 | ok 2 # skip negative lazy prereq (missing !LAZY_TRUE) |
| 700 | ok 3 # skip lazy prereq not satisfied (missing LAZY_FALSE) |
| 701 | ok 4 - negative false prereq |
| 702 | # passed all 4 test(s) |
| 703 | 1..4 |
| 704 | EOF |
Jeff King | bdccd3c | 2012-11-14 16:33:25 -0800 | [diff] [blame] | 705 | ' |
| 706 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 707 | test_expect_success 'subtest: nested lazy prerequisites' ' |
| 708 | write_and_run_sub_test_lib_test nested-lazy <<-\EOF && |
Jeff King | bdccd3c | 2012-11-14 16:33:25 -0800 | [diff] [blame] | 709 | |
Jeff King | efd2600 | 2021-01-28 01:32:32 -0500 | [diff] [blame] | 710 | test_lazy_prereq NESTED_INNER " |
| 711 | >inner && |
| 712 | rm -f outer |
| 713 | " |
| 714 | test_lazy_prereq NESTED_PREREQ " |
| 715 | >outer && |
| 716 | test_have_prereq NESTED_INNER && |
| 717 | echo can create new file in cwd >file && |
| 718 | test_path_is_file outer && |
| 719 | test_path_is_missing inner |
| 720 | " |
| 721 | test_expect_success NESTED_PREREQ "evaluate nested prereq" "true" |
SZEDER Gábor | 53ff3b9 | 2020-11-18 20:04:13 +0100 | [diff] [blame] | 722 | |
Jeff King | efd2600 | 2021-01-28 01:32:32 -0500 | [diff] [blame] | 723 | test_done |
| 724 | EOF |
| 725 | |
| 726 | check_sub_test_lib_test nested-lazy <<-\EOF |
| 727 | ok 1 - evaluate nested prereq |
| 728 | # passed all 1 test(s) |
| 729 | 1..1 |
| 730 | EOF |
| 731 | ' |
SZEDER Gábor | 53ff3b9 | 2020-11-18 20:04:13 +0100 | [diff] [blame] | 732 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 733 | test_expect_success 'subtest: lazy prereqs do not turn off tracing' ' |
Ævar Arnfjörð Bjarmason | 9f0a452 | 2021-09-22 13:19:48 +0200 | [diff] [blame] | 734 | write_and_run_sub_test_lib_test lazy-prereq-and-tracing \ |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 735 | -v -x <<-\EOF && |
Johannes Schindelin | 477dcad | 2020-03-26 15:35:26 +0000 | [diff] [blame] | 736 | test_lazy_prereq LAZY true |
| 737 | |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 738 | test_expect_success lazy "test_have_prereq LAZY && echo trace" |
Johannes Schindelin | 477dcad | 2020-03-26 15:35:26 +0000 | [diff] [blame] | 739 | |
| 740 | test_done |
| 741 | EOF |
| 742 | |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 743 | grep "echo trace" lazy-prereq-and-tracing/err |
| 744 | ' |
Johannes Schindelin | 477dcad | 2020-03-26 15:35:26 +0000 | [diff] [blame] | 745 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 746 | test_expect_success 'subtest: tests clean up after themselves' ' |
| 747 | write_and_run_sub_test_lib_test cleanup <<-\EOF && |
Jeff King | 080e295 | 2021-01-28 01:32:35 -0500 | [diff] [blame] | 748 | clean=no |
| 749 | test_expect_success "do cleanup" " |
| 750 | test_when_finished clean=yes |
| 751 | " |
| 752 | test_expect_success "cleanup happened" " |
| 753 | test $clean = yes |
| 754 | " |
| 755 | test_done |
| 756 | EOF |
Jeff King | 03efadb | 2021-01-28 01:32:28 -0500 | [diff] [blame] | 757 | |
Jeff King | 080e295 | 2021-01-28 01:32:35 -0500 | [diff] [blame] | 758 | check_sub_test_lib_test cleanup <<-\EOF |
| 759 | ok 1 - do cleanup |
| 760 | ok 2 - cleanup happened |
| 761 | # passed all 2 test(s) |
| 762 | 1..2 |
| 763 | EOF |
| 764 | ' |
Jeff King | 03efadb | 2021-01-28 01:32:28 -0500 | [diff] [blame] | 765 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 766 | test_expect_success 'subtest: tests clean up even on failures' ' |
Ævar Arnfjörð Bjarmason | 9f0a452 | 2021-09-22 13:19:48 +0200 | [diff] [blame] | 767 | write_and_run_sub_test_lib_test_err \ |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 768 | failing-cleanup <<-\EOF && |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 769 | test_expect_success "tests clean up even after a failure" " |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 770 | touch clean-after-failure && |
| 771 | test_when_finished rm clean-after-failure && |
| 772 | (exit 1) |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 773 | " |
| 774 | test_expect_success "failure to clean up causes the test to fail" " |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 775 | test_when_finished \"(exit 2)\" |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 776 | " |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 777 | test_done |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 778 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 779 | check_sub_test_lib_test failing-cleanup <<-\EOF |
Adam Spiers | 5e5c006 | 2012-12-16 18:28:09 +0000 | [diff] [blame] | 780 | > not ok 1 - tests clean up even after a failure |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 781 | > # Z |
| 782 | > # touch clean-after-failure && |
| 783 | > # test_when_finished rm clean-after-failure && |
| 784 | > # (exit 1) |
| 785 | > # Z |
Adam Spiers | 5e5c006 | 2012-12-16 18:28:09 +0000 | [diff] [blame] | 786 | > not ok 2 - failure to clean up causes the test to fail |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 787 | > # Z |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 788 | > # test_when_finished "(exit 2)" |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 789 | > # Z |
| 790 | > # failed 2 among 2 test(s) |
| 791 | > 1..2 |
| 792 | EOF |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 793 | ' |
Ævar Arnfjörð Bjarmason | 892e6f7 | 2010-10-03 13:59:59 -0600 | [diff] [blame] | 794 | |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 795 | test_expect_success 'subtest: test_atexit is run' ' |
Ævar Arnfjörð Bjarmason | 9f0a452 | 2021-09-22 13:19:48 +0200 | [diff] [blame] | 796 | write_and_run_sub_test_lib_test_err \ |
Ævar Arnfjörð Bjarmason | c3ff7be | 2021-09-22 13:19:49 +0200 | [diff] [blame] | 797 | atexit-cleanup -i <<-\EOF && |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 798 | test_expect_success "tests clean up even after a failure" " |
Johannes Schindelin | 900721e | 2019-03-13 13:24:11 +0100 | [diff] [blame] | 799 | > ../../clean-atexit && |
| 800 | test_atexit rm ../../clean-atexit && |
| 801 | > ../../also-clean-atexit && |
| 802 | test_atexit rm ../../also-clean-atexit && |
| 803 | > ../../dont-clean-atexit && |
| 804 | (exit 1) |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 805 | " |
Johannes Schindelin | 900721e | 2019-03-13 13:24:11 +0100 | [diff] [blame] | 806 | test_done |
| 807 | EOF |
| 808 | test_path_is_file dont-clean-atexit && |
| 809 | test_path_is_missing clean-atexit && |
| 810 | test_path_is_missing also-clean-atexit |
Jeff King | 3029152 | 2021-01-28 01:32:37 -0500 | [diff] [blame] | 811 | ' |
Johannes Schindelin | 900721e | 2019-03-13 13:24:11 +0100 | [diff] [blame] | 812 | |
brian m. carlson | 2c02b11 | 2018-09-13 05:17:31 +0000 | [diff] [blame] | 813 | test_expect_success 'test_oid provides sane info by default' ' |
| 814 | test_oid zero >actual && |
| 815 | grep "^00*\$" actual && |
| 816 | rawsz="$(test_oid rawsz)" && |
| 817 | hexsz="$(test_oid hexsz)" && |
SZEDER Gábor | a48a880 | 2022-12-18 17:29:05 +0100 | [diff] [blame] | 818 | # +1 accounts for the trailing newline |
| 819 | test $(( $hexsz + 1)) -eq $(wc -c <actual) && |
brian m. carlson | 2c02b11 | 2018-09-13 05:17:31 +0000 | [diff] [blame] | 820 | test $(( $rawsz * 2)) -eq "$hexsz" |
| 821 | ' |
| 822 | |
| 823 | test_expect_success 'test_oid can look up data for SHA-1' ' |
| 824 | test_when_finished "test_detect_hash" && |
| 825 | test_set_hash sha1 && |
| 826 | test_oid zero >actual && |
| 827 | grep "^00*\$" actual && |
| 828 | rawsz="$(test_oid rawsz)" && |
| 829 | hexsz="$(test_oid hexsz)" && |
SZEDER Gábor | a48a880 | 2022-12-18 17:29:05 +0100 | [diff] [blame] | 830 | test $(wc -c <actual) -eq 41 && |
brian m. carlson | 2c02b11 | 2018-09-13 05:17:31 +0000 | [diff] [blame] | 831 | test "$rawsz" -eq 20 && |
| 832 | test "$hexsz" -eq 40 |
| 833 | ' |
| 834 | |
| 835 | test_expect_success 'test_oid can look up data for SHA-256' ' |
| 836 | test_when_finished "test_detect_hash" && |
| 837 | test_set_hash sha256 && |
| 838 | test_oid zero >actual && |
| 839 | grep "^00*\$" actual && |
| 840 | rawsz="$(test_oid rawsz)" && |
| 841 | hexsz="$(test_oid hexsz)" && |
SZEDER Gábor | a48a880 | 2022-12-18 17:29:05 +0100 | [diff] [blame] | 842 | test $(wc -c <actual) -eq 65 && |
brian m. carlson | 2c02b11 | 2018-09-13 05:17:31 +0000 | [diff] [blame] | 843 | test "$rawsz" -eq 32 && |
| 844 | test "$hexsz" -eq 64 |
| 845 | ' |
| 846 | |
brian m. carlson | ceaa4b3 | 2020-07-29 23:14:23 +0000 | [diff] [blame] | 847 | test_expect_success 'test_oid can look up data for a specified algorithm' ' |
| 848 | rawsz="$(test_oid --hash=sha1 rawsz)" && |
| 849 | hexsz="$(test_oid --hash=sha1 hexsz)" && |
| 850 | test "$rawsz" -eq 20 && |
| 851 | test "$hexsz" -eq 40 && |
| 852 | rawsz="$(test_oid --hash=sha256 rawsz)" && |
| 853 | hexsz="$(test_oid --hash=sha256 hexsz)" && |
| 854 | test "$rawsz" -eq 32 && |
| 855 | test "$hexsz" -eq 64 |
| 856 | ' |
| 857 | |
SZEDER Gábor | 43a2afe | 2019-11-22 14:14:36 +0100 | [diff] [blame] | 858 | test_expect_success 'test_bool_env' ' |
| 859 | ( |
| 860 | sane_unset envvar && |
| 861 | |
| 862 | test_bool_env envvar true && |
| 863 | ! test_bool_env envvar false && |
| 864 | |
| 865 | envvar= && |
| 866 | export envvar && |
| 867 | ! test_bool_env envvar true && |
| 868 | ! test_bool_env envvar false && |
| 869 | |
| 870 | envvar=true && |
| 871 | test_bool_env envvar true && |
| 872 | test_bool_env envvar false && |
| 873 | |
| 874 | envvar=false && |
| 875 | ! test_bool_env envvar true && |
| 876 | ! test_bool_env envvar false && |
| 877 | |
| 878 | envvar=invalid && |
| 879 | # When encountering an invalid bool value, test_bool_env |
| 880 | # prints its error message to the original stderr of the |
| 881 | # test script, hence the redirection of fd 7, and aborts |
| 882 | # with "exit 1", hence the subshell. |
| 883 | ! ( test_bool_env envvar true ) 7>err && |
| 884 | grep "error: test_bool_env requires bool values" err && |
| 885 | |
| 886 | envvar=true && |
| 887 | ! ( test_bool_env envvar invalid ) 7>err && |
| 888 | grep "error: test_bool_env requires bool values" err |
| 889 | ) |
| 890 | ' |
| 891 | |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 892 | ################################################################ |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 893 | # Basics of the basics |
| 894 | |
brian m. carlson | e483e14 | 2018-09-13 05:17:33 +0000 | [diff] [blame] | 895 | test_oid_cache <<\EOF |
| 896 | path0f sha1:f87290f8eb2cbbea7857214459a0739927eab154 |
| 897 | path0f sha256:638106af7c38be056f3212cbd7ac65bc1bac74f420ca5a436ff006a9d025d17d |
| 898 | |
| 899 | path0s sha1:15a98433ae33114b085f3eb3bb03b832b3180a01 |
| 900 | path0s sha256:3a24cc53cf68edddac490bbf94a418a52932130541361f685df685e41dd6c363 |
| 901 | |
| 902 | path2f sha1:3feff949ed00a62d9f7af97c15cd8a30595e7ac7 |
| 903 | path2f sha256:2a7f36571c6fdbaf0e3f62751a0b25a3f4c54d2d1137b3f4af9cb794bb498e5f |
| 904 | |
| 905 | path2s sha1:d8ce161addc5173867a3c3c730924388daedbc38 |
| 906 | path2s sha256:18fd611b787c2e938ddcc248fabe4d66a150f9364763e9ec133dd01d5bb7c65a |
| 907 | |
| 908 | path2d sha1:58a09c23e2ca152193f2786e06986b7b6712bdbe |
| 909 | path2d sha256:00e4b32b96e7e3d65d79112dcbea53238a22715f896933a62b811377e2650c17 |
| 910 | |
| 911 | path3f sha1:0aa34cae68d0878578ad119c86ca2b5ed5b28376 |
| 912 | path3f sha256:09f58616b951bd571b8cb9dc76d372fbb09ab99db2393f5ab3189d26c45099ad |
| 913 | |
| 914 | path3s sha1:8599103969b43aff7e430efea79ca4636466794f |
| 915 | path3s sha256:fce1aed087c053306f3f74c32c1a838c662bbc4551a7ac2420f5d6eb061374d0 |
| 916 | |
| 917 | path3d sha1:21ae8269cacbe57ae09138dcc3a2887f904d02b3 |
| 918 | path3d sha256:9b60497be959cb830bf3f0dc82bcc9ad9e925a24e480837ade46b2295e47efe1 |
| 919 | |
| 920 | subp3f sha1:00fb5908cb97c2564a9783c0c64087333b3b464f |
| 921 | subp3f sha256:a1a9e16998c988453f18313d10375ee1d0ddefe757e710dcae0d66aa1e0c58b3 |
| 922 | |
| 923 | subp3s sha1:6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c |
| 924 | subp3s sha256:81759d9f5e93c6546ecfcadb560c1ff057314b09f93fe8ec06e2d8610d34ef10 |
| 925 | |
| 926 | subp3d sha1:3c5e5399f3a333eddecce7a9b9465b63f65f51e2 |
| 927 | subp3d sha256:76b4ef482d4fa1c754390344cf3851c7f883b27cf9bc999c6547928c46aeafb7 |
| 928 | |
| 929 | root sha1:087704a96baf1c2d1c869a8b084481e121c88b5b |
| 930 | root sha256:9481b52abab1b2ffeedbf9de63ce422b929f179c1b98ff7bee5f8f1bc0710751 |
| 931 | |
| 932 | simpletree sha1:7bb943559a305bdd6bdee2cef6e5df2413c3d30a |
| 933 | simpletree sha256:1710c07a6c86f9a3c7376364df04c47ee39e5a5e221fcdd84b743bc9bb7e2bc5 |
| 934 | EOF |
| 935 | |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 936 | # updating a new file without --add should fail. |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 937 | test_expect_success 'git update-index without --add should fail adding' ' |
| 938 | test_must_fail git update-index should-be-empty |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 939 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 940 | |
| 941 | # and with --add it should succeed, even if it is empty (it used to fail). |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 942 | test_expect_success 'git update-index with --add should succeed' ' |
| 943 | git update-index --add should-be-empty |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 944 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 945 | |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 946 | test_expect_success 'writing tree out with git write-tree' ' |
| 947 | tree=$(git write-tree) |
| 948 | ' |
| 949 | |
| 950 | # we know the shape and contents of the tree and know the object ID for it. |
brian m. carlson | e483e14 | 2018-09-13 05:17:33 +0000 | [diff] [blame] | 951 | test_expect_success 'validate object ID of a known tree' ' |
| 952 | test "$tree" = "$(test_oid simpletree)" |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 953 | ' |
| 954 | |
| 955 | # Removing paths. |
| 956 | test_expect_success 'git update-index without --remove should fail removing' ' |
| 957 | rm -f should-be-empty full-of-directories && |
| 958 | test_must_fail git update-index should-be-empty |
| 959 | ' |
| 960 | |
| 961 | test_expect_success 'git update-index with --remove should be able to remove' ' |
| 962 | git update-index --remove should-be-empty |
| 963 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 964 | |
| 965 | # Empty tree can be written with recent write-tree. |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 966 | test_expect_success 'git write-tree should be able to write an empty tree' ' |
| 967 | tree=$(git write-tree) |
| 968 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 969 | |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 970 | test_expect_success 'validate object ID of a known tree' ' |
Nguyễn Thái Ngọc Duy | f9e7d9f | 2016-07-16 07:06:24 +0200 | [diff] [blame] | 971 | test "$tree" = $EMPTY_TREE |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 972 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 973 | |
| 974 | # Various types of objects |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 975 | |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 976 | test_expect_success 'adding various types of objects with git update-index --add' ' |
| 977 | mkdir path2 path3 path3/subp3 && |
| 978 | paths="path0 path2/file2 path3/file3 path3/subp3/file3" && |
| 979 | ( |
| 980 | for p in $paths |
| 981 | do |
| 982 | echo "hello $p" >$p || exit 1 |
Johannes Sixt | c723a76 | 2013-06-07 22:53:29 +0200 | [diff] [blame] | 983 | test_ln_s_add "hello $p" ${p}sym || exit 1 |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 984 | done |
| 985 | ) && |
| 986 | find path* ! -type d -print | xargs git update-index --add |
| 987 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 988 | |
| 989 | # Show them and see that matches what we expect. |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 990 | test_expect_success 'showing stage with git ls-files --stage' ' |
| 991 | git ls-files --stage >current |
| 992 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 993 | |
brian m. carlson | e483e14 | 2018-09-13 05:17:33 +0000 | [diff] [blame] | 994 | test_expect_success 'validate git ls-files output for a known tree' ' |
| 995 | cat >expected <<-EOF && |
| 996 | 100644 $(test_oid path0f) 0 path0 |
| 997 | 120000 $(test_oid path0s) 0 path0sym |
| 998 | 100644 $(test_oid path2f) 0 path2/file2 |
| 999 | 120000 $(test_oid path2s) 0 path2/file2sym |
| 1000 | 100644 $(test_oid path3f) 0 path3/file3 |
| 1001 | 120000 $(test_oid path3s) 0 path3/file3sym |
| 1002 | 100644 $(test_oid subp3f) 0 path3/subp3/file3 |
| 1003 | 120000 $(test_oid subp3s) 0 path3/subp3/file3sym |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1004 | EOF |
| 1005 | test_cmp expected current |
| 1006 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 1007 | |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1008 | test_expect_success 'writing tree out with git write-tree' ' |
| 1009 | tree=$(git write-tree) |
| 1010 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 1011 | |
brian m. carlson | e483e14 | 2018-09-13 05:17:33 +0000 | [diff] [blame] | 1012 | test_expect_success 'validate object ID for a known tree' ' |
| 1013 | test "$tree" = "$(test_oid root)" |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1014 | ' |
| 1015 | |
| 1016 | test_expect_success 'showing tree with git ls-tree' ' |
John Cai | 2f68c99 | 2023-05-18 20:03:06 +0000 | [diff] [blame] | 1017 | git ls-tree $tree >current |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1018 | ' |
| 1019 | |
brian m. carlson | e483e14 | 2018-09-13 05:17:33 +0000 | [diff] [blame] | 1020 | test_expect_success 'git ls-tree output for a known tree' ' |
| 1021 | cat >expected <<-EOF && |
| 1022 | 100644 blob $(test_oid path0f) path0 |
| 1023 | 120000 blob $(test_oid path0s) path0sym |
| 1024 | 040000 tree $(test_oid path2d) path2 |
| 1025 | 040000 tree $(test_oid path3d) path3 |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1026 | EOF |
| 1027 | test_cmp expected current |
| 1028 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 1029 | |
Junio C Hamano | 246cc52 | 2005-11-28 02:32:42 -0800 | [diff] [blame] | 1030 | # This changed in ls-tree pathspec change -- recursive does |
| 1031 | # not show tree nodes anymore. |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1032 | test_expect_success 'showing tree with git ls-tree -r' ' |
| 1033 | git ls-tree -r $tree >current |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 1034 | ' |
Johannes Sixt | 3d12d0c | 2006-11-13 13:50:00 +0000 | [diff] [blame] | 1035 | |
brian m. carlson | e483e14 | 2018-09-13 05:17:33 +0000 | [diff] [blame] | 1036 | test_expect_success 'git ls-tree -r output for a known tree' ' |
| 1037 | cat >expected <<-EOF && |
| 1038 | 100644 blob $(test_oid path0f) path0 |
| 1039 | 120000 blob $(test_oid path0s) path0sym |
| 1040 | 100644 blob $(test_oid path2f) path2/file2 |
| 1041 | 120000 blob $(test_oid path2s) path2/file2sym |
| 1042 | 100644 blob $(test_oid path3f) path3/file3 |
| 1043 | 120000 blob $(test_oid path3s) path3/file3sym |
| 1044 | 100644 blob $(test_oid subp3f) path3/subp3/file3 |
| 1045 | 120000 blob $(test_oid subp3s) path3/subp3/file3sym |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1046 | EOF |
| 1047 | test_cmp expected current |
| 1048 | ' |
| 1049 | |
| 1050 | # But with -r -t we can have both. |
| 1051 | test_expect_success 'showing tree with git ls-tree -r -t' ' |
| 1052 | git ls-tree -r -t $tree >current |
| 1053 | ' |
| 1054 | |
brian m. carlson | e483e14 | 2018-09-13 05:17:33 +0000 | [diff] [blame] | 1055 | test_expect_success 'git ls-tree -r output for a known tree' ' |
| 1056 | cat >expected <<-EOF && |
| 1057 | 100644 blob $(test_oid path0f) path0 |
| 1058 | 120000 blob $(test_oid path0s) path0sym |
| 1059 | 040000 tree $(test_oid path2d) path2 |
| 1060 | 100644 blob $(test_oid path2f) path2/file2 |
| 1061 | 120000 blob $(test_oid path2s) path2/file2sym |
| 1062 | 040000 tree $(test_oid path3d) path3 |
| 1063 | 100644 blob $(test_oid path3f) path3/file3 |
| 1064 | 120000 blob $(test_oid path3s) path3/file3sym |
| 1065 | 040000 tree $(test_oid subp3d) path3/subp3 |
| 1066 | 100644 blob $(test_oid subp3f) path3/subp3/file3 |
| 1067 | 120000 blob $(test_oid subp3s) path3/subp3/file3sym |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1068 | EOF |
| 1069 | test_cmp expected current |
| 1070 | ' |
| 1071 | |
| 1072 | test_expect_success 'writing partial tree out with git write-tree --prefix' ' |
| 1073 | ptree=$(git write-tree --prefix=path3) |
| 1074 | ' |
| 1075 | |
brian m. carlson | e483e14 | 2018-09-13 05:17:33 +0000 | [diff] [blame] | 1076 | test_expect_success 'validate object ID for a known tree' ' |
| 1077 | test "$ptree" = $(test_oid path3d) |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1078 | ' |
| 1079 | |
| 1080 | test_expect_success 'writing partial tree out with git write-tree --prefix' ' |
| 1081 | ptree=$(git write-tree --prefix=path3/subp3) |
| 1082 | ' |
| 1083 | |
brian m. carlson | e483e14 | 2018-09-13 05:17:33 +0000 | [diff] [blame] | 1084 | test_expect_success 'validate object ID for a known tree' ' |
| 1085 | test "$ptree" = $(test_oid subp3d) |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1086 | ' |
| 1087 | |
| 1088 | test_expect_success 'put invalid objects into the index' ' |
| 1089 | rm -f .git/index && |
brian m. carlson | cdd1e17 | 2018-09-13 05:17:32 +0000 | [diff] [blame] | 1090 | suffix=$(echo $ZERO_OID | sed -e "s/^.//") && |
| 1091 | cat >badobjects <<-EOF && |
| 1092 | 100644 blob $(test_oid 001) dir/file1 |
| 1093 | 100644 blob $(test_oid 002) dir/file2 |
| 1094 | 100644 blob $(test_oid 003) dir/file3 |
| 1095 | 100644 blob $(test_oid 004) dir/file4 |
| 1096 | 100644 blob $(test_oid 005) dir/file5 |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1097 | EOF |
| 1098 | git update-index --index-info <badobjects |
| 1099 | ' |
| 1100 | |
| 1101 | test_expect_success 'writing this tree without --missing-ok' ' |
| 1102 | test_must_fail git write-tree |
| 1103 | ' |
| 1104 | |
| 1105 | test_expect_success 'writing this tree with --missing-ok' ' |
| 1106 | git write-tree --missing-ok |
| 1107 | ' |
Johannes Sixt | 3d12d0c | 2006-11-13 13:50:00 +0000 | [diff] [blame] | 1108 | |
| 1109 | |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 1110 | ################################################################ |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1111 | test_expect_success 'git read-tree followed by write-tree should be idempotent' ' |
Jeff King | 99094a7 | 2015-03-20 06:07:15 -0400 | [diff] [blame] | 1112 | rm -f .git/index && |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1113 | git read-tree $tree && |
Caleb Tillman | ac9b547 | 2020-10-17 02:43:53 +0000 | [diff] [blame] | 1114 | test_path_is_file .git/index && |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1115 | newtree=$(git write-tree) && |
| 1116 | test "$newtree" = "$tree" |
| 1117 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 1118 | |
brian m. carlson | e483e14 | 2018-09-13 05:17:33 +0000 | [diff] [blame] | 1119 | test_expect_success 'validate git diff-files output for a know cache/work tree state' ' |
| 1120 | cat >expected <<EOF && |
| 1121 | :100644 100644 $(test_oid path0f) $ZERO_OID M path0 |
| 1122 | :120000 120000 $(test_oid path0s) $ZERO_OID M path0sym |
| 1123 | :100644 100644 $(test_oid path2f) $ZERO_OID M path2/file2 |
| 1124 | :120000 120000 $(test_oid path2s) $ZERO_OID M path2/file2sym |
| 1125 | :100644 100644 $(test_oid path3f) $ZERO_OID M path3/file3 |
| 1126 | :120000 120000 $(test_oid path3s) $ZERO_OID M path3/file3sym |
| 1127 | :100644 100644 $(test_oid subp3f) $ZERO_OID M path3/subp3/file3 |
| 1128 | :120000 120000 $(test_oid subp3s) $ZERO_OID M path3/subp3/file3sym |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 1129 | EOF |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1130 | git diff-files >current && |
Matthew DeVore | dcbaa0b | 2018-10-05 14:54:04 -0700 | [diff] [blame] | 1131 | test_cmp expected current |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1132 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 1133 | |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1134 | test_expect_success 'git update-index --refresh should succeed' ' |
| 1135 | git update-index --refresh |
| 1136 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 1137 | |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1138 | test_expect_success 'no diff after checkout and git update-index --refresh' ' |
| 1139 | git diff-files >current && |
| 1140 | cmp -s current /dev/null |
| 1141 | ' |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 1142 | |
Junio C Hamano | 9af0b8d | 2006-04-26 18:25:15 -0700 | [diff] [blame] | 1143 | ################################################################ |
brian m. carlson | e483e14 | 2018-09-13 05:17:33 +0000 | [diff] [blame] | 1144 | P=$(test_oid root) |
Junio C Hamano | 9af0b8d | 2006-04-26 18:25:15 -0700 | [diff] [blame] | 1145 | |
brian m. carlson | e483e14 | 2018-09-13 05:17:33 +0000 | [diff] [blame] | 1146 | test_expect_success 'git commit-tree records the correct tree in a commit' ' |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1147 | commit0=$(echo NO | git commit-tree $P) && |
Carlo Marcelo Arenas Belón | 66c0c44 | 2021-09-16 01:55:23 -0700 | [diff] [blame] | 1148 | git show --pretty=raw $commit0 >out && |
| 1149 | tree=$(sed -n -e "s/^tree //p" -e "/^author /q" out) && |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1150 | test "z$tree" = "z$P" |
| 1151 | ' |
Junio C Hamano | 9af0b8d | 2006-04-26 18:25:15 -0700 | [diff] [blame] | 1152 | |
brian m. carlson | e483e14 | 2018-09-13 05:17:33 +0000 | [diff] [blame] | 1153 | test_expect_success 'git commit-tree records the correct parent in a commit' ' |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1154 | commit1=$(echo NO | git commit-tree $P -p $commit0) && |
Carlo Marcelo Arenas Belón | 66c0c44 | 2021-09-16 01:55:23 -0700 | [diff] [blame] | 1155 | git show --pretty=raw $commit1 >out && |
| 1156 | parent=$(sed -n -e "s/^parent //p" -e "/^author /q" out) && |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1157 | test "z$commit0" = "z$parent" |
| 1158 | ' |
| 1159 | |
brian m. carlson | e483e14 | 2018-09-13 05:17:33 +0000 | [diff] [blame] | 1160 | test_expect_success 'git commit-tree omits duplicated parent in a commit' ' |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1161 | commit2=$(echo NO | git commit-tree $P -p $commit0 -p $commit0) && |
Carlo Marcelo Arenas Belón | 66c0c44 | 2021-09-16 01:55:23 -0700 | [diff] [blame] | 1162 | git show --pretty=raw $commit2 >out && |
| 1163 | cat >match.sed <<-\EOF && |
| 1164 | s/^parent //p |
| 1165 | /^author /q |
| 1166 | EOF |
| 1167 | parent=$(sed -n -f match.sed out | sort -u) && |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1168 | test "z$commit0" = "z$parent" && |
Carlo Marcelo Arenas Belón | 66c0c44 | 2021-09-16 01:55:23 -0700 | [diff] [blame] | 1169 | git show --pretty=raw $commit2 >out && |
| 1170 | test_stdout_line_count = 1 sed -n -f match.sed out |
Stefano Lattarini | 1b5b2b6 | 2012-03-02 10:08:28 +0100 | [diff] [blame] | 1171 | ' |
Junio C Hamano | 9af0b8d | 2006-04-26 18:25:15 -0700 | [diff] [blame] | 1172 | |
Junio C Hamano | 81a361b | 2006-12-16 17:39:06 -0800 | [diff] [blame] | 1173 | test_expect_success 'update-index D/F conflict' ' |
| 1174 | mv path0 tmp && |
| 1175 | mv path2 path0 && |
| 1176 | mv tmp path2 && |
| 1177 | git update-index --add --replace path2 path0/file2 && |
Shubham Mishra | 9b6d1fc | 2022-03-12 11:51:25 +0530 | [diff] [blame] | 1178 | git ls-files path0 >tmp && |
| 1179 | numpath0=$(wc -l <tmp) && |
Junio C Hamano | 81a361b | 2006-12-16 17:39:06 -0800 | [diff] [blame] | 1180 | test $numpath0 = 1 |
| 1181 | ' |
| 1182 | |
Junio C Hamano | 7fec10b | 2008-01-18 23:42:00 -0800 | [diff] [blame] | 1183 | test_expect_success 'very long name in the index handled sanely' ' |
| 1184 | |
| 1185 | a=a && # 1 |
| 1186 | a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 16 |
| 1187 | a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 256 |
| 1188 | a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 4096 |
| 1189 | a=${a}q && |
| 1190 | |
| 1191 | >path4 && |
| 1192 | git update-index --add path4 && |
Shubham Mishra | 9b6d1fc | 2022-03-12 11:51:25 +0530 | [diff] [blame] | 1193 | git ls-files -s path4 >tmp && |
Junio C Hamano | 7fec10b | 2008-01-18 23:42:00 -0800 | [diff] [blame] | 1194 | ( |
Shubham Mishra | 9b6d1fc | 2022-03-12 11:51:25 +0530 | [diff] [blame] | 1195 | sed -e "s/ .*/ /" tmp | |
Eric Sunshine | 75651fd | 2018-07-01 20:23:55 -0400 | [diff] [blame] | 1196 | tr -d "\012" && |
Junio C Hamano | 7fec10b | 2008-01-18 23:42:00 -0800 | [diff] [blame] | 1197 | echo "$a" |
| 1198 | ) | git update-index --index-info && |
Shubham Mishra | 9b6d1fc | 2022-03-12 11:51:25 +0530 | [diff] [blame] | 1199 | git ls-files "a*" >tmp && |
| 1200 | len=$(wc -c <tmp) && |
Junio C Hamano | 7fec10b | 2008-01-18 23:42:00 -0800 | [diff] [blame] | 1201 | test $len = 4098 |
| 1202 | ' |
| 1203 | |
Denton Liu | 6a67c75 | 2020-07-07 02:04:38 -0400 | [diff] [blame] | 1204 | test_expect_success 'test_must_fail on a failing git command' ' |
| 1205 | test_must_fail git notacommand |
| 1206 | ' |
| 1207 | |
| 1208 | test_expect_success 'test_must_fail on a failing git command with env' ' |
| 1209 | test_must_fail env var1=a var2=b git notacommand |
| 1210 | ' |
| 1211 | |
| 1212 | test_expect_success 'test_must_fail rejects a non-git command' ' |
| 1213 | ! test_must_fail grep ^$ notafile 2>err && |
| 1214 | grep -F "test_must_fail: only '"'"'git'"'"' is allowed" err |
| 1215 | ' |
| 1216 | |
| 1217 | test_expect_success 'test_must_fail rejects a non-git command with env' ' |
| 1218 | ! test_must_fail env var1=a var2=b grep ^$ notafile 2>err && |
| 1219 | grep -F "test_must_fail: only '"'"'git'"'"' is allowed" err |
| 1220 | ' |
| 1221 | |
Junio C Hamano | e1970ce | 2005-05-13 22:50:32 -0700 | [diff] [blame] | 1222 | test_done |