threads / rfc / 48554

RFC v3, 2 partsAdd tests for rev-list --bisect* --first-parent

Subject: [RFC PATCH v3 2/2] Add tests for rev-list --bisect* --first-parent

## tl;dr

2 messages between May 23, 2018 and May 24, 2018. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Tiago Botelho· May 23, 2018, 12:01 UTC · lore
---
 t/t6002-rev-list-bisect.sh | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
Show changes to t/t6002-rev-list-bisect.sh +39 −0
diff --git a/t/t6002-rev-list-bisect.sh b/t/t6002-rev-list-bisect.sh
index a66140803..977c82157 100755
--- a/t/t6002-rev-list-bisect.sh
+++ b/t/t6002-rev-list-bisect.sh
@@ -263,4 +263,43 @@ test_expect_success 'rev-parse --bisect can default to good/bad refs' '
 	test_cmp expect.sorted actual.sorted
 '
 
+# We generate the following commit graph:
+#
+#     A
+#    / \
+#   D   B
+#   |   |
+#   EX  C
+#    \  /
+#     FX
+
+test_expect_success 'setup' '
+  test_commit A &&
+  test_commit B &&
+  test_commit C &&
+  git reset --hard A &&
+  test_commit D &&
+  test_commit EX &&
+  test_merge FX C
+'
+
+test_output_expect_success "--bisect --first-parent" 'git rev-list --bisect --first-parent FX ^A' <<EOF
+$(git rev-parse EX)
+EOF
+
+test_output_expect_success "--bisect-vars --first-parent" 'git rev-list --bisect-vars --first-parent FX ^A' <<EOF
+bisect_rev='$(git rev-parse EX)'
+bisect_nr=1
+bisect_good=0
+bisect_bad=1
+bisect_all=3
+bisect_steps=1
+EOF
+
+test_output_expect_success "--bisect-all --first-parent" 'git rev-list --bisect-all --first-parent FX ^A' <<EOF
+$(git rev-parse D) (dist=1)
+$(git rev-parse EX) (dist=1)
+$(git rev-parse FX) (dist=0)
+EOF
+
 test_done
-- 
2.16.3
Junio C Hamano· May 24, 2018, 02:42 UTC · re: Tiago Botelho · lore

Re: [RFC PATCH v3 2/2] Add tests for rev-list --bisect* --first-parent

Tiago Botelho <tiagonbotelho@gmail.com> writes:
> Subject: [RFC PATCH v3 1/2] Implement --first-parent for git rev-list --bisect
> Subject: [RFC PATCH v3 2/2] Add tests for rev-list --bisect* --first-parent
perhaps
	bisect: teach "git rev-list --bisect" to work with "--first-parent"
	bisect: test "git rev-list --first-parent --bisect"

or soemthing? I _think_ it is probably preferrable to have the test in the primary patch, making these two patches into one.

Show 21 quoted lines
> ---
>  t/t6002-rev-list-bisect.sh | 39 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
>
> diff --git a/t/t6002-rev-list-bisect.sh b/t/t6002-rev-list-bisect.sh
> index a66140803..977c82157 100755
> --- a/t/t6002-rev-list-bisect.sh
> +++ b/t/t6002-rev-list-bisect.sh
> @@ -263,4 +263,43 @@ test_expect_success 'rev-parse --bisect can default to good/bad refs' '
>  	test_cmp expect.sorted actual.sorted
>  '
>  
> +# We generate the following commit graph:
> +#
> +#     A
> +#    / \
> +#   D   B
> +#   |   |
> +#   EX  C
> +#    \  /
> +#     FX

Existing ascii art in the same script seems to draw the history growing from bottom to top, the other way around. Please be consistent. I think that we tend to draw simple histories growing from left to right, and a more complex ones from bottom to top.

Show 13 quoted lines
> +test_expect_success 'setup' '
> +  test_commit A &&
> +  test_commit B &&
> +  test_commit C &&
> +  git reset --hard A &&
> +  test_commit D &&
> +  test_commit EX &&
> +  test_merge FX C
> +'
> +
> +test_output_expect_success "--bisect --first-parent" 'git rev-list --bisect --first-parent FX ^A' <<EOF
> +$(git rev-parse EX)
> +EOF

OK, because our range has odd number of commits on the first-parent chain, the middle one is unambiguously the one to pick.

Show 16 quoted lines
> +test_output_expect_success "--bisect-vars --first-parent" 'git rev-list --bisect-vars --first-parent FX ^A' <<EOF
> +bisect_rev='$(git rev-parse EX)'
> +bisect_nr=1
> +bisect_good=0
> +bisect_bad=1
> +bisect_all=3
> +bisect_steps=1
> +EOF
> +
> +test_output_expect_success "--bisect-all --first-parent" 'git rev-list --bisect-all --first-parent FX ^A' <<EOF
> +$(git rev-parse D) (dist=1)
> +$(git rev-parse EX) (dist=1)
> +$(git rev-parse FX) (dist=0)
> +EOF
> +
>  test_done

← back to recent threads