t7508-status: test all modes with color
Move a useful script function to decode colored output to text form from t4034 and use it in this test as well. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
c521bb7114
commit
68cfc6f551
@ -11,18 +11,9 @@ test_expect_success setup '
|
|||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
decrypt_color () {
|
|
||||||
sed \
|
|
||||||
-e 's/.\[1m/<WHITE>/g' \
|
|
||||||
-e 's/.\[31m/<RED>/g' \
|
|
||||||
-e 's/.\[32m/<GREEN>/g' \
|
|
||||||
-e 's/.\[36m/<BROWN>/g' \
|
|
||||||
-e 's/.\[m/<RESET>/g'
|
|
||||||
}
|
|
||||||
|
|
||||||
word_diff () {
|
word_diff () {
|
||||||
test_must_fail git diff --no-index "$@" pre post > output &&
|
test_must_fail git diff --no-index "$@" pre post > output &&
|
||||||
decrypt_color < output > output.decrypted &&
|
test_decode_color <output >output.decrypted &&
|
||||||
test_cmp expect output.decrypted
|
test_cmp expect output.decrypted
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +38,7 @@ cat > expect <<\EOF
|
|||||||
<WHITE>index 330b04f..5ed8eff 100644<RESET>
|
<WHITE>index 330b04f..5ed8eff 100644<RESET>
|
||||||
<WHITE>--- a/pre<RESET>
|
<WHITE>--- a/pre<RESET>
|
||||||
<WHITE>+++ b/post<RESET>
|
<WHITE>+++ b/post<RESET>
|
||||||
<BROWN>@@ -1,3 +1,7 @@<RESET>
|
<CYAN>@@ -1,3 +1,7 @@<RESET>
|
||||||
<RED>h(4)<RESET><GREEN>h(4),hh[44]<RESET>
|
<RED>h(4)<RESET><GREEN>h(4),hh[44]<RESET>
|
||||||
<RESET>
|
<RESET>
|
||||||
a = b + c<RESET>
|
a = b + c<RESET>
|
||||||
@ -68,7 +59,7 @@ cat > expect <<\EOF
|
|||||||
<WHITE>index 330b04f..5ed8eff 100644<RESET>
|
<WHITE>index 330b04f..5ed8eff 100644<RESET>
|
||||||
<WHITE>--- a/pre<RESET>
|
<WHITE>--- a/pre<RESET>
|
||||||
<WHITE>+++ b/post<RESET>
|
<WHITE>+++ b/post<RESET>
|
||||||
<BROWN>@@ -1,3 +1,7 @@<RESET>
|
<CYAN>@@ -1,3 +1,7 @@<RESET>
|
||||||
h(4),<GREEN>hh<RESET>[44]
|
h(4),<GREEN>hh<RESET>[44]
|
||||||
<RESET>
|
<RESET>
|
||||||
a = b + c<RESET>
|
a = b + c<RESET>
|
||||||
@ -104,7 +95,7 @@ cat > expect <<\EOF
|
|||||||
<WHITE>index 330b04f..5ed8eff 100644<RESET>
|
<WHITE>index 330b04f..5ed8eff 100644<RESET>
|
||||||
<WHITE>--- a/pre<RESET>
|
<WHITE>--- a/pre<RESET>
|
||||||
<WHITE>+++ b/post<RESET>
|
<WHITE>+++ b/post<RESET>
|
||||||
<BROWN>@@ -1,3 +1,7 @@<RESET>
|
<CYAN>@@ -1,3 +1,7 @@<RESET>
|
||||||
h(4)<GREEN>,hh[44]<RESET>
|
h(4)<GREEN>,hh[44]<RESET>
|
||||||
<RESET>
|
<RESET>
|
||||||
a = b + c<RESET>
|
a = b + c<RESET>
|
||||||
@ -146,7 +137,7 @@ cat > expect <<\EOF
|
|||||||
<WHITE>index 330b04f..5ed8eff 100644<RESET>
|
<WHITE>index 330b04f..5ed8eff 100644<RESET>
|
||||||
<WHITE>--- a/pre<RESET>
|
<WHITE>--- a/pre<RESET>
|
||||||
<WHITE>+++ b/post<RESET>
|
<WHITE>+++ b/post<RESET>
|
||||||
<BROWN>@@ -1,3 +1,7 @@<RESET>
|
<CYAN>@@ -1,3 +1,7 @@<RESET>
|
||||||
h(4),<GREEN>hh[44<RESET>]
|
h(4),<GREEN>hh[44<RESET>]
|
||||||
<RESET>
|
<RESET>
|
||||||
a = b + c<RESET>
|
a = b + c<RESET>
|
||||||
@ -168,7 +159,7 @@ cat > expect <<\EOF
|
|||||||
<WHITE>index c29453b..be22f37 100644<RESET>
|
<WHITE>index c29453b..be22f37 100644<RESET>
|
||||||
<WHITE>--- a/pre<RESET>
|
<WHITE>--- a/pre<RESET>
|
||||||
<WHITE>+++ b/post<RESET>
|
<WHITE>+++ b/post<RESET>
|
||||||
<BROWN>@@ -1 +1 @@<RESET>
|
<CYAN>@@ -1 +1 @@<RESET>
|
||||||
aaa (aaa) <GREEN>aaa<RESET>
|
aaa (aaa) <GREEN>aaa<RESET>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@ -187,7 +178,7 @@ cat > expect <<\EOF
|
|||||||
<WHITE>index 289cb9d..2d06f37 100644<RESET>
|
<WHITE>index 289cb9d..2d06f37 100644<RESET>
|
||||||
<WHITE>--- a/pre<RESET>
|
<WHITE>--- a/pre<RESET>
|
||||||
<WHITE>+++ b/post<RESET>
|
<WHITE>+++ b/post<RESET>
|
||||||
<BROWN>@@ -1 +1 @@<RESET>
|
<CYAN>@@ -1 +1 @@<RESET>
|
||||||
(<RED>:<RESET>
|
(<RED>:<RESET>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
@ -8,26 +8,26 @@ test_description='git status'
|
|||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
test_expect_success 'setup' '
|
test_expect_success 'setup' '
|
||||||
: > tracked &&
|
: >tracked &&
|
||||||
: > modified &&
|
: >modified &&
|
||||||
mkdir dir1 &&
|
mkdir dir1 &&
|
||||||
: > dir1/tracked &&
|
: >dir1/tracked &&
|
||||||
: > dir1/modified &&
|
: >dir1/modified &&
|
||||||
mkdir dir2 &&
|
mkdir dir2 &&
|
||||||
: > dir1/tracked &&
|
: >dir1/tracked &&
|
||||||
: > dir1/modified &&
|
: >dir1/modified &&
|
||||||
git add . &&
|
git add . &&
|
||||||
|
|
||||||
git status >output &&
|
git status >output &&
|
||||||
|
|
||||||
test_tick &&
|
test_tick &&
|
||||||
git commit -m initial &&
|
git commit -m initial &&
|
||||||
: > untracked &&
|
: >untracked &&
|
||||||
: > dir1/untracked &&
|
: >dir1/untracked &&
|
||||||
: > dir2/untracked &&
|
: >dir2/untracked &&
|
||||||
echo 1 > dir1/modified &&
|
echo 1 >dir1/modified &&
|
||||||
echo 2 > dir2/modified &&
|
echo 2 >dir2/modified &&
|
||||||
echo 3 > dir2/added &&
|
echo 3 >dir2/added &&
|
||||||
git add dir2/added
|
git add dir2/added
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ test_expect_success 'status (1)' '
|
|||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
cat > expect << \EOF
|
cat >expect <<\EOF
|
||||||
# On branch master
|
# On branch master
|
||||||
# Changes to be committed:
|
# Changes to be committed:
|
||||||
# (use "git reset HEAD <file>..." to unstage)
|
# (use "git reset HEAD <file>..." to unstage)
|
||||||
@ -63,12 +63,12 @@ EOF
|
|||||||
|
|
||||||
test_expect_success 'status (2)' '
|
test_expect_success 'status (2)' '
|
||||||
|
|
||||||
git status > output &&
|
git status >output &&
|
||||||
test_cmp expect output
|
test_cmp expect output
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
cat > expect << \EOF
|
cat >expect <<\EOF
|
||||||
M dir1/modified
|
M dir1/modified
|
||||||
A dir2/added
|
A dir2/added
|
||||||
?? dir1/untracked
|
?? dir1/untracked
|
||||||
@ -81,7 +81,7 @@ EOF
|
|||||||
|
|
||||||
test_expect_success 'status -s (2)' '
|
test_expect_success 'status -s (2)' '
|
||||||
|
|
||||||
git status -s > output &&
|
git status -s >output &&
|
||||||
test_cmp expect output
|
test_cmp expect output
|
||||||
|
|
||||||
'
|
'
|
||||||
@ -103,8 +103,8 @@ cat >expect <<EOF
|
|||||||
EOF
|
EOF
|
||||||
test_expect_success 'status -uno' '
|
test_expect_success 'status -uno' '
|
||||||
mkdir dir3 &&
|
mkdir dir3 &&
|
||||||
: > dir3/untracked1 &&
|
: >dir3/untracked1 &&
|
||||||
: > dir3/untracked2 &&
|
: >dir3/untracked2 &&
|
||||||
git status -uno >output &&
|
git status -uno >output &&
|
||||||
test_cmp expect output
|
test_cmp expect output
|
||||||
'
|
'
|
||||||
@ -249,7 +249,7 @@ test_expect_success 'status -s (status.showUntrackedFiles all)' '
|
|||||||
test_cmp expect output
|
test_cmp expect output
|
||||||
'
|
'
|
||||||
|
|
||||||
cat > expect << \EOF
|
cat >expect <<\EOF
|
||||||
# On branch master
|
# On branch master
|
||||||
# Changes to be committed:
|
# Changes to be committed:
|
||||||
# (use "git reset HEAD <file>..." to unstage)
|
# (use "git reset HEAD <file>..." to unstage)
|
||||||
@ -275,12 +275,12 @@ EOF
|
|||||||
|
|
||||||
test_expect_success 'status with relative paths' '
|
test_expect_success 'status with relative paths' '
|
||||||
|
|
||||||
(cd dir1 && git status) > output &&
|
(cd dir1 && git status) >output &&
|
||||||
test_cmp expect output
|
test_cmp expect output
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
cat > expect << \EOF
|
cat >expect <<\EOF
|
||||||
M modified
|
M modified
|
||||||
A ../dir2/added
|
A ../dir2/added
|
||||||
?? untracked
|
?? untracked
|
||||||
@ -292,12 +292,12 @@ A ../dir2/added
|
|||||||
EOF
|
EOF
|
||||||
test_expect_success 'status -s with relative paths' '
|
test_expect_success 'status -s with relative paths' '
|
||||||
|
|
||||||
(cd dir1 && git status -s) > output &&
|
(cd dir1 && git status -s) >output &&
|
||||||
test_cmp expect output
|
test_cmp expect output
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
cat > expect << \EOF
|
cat >expect <<\EOF
|
||||||
M dir1/modified
|
M dir1/modified
|
||||||
A dir2/added
|
A dir2/added
|
||||||
?? dir1/untracked
|
?? dir1/untracked
|
||||||
@ -310,12 +310,121 @@ EOF
|
|||||||
|
|
||||||
test_expect_success 'status --porcelain ignores relative paths setting' '
|
test_expect_success 'status --porcelain ignores relative paths setting' '
|
||||||
|
|
||||||
(cd dir1 && git status --porcelain) > output &&
|
(cd dir1 && git status --porcelain) >output &&
|
||||||
test_cmp expect output
|
test_cmp expect output
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
cat > expect << \EOF
|
test_expect_success 'setup unique colors' '
|
||||||
|
|
||||||
|
git config status.color.untracked blue
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
|
cat >expect <<\EOF
|
||||||
|
# On branch master
|
||||||
|
# Changes to be committed:
|
||||||
|
# (use "git reset HEAD <file>..." to unstage)
|
||||||
|
#
|
||||||
|
# <GREEN>new file: dir2/added<RESET>
|
||||||
|
#
|
||||||
|
# Changed but not updated:
|
||||||
|
# (use "git add <file>..." to update what will be committed)
|
||||||
|
# (use "git checkout -- <file>..." to discard changes in working directory)
|
||||||
|
#
|
||||||
|
# <RED>modified: dir1/modified<RESET>
|
||||||
|
#
|
||||||
|
# Untracked files:
|
||||||
|
# (use "git add <file>..." to include in what will be committed)
|
||||||
|
#
|
||||||
|
# <BLUE>dir1/untracked<RESET>
|
||||||
|
# <BLUE>dir2/modified<RESET>
|
||||||
|
# <BLUE>dir2/untracked<RESET>
|
||||||
|
# <BLUE>expect<RESET>
|
||||||
|
# <BLUE>output<RESET>
|
||||||
|
# <BLUE>untracked<RESET>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success 'status with color.ui' '
|
||||||
|
|
||||||
|
git config color.ui always &&
|
||||||
|
git status | test_decode_color >output &&
|
||||||
|
test_cmp expect output
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'status with color.status' '
|
||||||
|
|
||||||
|
git config --unset color.ui &&
|
||||||
|
git config color.status always &&
|
||||||
|
git status | test_decode_color >output &&
|
||||||
|
test_cmp expect output
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
|
cat >expect <<\EOF
|
||||||
|
<RED>M<RESET> dir1/modified
|
||||||
|
<GREEN>A<RESET> dir2/added
|
||||||
|
<BLUE>??<RESET> dir1/untracked
|
||||||
|
<BLUE>??<RESET> dir2/modified
|
||||||
|
<BLUE>??<RESET> dir2/untracked
|
||||||
|
<BLUE>??<RESET> expect
|
||||||
|
<BLUE>??<RESET> output
|
||||||
|
<BLUE>??<RESET> untracked
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success 'status -s with color.ui' '
|
||||||
|
|
||||||
|
git config --unset color.status &&
|
||||||
|
git config color.ui always &&
|
||||||
|
git status -s | test_decode_color >output &&
|
||||||
|
test_cmp expect output
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'status -s with color.status' '
|
||||||
|
|
||||||
|
git config --unset color.ui &&
|
||||||
|
git config color.status always &&
|
||||||
|
git status -s | test_decode_color >output &&
|
||||||
|
test_cmp expect output
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
|
cat >expect <<\EOF
|
||||||
|
M dir1/modified
|
||||||
|
A dir2/added
|
||||||
|
?? dir1/untracked
|
||||||
|
?? dir2/modified
|
||||||
|
?? dir2/untracked
|
||||||
|
?? expect
|
||||||
|
?? output
|
||||||
|
?? untracked
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success 'status --porcelain ignores color.ui' '
|
||||||
|
|
||||||
|
git config --unset color.status &&
|
||||||
|
git config color.ui always &&
|
||||||
|
git status --porcelain | test_decode_color >output &&
|
||||||
|
test_cmp expect output
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'status --porcelain ignores color.status' '
|
||||||
|
|
||||||
|
git config --unset color.ui &&
|
||||||
|
git config color.status always &&
|
||||||
|
git status --porcelain | test_decode_color >output &&
|
||||||
|
test_cmp expect output
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
|
# recover unconditionally from color tests
|
||||||
|
git config --unset color.status
|
||||||
|
git config --unset color.ui
|
||||||
|
|
||||||
|
cat >expect <<\EOF
|
||||||
# On branch master
|
# On branch master
|
||||||
# Changes to be committed:
|
# Changes to be committed:
|
||||||
# (use "git reset HEAD <file>..." to unstage)
|
# (use "git reset HEAD <file>..." to unstage)
|
||||||
@ -339,15 +448,16 @@ cat > expect << \EOF
|
|||||||
# untracked
|
# untracked
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
test_expect_success 'status without relative paths' '
|
test_expect_success 'status without relative paths' '
|
||||||
|
|
||||||
git config status.relativePaths false
|
git config status.relativePaths false
|
||||||
(cd dir1 && git status) > output &&
|
(cd dir1 && git status) >output &&
|
||||||
test_cmp expect output
|
test_cmp expect output
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
cat > expect << \EOF
|
cat >expect <<\EOF
|
||||||
M dir1/modified
|
M dir1/modified
|
||||||
A dir2/added
|
A dir2/added
|
||||||
?? dir1/untracked
|
?? dir1/untracked
|
||||||
@ -360,7 +470,7 @@ EOF
|
|||||||
|
|
||||||
test_expect_success 'status -s without relative paths' '
|
test_expect_success 'status -s without relative paths' '
|
||||||
|
|
||||||
(cd dir1 && git status -s) > output &&
|
(cd dir1 && git status -s) >output &&
|
||||||
test_cmp expect output
|
test_cmp expect output
|
||||||
|
|
||||||
'
|
'
|
||||||
|
@ -208,6 +208,17 @@ test_set_editor () {
|
|||||||
export VISUAL
|
export VISUAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_decode_color () {
|
||||||
|
sed -e 's/.\[1m/<WHITE>/g' \
|
||||||
|
-e 's/.\[31m/<RED>/g' \
|
||||||
|
-e 's/.\[32m/<GREEN>/g' \
|
||||||
|
-e 's/.\[33m/<YELLOW>/g' \
|
||||||
|
-e 's/.\[34m/<BLUE>/g' \
|
||||||
|
-e 's/.\[35m/<MAGENTA>/g' \
|
||||||
|
-e 's/.\[36m/<CYAN>/g' \
|
||||||
|
-e 's/.\[m/<RESET>/g'
|
||||||
|
}
|
||||||
|
|
||||||
test_tick () {
|
test_tick () {
|
||||||
if test -z "${test_tick+set}"
|
if test -z "${test_tick+set}"
|
||||||
then
|
then
|
||||||
|
Reference in New Issue
Block a user