diff mbox series

[GSoC,3/5] t4215: use lib-log-graph functions

Message ID 20200216134750.18947-3-abhishekkumar8222@gmail.com
State New, archived
Headers show
Series [GSoC,1/5] lib-log-graph.sh: consolidate test_cmp_graph logic | expand

Commit Message

Abhishek Kumar Feb. 16, 2020, 1:47 p.m. UTC
Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>
---
 t/t4215-log-skewed-merges.sh | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

Comments

Junio C Hamano Feb. 19, 2020, 5:26 p.m. UTC | #1
Abhishek Kumar <abhishekkumar8222@gmail.com> writes:

> Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>
> ---
>  t/t4215-log-skewed-merges.sh | 26 ++++++++++----------------
>  1 file changed, 10 insertions(+), 16 deletions(-)
>
> diff --git a/t/t4215-log-skewed-merges.sh b/t/t4215-log-skewed-merges.sh
> index 1d0d3240ff..bca478cb83 100755
> --- a/t/t4215-log-skewed-merges.sh
> +++ b/t/t4215-log-skewed-merges.sh
> @@ -3,13 +3,7 @@
>  test_description='git log --graph of skewed merges'
>  
>  . ./test-lib.sh
> -
> -check_graph () {
> -	cat >expect &&
> -	git log --graph --pretty=tformat:%s "$@" >actual.raw &&
> -	sed "s/ *$//" actual.raw >actual &&
> -	test_cmp expect actual
> -}
> +. "$TEST_DIRECTORY"/lib-log-graph.sh
>  
>  test_expect_success 'log --graph with merge fusing with its left and right neighbors' '
>  	git checkout --orphan _p &&
> @@ -22,7 +16,7 @@ test_expect_success 'log --graph with merge fusing with its left and right neigh
>  	git checkout _p && git merge --no-ff _r -m G &&
>  	git checkout @^^ && git merge --no-ff _p -m H &&
>  
> -	check_graph <<-\EOF
> +	test_cmp_graph --pretty=tformat:%s <<-\EOF

Almost exactly the same comment as [2/5] applies here, but luckily
the name of the local helper used here is check_graph, so we can
discard all the hunks after -22,7 above and instead use

	check_graph () {
		test_cmp_graph --format:%s "$@"
	}

to reduce the code churn, I would think.
diff mbox series

Patch

diff --git a/t/t4215-log-skewed-merges.sh b/t/t4215-log-skewed-merges.sh
index 1d0d3240ff..bca478cb83 100755
--- a/t/t4215-log-skewed-merges.sh
+++ b/t/t4215-log-skewed-merges.sh
@@ -3,13 +3,7 @@ 
 test_description='git log --graph of skewed merges'
 
 . ./test-lib.sh
-
-check_graph () {
-	cat >expect &&
-	git log --graph --pretty=tformat:%s "$@" >actual.raw &&
-	sed "s/ *$//" actual.raw >actual &&
-	test_cmp expect actual
-}
+. "$TEST_DIRECTORY"/lib-log-graph.sh
 
 test_expect_success 'log --graph with merge fusing with its left and right neighbors' '
 	git checkout --orphan _p &&
@@ -22,7 +16,7 @@  test_expect_success 'log --graph with merge fusing with its left and right neigh
 	git checkout _p && git merge --no-ff _r -m G &&
 	git checkout @^^ && git merge --no-ff _p -m H &&
 
-	check_graph <<-\EOF
+	test_cmp_graph --pretty=tformat:%s <<-\EOF
 	*   H
 	|\
 	| *   G
@@ -50,7 +44,7 @@  test_expect_success 'log --graph with left-skewed merge' '
 	git checkout 0_p && git merge --no-ff 0_s -m 0_G &&
 	git checkout @^ && git merge --no-ff 0_q 0_r 0_t 0_p -m 0_H &&
 
-	check_graph <<-\EOF
+	test_cmp_graph --pretty=tformat:%s <<-\EOF
 	*-----.   0_H
 	|\ \ \ \
 	| | | | * 0_G
@@ -84,7 +78,7 @@  test_expect_success 'log --graph with nested left-skewed merge' '
 	git checkout 1_p && git merge --no-ff 1_r -m 1_G &&
 	git checkout @^^ && git merge --no-ff 1_p -m 1_H &&
 
-	check_graph <<-\EOF
+	test_cmp_graph --pretty=tformat:%s <<-\EOF
 	*   1_H
 	|\
 	| *   1_G
@@ -116,7 +110,7 @@  test_expect_success 'log --graph with nested left-skewed merge following normal
 	git checkout -b 2_s @^^ && git merge --no-ff 2_q -m 2_J &&
 	git checkout 2_p && git merge --no-ff 2_s -m 2_K &&
 
-	check_graph <<-\EOF
+	test_cmp_graph --pretty=tformat:%s <<-\EOF
 	*   2_K
 	|\
 	| *   2_J
@@ -152,7 +146,7 @@  test_expect_success 'log --graph with nested right-skewed merge following left-s
 	git checkout 3_p && git merge --no-ff 3_r -m 3_H &&
 	git checkout @^^ && git merge --no-ff 3_p -m 3_J &&
 
-	check_graph <<-\EOF
+	test_cmp_graph --pretty=tformat:%s <<-\EOF
 	*   3_J
 	|\
 	| *   3_H
@@ -183,7 +177,7 @@  test_expect_success 'log --graph with right-skewed merge following a left-skewed
 	git merge --no-ff 4_p -m 4_G &&
 	git checkout @^^ && git merge --no-ff 4_s -m 4_H &&
 
-	check_graph --date-order <<-\EOF
+	test_cmp_graph --pretty=tformat:%s --date-order <<-\EOF
 	*   4_H
 	|\
 	| *   4_G
@@ -219,7 +213,7 @@  test_expect_success 'log --graph with octopus merge with column joining its penu
 	git checkout 5_r &&
 	git merge --no-ff 5_s -m 5_H &&
 
-	check_graph <<-\EOF
+	test_cmp_graph --pretty=tformat:%s <<-\EOF
 	*   5_H
 	|\
 	| *-.   5_G
@@ -258,7 +252,7 @@  test_expect_success 'log --graph with multiple tips' '
 	git checkout 6_1 &&
 	git merge --no-ff 6_2 -m 6_I &&
 
-	check_graph 6_1 6_3 6_5 <<-\EOF
+	test_cmp_graph --pretty=tformat:%s 6_1 6_3 6_5 <<-\EOF
 	*   6_I
 	|\
 	| | *   6_H
@@ -337,7 +331,7 @@  test_expect_success 'log --graph with multiple tips' '
 	git checkout -b M_7 7_1 &&
 	git merge --no-ff 7_2 7_3 -m 7_M4 &&
 
-	check_graph M_1 M_3 M_5 M_7 <<-\EOF
+	test_cmp_graph --pretty=tformat:%s M_1 M_3 M_5 M_7 <<-\EOF
 	*   7_M1
 	|\
 	| | *   7_M2