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 <avarab@gmail.com> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Ævar Arnfjörð Bjarmason committed
Nov 10, 2022 at 23:36 UTC
929bf9db28e617e55b52bdd307f3d44ceeb3e978
1 file changed
+30
t/t6030-bisect-porcelain.sh
+30
@@ -34,6 +34,36 @@ HASH2=
34
HASH3=
35
HASH4=
36
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
+
67
test_expect_success 'set up basic repo with 1 file (hello) and 4 commits' '
68
add_line_into_file "1: Hello World" hello &&
69
HASH1=$(git rev-parse --verify HEAD) &&