t0018: two small fixes

Even though the three tests that were recently added started their here-doc with "<<-\EOF", it did not take advantage of that and instead wrote the here-doc payload abut to the left edge. Use a tabs to indent these lines. More importantly, because these all hardcode the expected output, which contains the current branch name, they break the CI job that uses 'main' as the default branch name. Use GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=trunk export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME between the test_description line and ". ./test-lib.sh" line to force the initial branch name to 'trunk' and expect it to show in the output. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed May 7, 2024 at 17:40 UTC cbdc83f1514963f86e8f027f9e75cde7f757c2a8
1 file changed +22 -19
t/t0018-advice.sh
+22 -19
@@ -2,6 +2,9 @@
2
3 test_description='Test advise_if_enabled functionality'
4
5 +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=trunk
6 +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 +
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
@@ -31,15 +34,15 @@ test_expect_success 'advice should not be printed when config variable is set to
34
35 test_expect_success 'advice should not be printed when --no-advice is used' '
36 q_to_tab >expect <<-\EOF &&
34 -On branch master
37 + On branch trunk
38
36 -No commits yet
39 + No commits yet
40
38 -Untracked files:
39 -QREADME
41 + Untracked files:
42 + QREADME
43
41 -nothing added to commit but untracked files present
42 -EOF
44 + nothing added to commit but untracked files present
45 + EOF
46
47 test_when_finished "rm -fr advice-test" &&
48 git init advice-test &&
@@ -53,15 +56,15 @@ EOF
56
57 test_expect_success 'advice should not be printed when GIT_ADVICE is set to false' '
58 q_to_tab >expect <<-\EOF &&
56 -On branch master
59 + On branch trunk
60
58 -No commits yet
61 + No commits yet
62
60 -Untracked files:
61 -QREADME
63 + Untracked files:
64 + QREADME
65
63 -nothing added to commit but untracked files present
64 -EOF
66 + nothing added to commit but untracked files present
67 + EOF
68
69 test_when_finished "rm -fr advice-test" &&
70 git init advice-test &&
@@ -75,16 +78,16 @@ EOF
78
79 test_expect_success 'advice should be printed when GIT_ADVICE is set to true' '
80 q_to_tab >expect <<-\EOF &&
78 -On branch master
81 + On branch trunk
82
80 -No commits yet
83 + No commits yet
84
82 -Untracked files:
83 - (use "git add <file>..." to include in what will be committed)
84 -QREADME
85 + Untracked files:
86 + (use "git add <file>..." to include in what will be committed)
87 + QREADME
88
86 -nothing added to commit but untracked files present (use "git add" to track)
87 -EOF
89 + nothing added to commit but untracked files present (use "git add" to track)
90 + EOF
91
92 test_when_finished "rm -fr advice-test" &&
93 git init advice-test &&