]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | ||
3 | test_description='Test commands behavior when given invalid argument value' | |
4 | ||
5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main | |
6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME | |
7 | ||
8 | TEST_PASSES_SANITIZE_LEAK=true | |
9 | . ./test-lib.sh | |
10 | ||
11 | test_expect_success 'setup ' ' | |
12 | test_commit "v1.0" | |
13 | ' | |
14 | ||
15 | test_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 | ||
21 | test_expect_success 'tag --contains <inexistent_tag>' ' | |
22 | test_must_fail git tag --contains "notag" >actual 2>actual.err && | |
23 | test_line_count = 0 actual && | |
24 | test_grep "error" actual.err && | |
25 | test_grep ! "usage" actual.err | |
26 | ' | |
27 | ||
28 | test_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 | ||
34 | test_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 && | |
37 | test_grep "error" actual.err && | |
38 | test_grep ! "usage" actual.err | |
39 | ' | |
40 | ||
41 | test_expect_success 'tag usage error' ' | |
42 | test_must_fail git tag --noopt >actual 2>actual.err && | |
43 | test_line_count = 0 actual && | |
44 | test_grep "usage" actual.err | |
45 | ' | |
46 | ||
47 | test_expect_success 'branch --contains <existent_commit>' ' | |
48 | git branch --contains "main" >actual 2>actual.err && | |
49 | test_grep "main" actual && | |
50 | test_line_count = 0 actual.err | |
51 | ' | |
52 | ||
53 | test_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 && | |
56 | test_grep "error" actual.err && | |
57 | test_grep ! "usage" actual.err | |
58 | ' | |
59 | ||
60 | test_expect_success 'branch --no-contains <existent_commit>' ' | |
61 | git branch --no-contains "main" >actual 2>actual.err && | |
62 | test_line_count = 0 actual && | |
63 | test_line_count = 0 actual.err | |
64 | ' | |
65 | ||
66 | test_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 && | |
69 | test_grep "error" actual.err && | |
70 | test_grep ! "usage" actual.err | |
71 | ' | |
72 | ||
73 | test_expect_success 'branch usage error' ' | |
74 | test_must_fail git branch --noopt >actual 2>actual.err && | |
75 | test_line_count = 0 actual && | |
76 | test_grep "usage" actual.err | |
77 | ' | |
78 | ||
79 | test_expect_success 'for-each-ref --contains <existent_object>' ' | |
80 | git for-each-ref --contains "main" >actual 2>actual.err && | |
81 | test_line_count = 2 actual && | |
82 | test_line_count = 0 actual.err | |
83 | ' | |
84 | ||
85 | test_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 && | |
88 | test_grep "error" actual.err && | |
89 | test_grep ! "usage" actual.err | |
90 | ' | |
91 | ||
92 | test_expect_success 'for-each-ref --no-contains <existent_object>' ' | |
93 | git for-each-ref --no-contains "main" >actual 2>actual.err && | |
94 | test_line_count = 0 actual && | |
95 | test_line_count = 0 actual.err | |
96 | ' | |
97 | ||
98 | test_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 && | |
101 | test_grep "error" actual.err && | |
102 | test_grep ! "usage" actual.err | |
103 | ' | |
104 | ||
105 | test_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 && | |
108 | test_grep "usage" actual.err | |
109 | ' | |
110 | ||
111 | test_done |