]> git.ipfire.org Git - thirdparty/git.git/blob - t/t0091-bugreport.sh
clone: allow "--bare" with "-o"
[thirdparty/git.git] / t / t0091-bugreport.sh
1 #!/bin/sh
2
3 test_description='git bugreport'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 # Headers "[System Info]" will be followed by a non-empty line if we put some
9 # information there; we can make sure all our headers were followed by some
10 # information to check if the command was successful.
11 HEADER_PATTERN="^\[.*\]$"
12
13 check_all_headers_populated () {
14 while read -r line
15 do
16 if test "$(grep "$HEADER_PATTERN" "$line")"
17 then
18 echo "$line"
19 read -r nextline
20 if test -z "$nextline"; then
21 return 1;
22 fi
23 fi
24 done
25 }
26
27 test_expect_success 'creates a report with content in the right places' '
28 test_when_finished rm git-bugreport-check-headers.txt &&
29 git bugreport -s check-headers &&
30 check_all_headers_populated <git-bugreport-check-headers.txt
31 '
32
33 test_expect_success 'dies if file with same name as report already exists' '
34 test_when_finished rm git-bugreport-duplicate.txt &&
35 >>git-bugreport-duplicate.txt &&
36 test_must_fail git bugreport --suffix duplicate
37 '
38
39 test_expect_success '--output-directory puts the report in the provided dir' '
40 test_when_finished rm -fr foo/ &&
41 git bugreport -o foo/ &&
42 test_path_is_file foo/git-bugreport-*
43 '
44
45 test_expect_success 'incorrect arguments abort with usage' '
46 test_must_fail git bugreport --false 2>output &&
47 test_i18ngrep usage output &&
48 test_path_is_missing git-bugreport-*
49 '
50
51 test_expect_success 'runs outside of a git dir' '
52 test_when_finished rm non-repo/git-bugreport-* &&
53 nongit git bugreport
54 '
55
56 test_expect_success 'can create leading directories outside of a git dir' '
57 test_when_finished rm -fr foo/bar/baz &&
58 nongit git bugreport -o foo/bar/baz
59 '
60
61 test_expect_success 'indicates populated hooks' '
62 test_when_finished rm git-bugreport-hooks.txt &&
63
64 test_hook applypatch-msg <<-\EOF &&
65 true
66 EOF
67 test_hook unknown-hook <<-\EOF &&
68 true
69 EOF
70 git bugreport -s hooks &&
71
72 sort >expect <<-\EOF &&
73 [Enabled Hooks]
74 applypatch-msg
75 EOF
76
77 sed -ne "/^\[Enabled Hooks\]$/,/^$/p" <git-bugreport-hooks.txt >actual &&
78 test_cmp expect actual
79 '
80
81 test_done