Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-03-03 02:07:19 +0300
committerJunio C Hamano <gitster@pobox.com>2020-03-03 02:07:19 +0300
commit46703057c1a0f85e24c0144b38c226c6a9ccb737 (patch)
treeb1f0913b35341d5055b214df6cd24db376ab41cd /t
parent777815f5f97da6a41233fa2bb6ecbcb111929d1c (diff)
parentffe005576ac2bd46021fc80112ba7e8e0ab5dd10 (diff)
Merge branch 'ak/test-log-graph'
Test update. * ak/test-log-graph: lib-log-graph: consolidate colored graph cmp logic lib-log-graph: consolidate test_cmp_graph logic
Diffstat (limited to 't')
-rwxr-xr-xt/lib-log-graph.sh28
-rwxr-xr-xt/t3430-rebase-merges.sh5
-rwxr-xr-xt/t4202-log.sh57
-rwxr-xr-xt/t4214-log-graph-octopus.sh82
-rwxr-xr-xt/t4215-log-skewed-merges.sh9
5 files changed, 74 insertions, 107 deletions
diff --git a/t/lib-log-graph.sh b/t/lib-log-graph.sh
new file mode 100755
index 0000000000..1184cceef2
--- /dev/null
+++ b/t/lib-log-graph.sh
@@ -0,0 +1,28 @@
+# Helps shared by the test scripts for comparing log graphs.
+
+sanitize_log_output () {
+ sed -e 's/ *$//' \
+ -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
+ -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
+ -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
+ -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
+ -e 's/index [0-9a-f]*\.\.[0-9a-f]*/index BEFORE..AFTER/'
+}
+
+lib_test_cmp_graph () {
+ git log --graph "$@" >output &&
+ sed 's/ *$//' >output.sanitized <output &&
+ test_i18ncmp expect output.sanitized
+}
+
+lib_test_cmp_short_graph () {
+ git log --graph --pretty=short "$@" >output &&
+ sanitize_log_output >output.sanitized <output &&
+ test_i18ncmp expect output.sanitized
+}
+
+lib_test_cmp_colored_graph () {
+ git log --graph --color=always "$@" >output.colors.raw &&
+ test_decode_color <output.colors.raw | sed "s/ *\$//" >output.colors &&
+ test_cmp expect.colors output.colors
+}
diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh
index e72ca348ea..a1bc3e2001 100755
--- a/t/t3430-rebase-merges.sh
+++ b/t/t3430-rebase-merges.sh
@@ -20,12 +20,11 @@ Initial setup:
'
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-rebase.sh
+. "$TEST_DIRECTORY"/lib-log-graph.sh
test_cmp_graph () {
cat >expect &&
- git log --graph --boundary --format=%s "$@" >output &&
- sed "s/ *$//" <output >output.trimmed &&
- test_cmp expect output.trimmed
+ lib_test_cmp_graph --boundary --format=%s "$@"
}
test_expect_success 'setup' '
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 192347a3e1..4694b6d0ce 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -5,6 +5,11 @@ test_description='git log'
. ./test-lib.sh
. "$TEST_DIRECTORY/lib-gpg.sh"
. "$TEST_DIRECTORY/lib-terminal.sh"
+. "$TEST_DIRECTORY/lib-log-graph.sh"
+
+test_cmp_graph () {
+ lib_test_cmp_graph --format=%s "$@"
+}
test_expect_success setup '
@@ -452,8 +457,7 @@ cat > expect <<EOF
EOF
test_expect_success 'simple log --graph' '
- git log --graph --pretty=tformat:%s >actual &&
- test_cmp expect actual
+ test_cmp_graph
'
cat > expect <<EOF
@@ -467,8 +471,7 @@ cat > expect <<EOF
EOF
test_expect_success 'simple log --graph --line-prefix="123 "' '
- git log --graph --line-prefix="123 " --pretty=tformat:%s >actual &&
- test_cmp expect actual
+ test_cmp_graph --line-prefix="123 "
'
test_expect_success 'set up merge history' '
@@ -495,9 +498,7 @@ cat > expect <<\EOF
EOF
test_expect_success 'log --graph with merge' '
- git log --graph --date-order --pretty=tformat:%s |
- sed "s/ *\$//" >actual &&
- test_cmp expect actual
+ test_cmp_graph --date-order
'
cat > expect <<\EOF
@@ -516,9 +517,7 @@ cat > expect <<\EOF
EOF
test_expect_success 'log --graph --line-prefix="| | | " with merge' '
- git log --line-prefix="| | | " --graph --date-order --pretty=tformat:%s |
- sed "s/ *\$//" >actual &&
- test_cmp expect actual
+ test_cmp_graph --line-prefix="| | | " --date-order
'
cat > expect.colors <<\EOF
@@ -538,9 +537,7 @@ EOF
test_expect_success 'log --graph with merge with log.graphColors' '
test_config log.graphColors " blue,invalid-color, cyan, red , " &&
- git log --color=always --graph --date-order --pretty=tformat:%s |
- test_decode_color | sed "s/ *\$//" >actual &&
- test_cmp expect.colors actual
+ lib_test_cmp_colored_graph --date-order --format=%s
'
test_expect_success 'log --raw --graph -m with merge' '
@@ -676,9 +673,7 @@ cat > expect <<\EOF
EOF
test_expect_success 'log --graph with merge' '
- git log --graph --date-order --pretty=tformat:%s |
- sed "s/ *\$//" >actual &&
- test_cmp expect actual
+ test_cmp_graph --date-order
'
test_expect_success 'log.decorate configuration' '
@@ -1213,24 +1208,8 @@ cat >expect <<\EOF
+one
EOF
-sanitize_output () {
- sed -e 's/ *$//' \
- -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
- -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
- -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
- -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
- -e 's/, 0 deletions(-)//' \
- -e 's/, 0 insertions(+)//' \
- -e 's/ 1 files changed, / 1 file changed, /' \
- -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
- -e 's/, 1 insertions(+)/, 1 insertion(+)/' \
- -e 's/index [0-9a-f]*\.\.[0-9a-f]*/index BEFORE..AFTER/'
-}
-
test_expect_success 'log --graph with diff and stats' '
- git log --no-renames --graph --pretty=short --stat -p >actual &&
- sanitize_output >actual.sanitized <actual &&
- test_i18ncmp expect actual.sanitized
+ lib_test_cmp_short_graph --no-renames --stat -p
'
cat >expect <<\EOF
@@ -1505,9 +1484,7 @@ cat >expect <<\EOF
EOF
test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
- git log --line-prefix="*** " --no-renames --graph --pretty=short --stat -p >actual &&
- sanitize_output >actual.sanitized <actual &&
- test_i18ncmp expect actual.sanitized
+ lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
'
cat >expect <<-\EOF
@@ -1529,9 +1506,7 @@ cat >expect <<-\EOF
EOF
test_expect_success 'log --graph with --name-status' '
- git log --graph --format=%s --name-status tangle..reach >actual &&
- sanitize_output <actual >actual.sanitized &&
- test_cmp expect actual.sanitized
+ test_cmp_graph --name-status tangle..reach
'
cat >expect <<-\EOF
@@ -1553,9 +1528,7 @@ cat >expect <<-\EOF
EOF
test_expect_success 'log --graph with --name-only' '
- git log --graph --format=%s --name-only tangle..reach >actual &&
- sanitize_output <actual >actual.sanitized &&
- test_cmp expect actual.sanitized
+ test_cmp_graph --name-only tangle..reach
'
test_expect_success 'dotdot is a parent directory' '
diff --git a/t/t4214-log-graph-octopus.sh b/t/t4214-log-graph-octopus.sh
index 40d27db674..a080325098 100755
--- a/t/t4214-log-graph-octopus.sh
+++ b/t/t4214-log-graph-octopus.sh
@@ -3,6 +3,16 @@
test_description='git log --graph of skewed left octopus merge.'
. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-log-graph.sh
+
+test_cmp_graph () {
+ cat >expect &&
+ lib_test_cmp_graph --color=never --date-order --format=%s "$@"
+}
+
+test_cmp_colored_graph () {
+ lib_test_cmp_colored_graph --date-order --format=%s "$@"
+}
test_expect_success 'set up merge history' '
test_commit initial &&
@@ -24,7 +34,7 @@ test_expect_success 'set up merge history' '
'
test_expect_success 'log --graph with tricky octopus merge, no color' '
- cat >expect.uncolored <<-\EOF &&
+ test_cmp_graph left octopus-merge <<-\EOF
* left
| *-. octopus-merge
|/|\ \
@@ -37,9 +47,6 @@ test_expect_success 'log --graph with tricky octopus merge, no color' '
|/
* initial
EOF
- git log --color=never --graph --date-order --pretty=tformat:%s left octopus-merge >actual.raw &&
- sed "s/ *\$//" actual.raw >actual &&
- test_cmp expect.uncolored actual
'
test_expect_success 'log --graph with tricky octopus merge with colors' '
@@ -57,16 +64,14 @@ test_expect_success 'log --graph with tricky octopus merge with colors' '
<MAGENTA>|<RESET><MAGENTA>/<RESET>
* initial
EOF
- git log --color=always --graph --date-order --pretty=tformat:%s left octopus-merge >actual.colors.raw &&
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
- test_cmp expect.colors actual.colors
+ test_cmp_colored_graph left octopus-merge
'
# Repeat the previous two tests with "normal" octopus merge (i.e.,
# without the first parent skewing to the "left" branch column).
test_expect_success 'log --graph with normal octopus merge, no color' '
- cat >expect.uncolored <<-\EOF &&
+ test_cmp_graph octopus-merge <<-\EOF
*---. octopus-merge
|\ \ \
| | | * 4
@@ -78,9 +83,6 @@ test_expect_success 'log --graph with normal octopus merge, no color' '
|/
* initial
EOF
- git log --color=never --graph --date-order --pretty=tformat:%s octopus-merge >actual.raw &&
- sed "s/ *\$//" actual.raw >actual &&
- test_cmp expect.uncolored actual
'
test_expect_success 'log --graph with normal octopus merge with colors' '
@@ -97,13 +99,11 @@ test_expect_success 'log --graph with normal octopus merge with colors' '
* initial
EOF
test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
- git log --color=always --graph --date-order --pretty=tformat:%s octopus-merge >actual.colors.raw &&
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
- test_cmp expect.colors actual.colors
+ test_cmp_colored_graph octopus-merge
'
test_expect_success 'log --graph with normal octopus merge and child, no color' '
- cat >expect.uncolored <<-\EOF &&
+ test_cmp_graph after-merge <<-\EOF
* after-merge
*---. octopus-merge
|\ \ \
@@ -116,9 +116,6 @@ test_expect_success 'log --graph with normal octopus merge and child, no color'
|/
* initial
EOF
- git log --color=never --graph --date-order --pretty=tformat:%s after-merge >actual.raw &&
- sed "s/ *\$//" actual.raw >actual &&
- test_cmp expect.uncolored actual
'
test_expect_success 'log --graph with normal octopus and child merge with colors' '
@@ -136,13 +133,11 @@ test_expect_success 'log --graph with normal octopus and child merge with colors
* initial
EOF
test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
- git log --color=always --graph --date-order --pretty=tformat:%s after-merge >actual.colors.raw &&
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
- test_cmp expect.colors actual.colors
+ test_cmp_colored_graph after-merge
'
test_expect_success 'log --graph with tricky octopus merge and its child, no color' '
- cat >expect.uncolored <<-\EOF &&
+ test_cmp_graph left after-merge <<-\EOF
* left
| * after-merge
| *-. octopus-merge
@@ -156,9 +151,6 @@ test_expect_success 'log --graph with tricky octopus merge and its child, no col
|/
* initial
EOF
- git log --color=never --graph --date-order --pretty=tformat:%s left after-merge >actual.raw &&
- sed "s/ *\$//" actual.raw >actual &&
- test_cmp expect.uncolored actual
'
test_expect_success 'log --graph with tricky octopus merge and its child with colors' '
@@ -177,13 +169,11 @@ test_expect_success 'log --graph with tricky octopus merge and its child with co
<CYAN>|<RESET><CYAN>/<RESET>
* initial
EOF
- git log --color=always --graph --date-order --pretty=tformat:%s left after-merge >actual.colors.raw &&
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
- test_cmp expect.colors actual.colors
+ test_cmp_colored_graph left after-merge
'
test_expect_success 'log --graph with crossover in octopus merge, no color' '
- cat >expect.uncolored <<-\EOF &&
+ test_cmp_graph after-4 octopus-merge <<-\EOF
* after-4
| *---. octopus-merge
| |\ \ \
@@ -200,9 +190,6 @@ test_expect_success 'log --graph with crossover in octopus merge, no color' '
|/
* initial
EOF
- git log --color=never --graph --date-order --pretty=tformat:%s after-4 octopus-merge >actual.raw &&
- sed "s/ *\$//" actual.raw >actual &&
- test_cmp expect.uncolored actual
'
test_expect_success 'log --graph with crossover in octopus merge with colors' '
@@ -224,13 +211,11 @@ test_expect_success 'log --graph with crossover in octopus merge with colors' '
<MAGENTA>|<RESET><MAGENTA>/<RESET>
* initial
EOF
- git log --color=always --graph --date-order --pretty=tformat:%s after-4 octopus-merge >actual.colors.raw &&
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
- test_cmp expect.colors actual.colors
+ test_cmp_colored_graph after-4 octopus-merge
'
test_expect_success 'log --graph with crossover in octopus merge and its child, no color' '
- cat >expect.uncolored <<-\EOF &&
+ test_cmp_graph after-4 after-merge <<-\EOF
* after-4
| * after-merge
| *---. octopus-merge
@@ -248,9 +233,6 @@ test_expect_success 'log --graph with crossover in octopus merge and its child,
|/
* initial
EOF
- git log --color=never --graph --date-order --pretty=tformat:%s after-4 after-merge >actual.raw &&
- sed "s/ *\$//" actual.raw >actual &&
- test_cmp expect.uncolored actual
'
test_expect_success 'log --graph with crossover in octopus merge and its child with colors' '
@@ -273,13 +255,11 @@ test_expect_success 'log --graph with crossover in octopus merge and its child w
<CYAN>|<RESET><CYAN>/<RESET>
* initial
EOF
- git log --color=always --graph --date-order --pretty=tformat:%s after-4 after-merge >actual.colors.raw &&
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
- test_cmp expect.colors actual.colors
+ test_cmp_colored_graph after-4 after-merge
'
test_expect_success 'log --graph with unrelated commit and octopus tip, no color' '
- cat >expect.uncolored <<-\EOF &&
+ test_cmp_graph after-initial octopus-merge <<-\EOF
* after-initial
| *---. octopus-merge
| |\ \ \
@@ -296,9 +276,6 @@ test_expect_success 'log --graph with unrelated commit and octopus tip, no color
|/
* initial
EOF
- git log --color=never --graph --date-order --pretty=tformat:%s after-initial octopus-merge >actual.raw &&
- sed "s/ *\$//" actual.raw >actual &&
- test_cmp expect.uncolored actual
'
test_expect_success 'log --graph with unrelated commit and octopus tip with colors' '
@@ -320,13 +297,11 @@ test_expect_success 'log --graph with unrelated commit and octopus tip with colo
<RED>|<RESET><RED>/<RESET>
* initial
EOF
- git log --color=always --graph --date-order --pretty=tformat:%s after-initial octopus-merge >actual.colors.raw &&
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
- test_cmp expect.colors actual.colors
+ test_cmp_colored_graph after-initial octopus-merge
'
test_expect_success 'log --graph with unrelated commit and octopus child, no color' '
- cat >expect.uncolored <<-\EOF &&
+ test_cmp_graph after-initial after-merge <<-\EOF
* after-initial
| * after-merge
| *---. octopus-merge
@@ -344,9 +319,6 @@ test_expect_success 'log --graph with unrelated commit and octopus child, no col
|/
* initial
EOF
- git log --color=never --graph --date-order --pretty=tformat:%s after-initial after-merge >actual.raw &&
- sed "s/ *\$//" actual.raw >actual &&
- test_cmp expect.uncolored actual
'
test_expect_success 'log --graph with unrelated commit and octopus child with colors' '
@@ -369,9 +341,7 @@ test_expect_success 'log --graph with unrelated commit and octopus child with co
<RED>|<RESET><RED>/<RESET>
* initial
EOF
- git log --color=always --graph --date-order --pretty=tformat:%s after-initial after-merge >actual.colors.raw &&
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
- test_cmp expect.colors actual.colors
+ test_cmp_colored_graph after-initial after-merge
'
test_done
diff --git a/t/t4215-log-skewed-merges.sh b/t/t4215-log-skewed-merges.sh
index 1d0d3240ff..28d0779a8c 100755
--- a/t/t4215-log-skewed-merges.sh
+++ b/t/t4215-log-skewed-merges.sh
@@ -3,12 +3,11 @@
test_description='git log --graph of skewed merges'
. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-log-graph.sh
check_graph () {
cat >expect &&
- git log --graph --pretty=tformat:%s "$@" >actual.raw &&
- sed "s/ *$//" actual.raw >actual &&
- test_cmp expect actual
+ lib_test_cmp_graph --format=%s "$@"
}
test_expect_success 'log --graph with merge fusing with its left and right neighbors' '
@@ -306,9 +305,7 @@ test_expect_success 'log --graph with multiple tips and colors' '
<BLUE>|<RESET><BLUE>/<RESET>
* 6_A
EOF
- git log --color=always --graph --date-order --pretty=tformat:%s 6_1 6_3 6_5 >actual.colors.raw &&
- test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
- test_cmp expect.colors actual.colors
+ lib_test_cmp_colored_graph --date-order --pretty=tformat:%s 6_1 6_3 6_5
'
test_expect_success 'log --graph with multiple tips' '