]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5409-colorize-remote-messages.sh
The sixth batch
[thirdparty/git.git] / t / t5409-colorize-remote-messages.sh
1 #!/bin/sh
2
3 test_description='remote messages are colorized on the client'
4
5 . ./test-lib.sh
6
7 test_expect_success 'setup' '
8 mkdir .git/hooks &&
9 write_script .git/hooks/update <<-\EOF &&
10 echo error: error
11 echo ERROR: also highlighted
12 echo hint: hint
13 echo hinting: not highlighted
14 echo success: success
15 echo warning: warning
16 echo prefixerror: error
17 echo " " "error: leading space"
18 echo " "
19 echo Err
20 echo SUCCESS
21 exit 0
22 EOF
23 echo 1 >file &&
24 git add file &&
25 git commit -m 1 &&
26 git clone . child &&
27 (
28 cd child &&
29 test_commit message2 file content2
30 )
31 '
32
33 test_expect_success 'keywords' '
34 git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/keywords 2>output &&
35 test_decode_color <output >decoded &&
36 grep "<BOLD;RED>error<RESET>: error" decoded &&
37 grep "<YELLOW>hint<RESET>:" decoded &&
38 grep "<BOLD;GREEN>success<RESET>:" decoded &&
39 grep "<BOLD;GREEN>SUCCESS<RESET>" decoded &&
40 grep "<BOLD;YELLOW>warning<RESET>:" decoded
41 '
42
43 test_expect_success 'whole words at line start' '
44 git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/whole-words 2>output &&
45 test_decode_color <output >decoded &&
46 grep "<YELLOW>hint<RESET>:" decoded &&
47 grep "hinting: not highlighted" decoded &&
48 grep "prefixerror: error" decoded
49 '
50
51 test_expect_success 'short line' '
52 git -C child -c color.remote=always push -f origin HEAD:short-line 2>output &&
53 test_decode_color <output >decoded &&
54 grep "remote: Err" decoded
55 '
56
57 test_expect_success 'case-insensitive' '
58 git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/case-insensitive 2>output &&
59 test_decode_color <output >decoded &&
60 grep "<BOLD;RED>error<RESET>: error" decoded &&
61 grep "<BOLD;RED>ERROR<RESET>: also highlighted" decoded
62 '
63
64 test_expect_success 'leading space' '
65 git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/leading-space 2>output &&
66 test_decode_color <output >decoded &&
67 grep " <BOLD;RED>error<RESET>: leading space" decoded
68 '
69
70 test_expect_success 'spaces only' '
71 git -C child -c color.remote=always push -f origin HEAD:only-space 2>output &&
72 test_decode_color <output >decoded &&
73 grep "remote: " decoded
74 '
75
76 test_expect_success 'no coloring for redirected output' '
77 git --git-dir child/.git push -f origin HEAD:refs/heads/redirected-output 2>output &&
78 test_decode_color <output >decoded &&
79 grep "error: error" decoded
80 '
81
82 test_expect_success 'push with customized color' '
83 git --git-dir child/.git -c color.remote=always -c color.remote.error=blue push -f origin HEAD:refs/heads/customized-color 2>output &&
84 test_decode_color <output >decoded &&
85 grep "<BLUE>error<RESET>:" decoded &&
86 grep "<BOLD;GREEN>success<RESET>:" decoded
87 '
88
89
90 test_expect_success 'error in customized color' '
91 git --git-dir child/.git -c color.remote=always -c color.remote.error=i-am-not-a-color push -f origin HEAD:refs/heads/error-customized-color 2>output &&
92 test_decode_color <output >decoded &&
93 grep "<BOLD;GREEN>success<RESET>:" decoded
94 '
95
96 test_expect_success 'fallback to color.ui' '
97 git --git-dir child/.git -c color.ui=always push -f origin HEAD:refs/heads/fallback-color-ui 2>output &&
98 test_decode_color <output >decoded &&
99 grep "<BOLD;RED>error<RESET>: error" decoded
100 '
101
102 test_done