builtin: patch-id: add --verbatim as a command mode
[git/debian.git] / t / t0091-bugreport.sh
blob08f5fe9caef0c8901e49401abf2762753d8a0b7c
1 #!/bin/sh
3 test_description='git bugreport'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
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="^\[.*\]$"
13 check_all_headers_populated () {
14 while read -r line
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;
24 done
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
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
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-*
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-*
51 test_expect_success 'runs outside of a git dir' '
52 test_when_finished rm non-repo/git-bugreport-* &&
53 nongit git bugreport
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
61 test_expect_success 'indicates populated hooks' '
62 test_when_finished rm git-bugreport-hooks.txt &&
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 &&
72 sort >expect <<-\EOF &&
73 [Enabled Hooks]
74 applypatch-msg
75 EOF
77 sed -ne "/^\[Enabled Hooks\]$/,/^$/p" <git-bugreport-hooks.txt >actual &&
78 test_cmp expect actual
81 test_done