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