3 test_description
='git bugreport'
5 TEST_PASSES_SANITIZE_LEAK
=true
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
() {
16 if test "$(grep "$HEADER_PATTERN" "$line")"
20 if test -z "$nextline"; then
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-* &&
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 &&
63 test_when_finished rm -fr .git/hooks &&
66 for hook in applypatch-msg prepare-commit-msg.sample
68 write_script ".git/hooks/$hook" <<-EOF || return 1
69 echo "hook $hook exists"
72 git bugreport -s hooks &&
73 grep applypatch-msg git-bugreport-hooks.txt &&
74 ! grep prepare-commit-msg git-bugreport-hooks.txt