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