commit-reach: fix in_merge_bases_many bug
[git/debian.git] / t / t0091-bugreport.sh
blob526304ff95b3e91e7db69f823bfc0e173b4e0764
1 #!/bin/sh
3 test_description='git bugreport'
5 . ./test-lib.sh
7 # Headers "[System Info]" will be followed by a non-empty line if we put some
8 # information there; we can make sure all our headers were followed by some
9 # information to check if the command was successful.
10 HEADER_PATTERN="^\[.*\]$"
12 check_all_headers_populated () {
13 while read -r line
15 if test "$(grep "$HEADER_PATTERN" "$line")"
16 then
17 echo "$line"
18 read -r nextline
19 if test -z "$nextline"; then
20 return 1;
23 done
26 test_expect_success 'creates a report with content in the right places' '
27 test_when_finished rm git-bugreport-check-headers.txt &&
28 git bugreport -s check-headers &&
29 check_all_headers_populated <git-bugreport-check-headers.txt
32 test_expect_success 'dies if file with same name as report already exists' '
33 test_when_finished rm git-bugreport-duplicate.txt &&
34 >>git-bugreport-duplicate.txt &&
35 test_must_fail git bugreport --suffix duplicate
38 test_expect_success '--output-directory puts the report in the provided dir' '
39 test_when_finished rm -fr foo/ &&
40 git bugreport -o foo/ &&
41 test_path_is_file foo/git-bugreport-*
44 test_expect_success 'incorrect arguments abort with usage' '
45 test_must_fail git bugreport --false 2>output &&
46 test_i18ngrep usage output &&
47 test_path_is_missing git-bugreport-*
50 test_expect_success 'runs outside of a git dir' '
51 test_when_finished rm non-repo/git-bugreport-* &&
52 nongit git bugreport
55 test_expect_success 'can create leading directories outside of a git dir' '
56 test_when_finished rm -fr foo/bar/baz &&
57 nongit git bugreport -o foo/bar/baz
60 test_expect_success 'indicates populated hooks' '
61 test_when_finished rm git-bugreport-hooks.txt &&
62 test_when_finished rm -fr .git/hooks &&
63 rm -fr .git/hooks &&
64 mkdir .git/hooks &&
65 for hook in applypatch-msg prepare-commit-msg.sample
67 write_script ".git/hooks/$hook" <<-EOF || return 1
68 echo "hook $hook exists"
69 EOF
70 done &&
71 git bugreport -s hooks &&
72 grep applypatch-msg git-bugreport-hooks.txt &&
73 ! grep prepare-commit-msg git-bugreport-hooks.txt
76 test_done