mirror of
https://github.com/git/git.git
synced 2024-11-23 18:05:29 +08:00
7da7f63cf9
Add a "test_hook" wrapper similar to the existing "test_config"
wrapper added in d960c47a88
(test-lib: add helper functions for
config, 2011-08-17).
This wrapper:
- Will clean up the hook with "test_when_finished", unless --setup is
provided.
- Will error if we clobber a hook, unless --clobber is provided.
- Takes a name like "update" instead of ".git/hooks/update".
- Accepts -C <dir>, like "test_config" and "test_commit".
By using a wrapper we'll be able to easily change all the hook-related
code that assumes that the template-created ".git/hooks" directory is
created by "init", "clone" etc. once another topic follows-up and
changes the test suite to stop creating trash directories using those
templates.
In addition this will make it easy to have the hooks configured using
the "configuration-based hooks" topic, once we get around to
integrating that. I.e. we'll be able to run the tests in a mode where
we sometimes create a .git/hooks/<name>, and other times create a
script in another location, and point the relevant configuration
snippet to it.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
102 lines
3.2 KiB
Bash
Executable File
102 lines
3.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='remote messages are colorized on the client'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'setup' '
|
|
test_hook --setup update <<-\EOF &&
|
|
echo error: error
|
|
echo ERROR: also highlighted
|
|
echo hint: hint
|
|
echo hinting: not highlighted
|
|
echo success: success
|
|
echo warning: warning
|
|
echo prefixerror: error
|
|
echo " " "error: leading space"
|
|
echo " "
|
|
echo Err
|
|
echo SUCCESS
|
|
exit 0
|
|
EOF
|
|
echo 1 >file &&
|
|
git add file &&
|
|
git commit -m 1 &&
|
|
git clone . child &&
|
|
(
|
|
cd child &&
|
|
test_commit message2 file content2
|
|
)
|
|
'
|
|
|
|
test_expect_success 'keywords' '
|
|
git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/keywords 2>output &&
|
|
test_decode_color <output >decoded &&
|
|
grep "<BOLD;RED>error<RESET>: error" decoded &&
|
|
grep "<YELLOW>hint<RESET>:" decoded &&
|
|
grep "<BOLD;GREEN>success<RESET>:" decoded &&
|
|
grep "<BOLD;GREEN>SUCCESS<RESET>" decoded &&
|
|
grep "<BOLD;YELLOW>warning<RESET>:" decoded
|
|
'
|
|
|
|
test_expect_success 'whole words at line start' '
|
|
git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/whole-words 2>output &&
|
|
test_decode_color <output >decoded &&
|
|
grep "<YELLOW>hint<RESET>:" decoded &&
|
|
grep "hinting: not highlighted" decoded &&
|
|
grep "prefixerror: error" decoded
|
|
'
|
|
|
|
test_expect_success 'short line' '
|
|
git -C child -c color.remote=always push -f origin HEAD:short-line 2>output &&
|
|
test_decode_color <output >decoded &&
|
|
grep "remote: Err" decoded
|
|
'
|
|
|
|
test_expect_success 'case-insensitive' '
|
|
git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/case-insensitive 2>output &&
|
|
test_decode_color <output >decoded &&
|
|
grep "<BOLD;RED>error<RESET>: error" decoded &&
|
|
grep "<BOLD;RED>ERROR<RESET>: also highlighted" decoded
|
|
'
|
|
|
|
test_expect_success 'leading space' '
|
|
git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/leading-space 2>output &&
|
|
test_decode_color <output >decoded &&
|
|
grep " <BOLD;RED>error<RESET>: leading space" decoded
|
|
'
|
|
|
|
test_expect_success 'spaces only' '
|
|
git -C child -c color.remote=always push -f origin HEAD:only-space 2>output &&
|
|
test_decode_color <output >decoded &&
|
|
grep "remote: " decoded
|
|
'
|
|
|
|
test_expect_success 'no coloring for redirected output' '
|
|
git --git-dir child/.git push -f origin HEAD:refs/heads/redirected-output 2>output &&
|
|
test_decode_color <output >decoded &&
|
|
grep "error: error" decoded
|
|
'
|
|
|
|
test_expect_success 'push with customized color' '
|
|
git --git-dir child/.git -c color.remote=always -c color.remote.error=blue push -f origin HEAD:refs/heads/customized-color 2>output &&
|
|
test_decode_color <output >decoded &&
|
|
grep "<BLUE>error<RESET>:" decoded &&
|
|
grep "<BOLD;GREEN>success<RESET>:" decoded
|
|
'
|
|
|
|
|
|
test_expect_success 'error in customized color' '
|
|
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 &&
|
|
test_decode_color <output >decoded &&
|
|
grep "<BOLD;GREEN>success<RESET>:" decoded
|
|
'
|
|
|
|
test_expect_success 'fallback to color.ui' '
|
|
git --git-dir child/.git -c color.ui=always push -f origin HEAD:refs/heads/fallback-color-ui 2>output &&
|
|
test_decode_color <output >decoded &&
|
|
grep "<BOLD;RED>error<RESET>: error" decoded
|
|
'
|
|
|
|
test_done
|