diff options
author | Jeff King <peff@peff.net> | 2017-07-13 14:58:41 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-07-13 19:42:50 (GMT) |
commit | 097b681baac3a5e9455c74e3072a458249691e40 (patch) | |
tree | fc7ea06a96e684f7ce2b1577a374b68cfb5ba889 /t/t4207-log-decoration-colors.sh | |
parent | 5d3d0681abb8f2bc2383ee7660cf2b02e89cdd07 (diff) | |
download | git-097b681baac3a5e9455c74e3072a458249691e40.zip git-097b681baac3a5e9455c74e3072a458249691e40.tar.gz git-097b681baac3a5e9455c74e3072a458249691e40.tar.bz2 |
t: use test_decode_color rather than literal ANSI codes
When we put literal ANSI terminal codes into our test
scripts, it makes diffs on those scripts hard to read (the
colors may be indistinguishable from diff coloring, or in
the case of a reset, may not be visible at all).
Some scripts get around this by including human-readable
names and converting to literal codes with a git-config
hack. This makes the actual code diffs look OK, but test_cmp
output suffers from the same problem.
Let's use test_decode_color instead, which turns the codes
into obvious text tags.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4207-log-decoration-colors.sh')
-rwxr-xr-x | t/t4207-log-decoration-colors.sh | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/t/t4207-log-decoration-colors.sh b/t/t4207-log-decoration-colors.sh index b972296..60f040c 100755 --- a/t/t4207-log-decoration-colors.sh +++ b/t/t4207-log-decoration-colors.sh @@ -7,11 +7,6 @@ test_description='Test for "git log --decorate" colors' . ./test-lib.sh -get_color () -{ - git config --get-color no.such.slot "$1" -} - test_expect_success setup ' git config diff.color.commit yellow && git config color.decorate.branch green && @@ -20,14 +15,14 @@ test_expect_success setup ' git config color.decorate.stash magenta && git config color.decorate.HEAD cyan && - c_reset=$(get_color reset) && + c_reset="<RESET>" && - c_commit=$(get_color yellow) && - c_branch=$(get_color green) && - c_remoteBranch=$(get_color red) && - c_tag=$(get_color "reverse bold yellow") && - c_stash=$(get_color magenta) && - c_HEAD=$(get_color cyan) && + c_commit="<YELLOW>" && + c_branch="<GREEN>" && + c_remoteBranch="<RED>" && + c_tag="<BOLD;REVERSE;YELLOW>" && + c_stash="<MAGENTA>" && + c_HEAD="<CYAN>" && test_commit A && git clone . other && @@ -59,7 +54,8 @@ EOF # to this test since it does not contain any decoration, hence --first-parent test_expect_success 'Commit Decorations Colored Correctly' ' git log --first-parent --abbrev=10 --all --decorate --oneline --color=always | - sed "s/[0-9a-f]\{10,10\}/COMMIT_ID/" >out && + sed "s/[0-9a-f]\{10,10\}/COMMIT_ID/" | + test_decode_color >out && test_cmp expected out ' |