t / t5409-colorize-remote-messages.shon commit rebase: fix regression in rebase.useBuiltin=false test mode (9aea5e9)
   1#!/bin/sh
   2
   3test_description='remote messages are colorized on the client'
   4
   5. ./test-lib.sh
   6
   7test_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
  33test_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
  43test_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
  51test_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
  57test_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        cat output &&
  60        test_decode_color <output >decoded &&
  61        grep "<BOLD;RED>error<RESET>: error" decoded &&
  62        grep "<BOLD;RED>ERROR<RESET>: also highlighted" decoded
  63'
  64
  65test_expect_success 'leading space' '
  66        git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/leading-space 2>output &&        cat output &&
  67        test_decode_color <output >decoded &&
  68        grep "  <BOLD;RED>error<RESET>: leading space" decoded
  69'
  70
  71test_expect_success 'spaces only' '
  72        git -C child -c color.remote=always push -f origin HEAD:only-space 2>output &&
  73        test_decode_color <output >decoded &&
  74        grep "remote:     " decoded
  75'
  76
  77test_expect_success 'no coloring for redirected output' '
  78        git --git-dir child/.git push -f origin HEAD:refs/heads/redirected-output 2>output &&
  79        test_decode_color <output >decoded &&
  80        grep "error: error" decoded
  81'
  82
  83test_expect_success 'push with customized color' '
  84        git --git-dir child/.git -c color.remote=always -c color.remote.error=blue push -f origin HEAD:refs/heads/customized-color 2>output &&
  85        test_decode_color <output >decoded &&
  86        grep "<BLUE>error<RESET>:" decoded &&
  87        grep "<BOLD;GREEN>success<RESET>:" decoded
  88'
  89
  90
  91test_expect_success 'error in customized color' '
  92        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 &&
  93        test_decode_color <output >decoded &&
  94        grep "<BOLD;GREEN>success<RESET>:" decoded
  95'
  96
  97test_expect_success 'fallback to color.ui' '
  98        git --git-dir child/.git -c color.ui=always push -f origin HEAD:refs/heads/fallback-color-ui 2>output &&
  99        test_decode_color <output >decoded &&
 100        grep "<BOLD;RED>error<RESET>: error" decoded
 101'
 102
 103test_done