]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0091-bugreport.sh
tests: teach callers of test_i18ngrep to use test_grep
[thirdparty/git.git] / t / t0091-bugreport.sh
CommitLineData
238b439d
ES
1#!/bin/sh
2
3test_description='git bugreport'
4
956d2e46 5TEST_PASSES_SANITIZE_LEAK=true
238b439d
ES
6. ./test-lib.sh
7
1aa92b85
8test_expect_success 'create a report' '
9 git bugreport -s format &&
10 test_file_not_empty git-bugreport-format.txt
11'
12
13test_expect_success 'report contains wanted template (before first section)' '
14 sed -ne "/^\[/q;p" git-bugreport-format.txt >actual &&
15 cat >expect <<-\EOF &&
16 Thank you for filling out a Git bug report!
17 Please answer the following questions to help us understand your issue.
18
19 What did you do before the bug happened? (Steps to reproduce your issue)
20
21 What did you expect to happen? (Expected behavior)
22
23 What happened instead? (Actual behavior)
24
25 What'\''s different between what you expected and what actually happened?
26
27 Anything else you want to add:
28
29 Please review the rest of the bug report below.
30 You can delete any lines you don'\''t wish to share.
31
32
33 EOF
34 test_cmp expect actual
35'
36
37test_expect_success 'sanity check "System Info" section' '
38 test_when_finished rm -f git-bugreport-format.txt &&
39
40 sed -ne "/^\[System Info\]$/,/^$/p" <git-bugreport-format.txt >system &&
41
42 # The beginning should match "git version --build-info" verbatim,
43 # but rather than checking bit-for-bit equality, just test some basics.
44 grep "git version [0-9]." system &&
45 grep "shell-path: ." system &&
46
47 # After the version, there should be some more info.
48 # This is bound to differ from environment to environment,
49 # so we just do some rather high-level checks.
50 grep "uname: ." system &&
51 grep "compiler info: ." system
238b439d
ES
52'
53
54test_expect_success 'dies if file with same name as report already exists' '
55 test_when_finished rm git-bugreport-duplicate.txt &&
56 >>git-bugreport-duplicate.txt &&
57 test_must_fail git bugreport --suffix duplicate
58'
59
60test_expect_success '--output-directory puts the report in the provided dir' '
61 test_when_finished rm -fr foo/ &&
62 git bugreport -o foo/ &&
63 test_path_is_file foo/git-bugreport-*
64'
65
66test_expect_success 'incorrect arguments abort with usage' '
67 test_must_fail git bugreport --false 2>output &&
6789275d 68 test_grep usage output &&
238b439d
ES
69 test_path_is_missing git-bugreport-*
70'
71
72test_expect_success 'runs outside of a git dir' '
73 test_when_finished rm non-repo/git-bugreport-* &&
74 nongit git bugreport
75'
76
77test_expect_success 'can create leading directories outside of a git dir' '
78 test_when_finished rm -fr foo/bar/baz &&
79 nongit git bugreport -o foo/bar/baz
80'
81
788a7760
ES
82test_expect_success 'indicates populated hooks' '
83 test_when_finished rm git-bugreport-hooks.txt &&
003cdf88
ÆAB
84
85 test_hook applypatch-msg <<-\EOF &&
86 true
87 EOF
88 test_hook unknown-hook <<-\EOF &&
89 true
90 EOF
788a7760 91 git bugreport -s hooks &&
003cdf88
ÆAB
92
93 sort >expect <<-\EOF &&
94 [Enabled Hooks]
95 applypatch-msg
96 EOF
97
98 sed -ne "/^\[Enabled Hooks\]$/,/^$/p" <git-bugreport-hooks.txt >actual &&
99 test_cmp expect actual
788a7760 100'
238b439d 101
aac0e8ff
VD
102test_expect_success UNZIP '--diagnose creates diagnostics zip archive' '
103 test_when_finished rm -rf report &&
104
105 git bugreport --diagnose -o report -s test >out &&
106
107 zip_path=report/git-diagnostics-test.zip &&
108 grep "Available space" out &&
109 test_path_is_file "$zip_path" &&
110
111 # Check zipped archive content
112 "$GIT_UNZIP" -p "$zip_path" diagnostics.log >out &&
113 test_file_not_empty out &&
114
115 "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out &&
116 grep ".git/objects" out &&
117
118 "$GIT_UNZIP" -p "$zip_path" objects-local.txt >out &&
119 grep "^Total: [0-9][0-9]*" out &&
120
121 # Should not include .git directory contents by default
122 ! "$GIT_UNZIP" -l "$zip_path" | grep ".git/"
123'
124
125test_expect_success UNZIP '--diagnose=stats excludes .git dir contents' '
126 test_when_finished rm -rf report &&
127
128 git bugreport --diagnose=stats -o report -s test >out &&
129
130 # Includes pack quantity/size info
131 "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out &&
132 grep ".git/objects" out &&
133
134 # Does not include .git directory contents
135 ! "$GIT_UNZIP" -l "$zip_path" | grep ".git/"
136'
137
138test_expect_success UNZIP '--diagnose=all includes .git dir contents' '
139 test_when_finished rm -rf report &&
140
141 git bugreport --diagnose=all -o report -s test >out &&
142
143 # Includes .git directory contents
144 "$GIT_UNZIP" -l "$zip_path" | grep ".git/" &&
145
146 "$GIT_UNZIP" -p "$zip_path" .git/HEAD >out &&
147 test_file_not_empty out
148'
149
238b439d 150test_done