Merge branch 'cl/config-regexp-docfix' into maint-2.46
[git/gitster.git] / t / t0018-advice.sh
blobfac52322a7f6739ce95feea6b527edce00941361
1 #!/bin/sh
3 test_description='Test advise_if_enabled functionality'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=trunk
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 test_expect_success 'advice should be printed when config variable is unset' '
12 cat >expect <<-\EOF &&
13 hint: This is a piece of advice
14 hint: Disable this message with "git config advice.nestedTag false"
15 EOF
16 test-tool advise "This is a piece of advice" 2>actual &&
17 test_cmp expect actual
20 test_expect_success 'advice should be printed when config variable is set to true' '
21 cat >expect <<-\EOF &&
22 hint: This is a piece of advice
23 EOF
24 test_config advice.nestedTag true &&
25 test-tool advise "This is a piece of advice" 2>actual &&
26 test_cmp expect actual
29 test_expect_success 'advice should not be printed when config variable is set to false' '
30 test_config advice.nestedTag false &&
31 test-tool advise "This is a piece of advice" 2>actual &&
32 test_must_be_empty actual
35 test_expect_success 'advice should not be printed when --no-advice is used' '
36 q_to_tab >expect <<-\EOF &&
37 On branch trunk
39 No commits yet
41 Untracked files:
42 QREADME
44 nothing added to commit but untracked files present
45 EOF
47 test_when_finished "rm -fr advice-test" &&
48 git init advice-test &&
50 cd advice-test &&
51 >README &&
52 git --no-advice status
53 ) >actual &&
54 test_cmp expect actual
57 test_expect_success 'advice should not be printed when GIT_ADVICE is set to false' '
58 q_to_tab >expect <<-\EOF &&
59 On branch trunk
61 No commits yet
63 Untracked files:
64 QREADME
66 nothing added to commit but untracked files present
67 EOF
69 test_when_finished "rm -fr advice-test" &&
70 git init advice-test &&
72 cd advice-test &&
73 >README &&
74 GIT_ADVICE=false git status
75 ) >actual &&
76 test_cmp expect actual
79 test_expect_success 'advice should be printed when GIT_ADVICE is set to true' '
80 q_to_tab >expect <<-\EOF &&
81 On branch trunk
83 No commits yet
85 Untracked files:
86 (use "git add <file>..." to include in what will be committed)
87 QREADME
89 nothing added to commit but untracked files present (use "git add" to track)
90 EOF
92 test_when_finished "rm -fr advice-test" &&
93 git init advice-test &&
95 cd advice-test &&
96 >README &&
97 GIT_ADVICE=true git status
98 ) >actual &&
99 test_cmp expect actual
102 test_done