Skip to content

Commit 929bf9d

Browse files
avarttaylorr
authored andcommitted
bisect test: test exit codes on bad usage
Address a test blindspot, the "log" command is the odd one out because "git-bisect.sh" ignores any arguments it receives. Let's test both the exit codes we expect, and the stderr and stdout we're emitting. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Đoàn Trần Công Danh <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 252060b commit 929bf9d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

t/t6030-bisect-porcelain.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,36 @@ HASH2=
3434
HASH3=
3535
HASH4=
3636

37+
test_bisect_usage () {
38+
local code="$1" &&
39+
shift &&
40+
cat >expect &&
41+
test_expect_code $code "$@" >out 2>actual &&
42+
test_must_be_empty out &&
43+
test_cmp expect actual
44+
}
45+
46+
test_expect_success 'bisect usage' "
47+
test_bisect_usage 1 git bisect reset extra1 extra2 <<-\EOF &&
48+
error: 'git bisect reset' requires either no argument or a commit
49+
EOF
50+
test_bisect_usage 1 git bisect terms extra1 extra2 <<-\EOF &&
51+
error: 'git bisect terms' requires 0 or 1 argument
52+
EOF
53+
test_bisect_usage 1 git bisect next extra1 <<-\EOF &&
54+
error: 'git bisect next' requires 0 arguments
55+
EOF
56+
test_bisect_usage 1 git bisect log extra1 <<-\EOF &&
57+
error: We are not bisecting.
58+
EOF
59+
test_bisect_usage 1 git bisect replay <<-\EOF &&
60+
error: no logfile given
61+
EOF
62+
test_bisect_usage 1 git bisect run <<-\EOF
63+
error: 'git bisect run' failed: no command provided.
64+
EOF
65+
"
66+
3767
test_expect_success 'set up basic repo with 1 file (hello) and 4 commits' '
3868
add_line_into_file "1: Hello World" hello &&
3969
HASH1=$(git rev-parse --verify HEAD) &&

0 commit comments

Comments
 (0)