]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0041-usage.sh
The second batch
[thirdparty/git.git] / t / t0041-usage.sh
CommitLineData
3bb0923f
PSU
1#!/bin/sh
2
3test_description='Test commands behavior when given invalid argument value'
4
06d53148 5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
b571fb98 8TEST_PASSES_SANITIZE_LEAK=true
3bb0923f
PSU
9. ./test-lib.sh
10
11test_expect_success 'setup ' '
12 test_commit "v1.0"
13'
14
15test_expect_success 'tag --contains <existent_tag>' '
16 git tag --contains "v1.0" >actual 2>actual.err &&
17 grep "v1.0" actual &&
18 test_line_count = 0 actual.err
19'
20
21test_expect_success 'tag --contains <inexistent_tag>' '
22 test_must_fail git tag --contains "notag" >actual 2>actual.err &&
23 test_line_count = 0 actual &&
6789275d
JH
24 test_grep "error" actual.err &&
25 test_grep ! "usage" actual.err
3bb0923f
PSU
26'
27
28test_expect_success 'tag --no-contains <existent_tag>' '
29 git tag --no-contains "v1.0" >actual 2>actual.err &&
30 test_line_count = 0 actual &&
31 test_line_count = 0 actual.err
32'
33
34test_expect_success 'tag --no-contains <inexistent_tag>' '
35 test_must_fail git tag --no-contains "notag" >actual 2>actual.err &&
36 test_line_count = 0 actual &&
6789275d
JH
37 test_grep "error" actual.err &&
38 test_grep ! "usage" actual.err
3bb0923f
PSU
39'
40
41test_expect_success 'tag usage error' '
42 test_must_fail git tag --noopt >actual 2>actual.err &&
43 test_line_count = 0 actual &&
6789275d 44 test_grep "usage" actual.err
3bb0923f
PSU
45'
46
47test_expect_success 'branch --contains <existent_commit>' '
06d53148 48 git branch --contains "main" >actual 2>actual.err &&
6789275d 49 test_grep "main" actual &&
3bb0923f
PSU
50 test_line_count = 0 actual.err
51'
52
53test_expect_success 'branch --contains <inexistent_commit>' '
54 test_must_fail git branch --no-contains "nocommit" >actual 2>actual.err &&
55 test_line_count = 0 actual &&
6789275d
JH
56 test_grep "error" actual.err &&
57 test_grep ! "usage" actual.err
3bb0923f
PSU
58'
59
60test_expect_success 'branch --no-contains <existent_commit>' '
06d53148 61 git branch --no-contains "main" >actual 2>actual.err &&
3bb0923f
PSU
62 test_line_count = 0 actual &&
63 test_line_count = 0 actual.err
64'
65
66test_expect_success 'branch --no-contains <inexistent_commit>' '
67 test_must_fail git branch --no-contains "nocommit" >actual 2>actual.err &&
68 test_line_count = 0 actual &&
6789275d
JH
69 test_grep "error" actual.err &&
70 test_grep ! "usage" actual.err
3bb0923f
PSU
71'
72
73test_expect_success 'branch usage error' '
74 test_must_fail git branch --noopt >actual 2>actual.err &&
75 test_line_count = 0 actual &&
6789275d 76 test_grep "usage" actual.err
3bb0923f
PSU
77'
78
79test_expect_success 'for-each-ref --contains <existent_object>' '
06d53148 80 git for-each-ref --contains "main" >actual 2>actual.err &&
3bb0923f
PSU
81 test_line_count = 2 actual &&
82 test_line_count = 0 actual.err
83'
84
85test_expect_success 'for-each-ref --contains <inexistent_object>' '
86 test_must_fail git for-each-ref --no-contains "noobject" >actual 2>actual.err &&
87 test_line_count = 0 actual &&
6789275d
JH
88 test_grep "error" actual.err &&
89 test_grep ! "usage" actual.err
3bb0923f
PSU
90'
91
92test_expect_success 'for-each-ref --no-contains <existent_object>' '
06d53148 93 git for-each-ref --no-contains "main" >actual 2>actual.err &&
3bb0923f
PSU
94 test_line_count = 0 actual &&
95 test_line_count = 0 actual.err
96'
97
98test_expect_success 'for-each-ref --no-contains <inexistent_object>' '
99 test_must_fail git for-each-ref --no-contains "noobject" >actual 2>actual.err &&
100 test_line_count = 0 actual &&
6789275d
JH
101 test_grep "error" actual.err &&
102 test_grep ! "usage" actual.err
3bb0923f
PSU
103'
104
105test_expect_success 'for-each-ref usage error' '
106 test_must_fail git for-each-ref --noopt >actual 2>actual.err &&
107 test_line_count = 0 actual &&
6789275d 108 test_grep "usage" actual.err
3bb0923f
PSU
109'
110
111test_done