diff mbox series

[v2] test: add test for git bisect skip with --term* arguments

Message ID 20210421040808.14185-1-bagasdotme@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2] test: add test for git bisect skip with --term* arguments | expand

Commit Message

Bagas Sanjaya April 21, 2021, 4:08 a.m. UTC
Trygve Aaberge reported the current git bisect breakage on [1].
After starting bisection with --term-new and --term-old arguments to git
bisect start, skipping with git bisect skip does not change HEAD as
expected.

Let's add the test to catch this breakage.

[1]: https://lore.kernel.org/git/20210418151459.GC10839@aaberge.net/

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
---

Changes from v1:
  * style changes requested by Junio
  * rename test script and edit test description to be more descriptive
  * remove exec </dev/null (I don't know what it means)
  * repo initialization is now on test_expect_success block (as
    requested by Junio)
  
 t/t6031-bisect-skip-with-term.sh | 36 ++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100755 t/t6031-bisect-skip-with-term.sh


base-commit: b0c09ab8796fb736efa432b8e817334f3e5ee75a

Comments

Junio C Hamano April 21, 2021, 5:25 p.m. UTC | #1
Bagas Sanjaya <bagasdotme@gmail.com> writes:

> Trygve Aaberge reported the current git bisect breakage on [1].
> After starting bisection with --term-new and --term-old arguments to git
> bisect start, skipping with git bisect skip does not change HEAD as
> expected.
>
> Let's add the test to catch this breakage.

I expected, as you said in your first version, that it would be
added as part of an existing test script for "git bisect".  And I
suspect that you can reuse the history the existing tests in the
script already use, so you won't have to add the first "initialize"
piece.  If the tested sequence should work but does not yet work due
to lack of a fix to a known bug, the test should be marked as
test_expect_failure instead of test_expect_success.

>   * style changes requested by Junio

Heh, I didn't request anything.  I merely pointed out the parts that
violate the style guide, so if anything, the guide requested you and
I was just a messenger ;-).

Thanks.
Bagas Sanjaya April 22, 2021, 5:16 a.m. UTC | #2
On 22/04/21 00.25, Junio C Hamano wrote:
> I expected, as you said in your first version, that it would be
> added as part of an existing test script for "git bisect".  And I
> suspect that you can reuse the history the existing tests in the
> script already use, so you won't have to add the first "initialize"
> piece.  If the tested sequence should work but does not yet work due
> to lack of a fix to a known bug, the test should be marked as
> test_expect_failure instead of test_expect_success.

So will this patch be queued? Or should I send the patch adding this
test to t6030 instead of separate test script here?
diff mbox series

Patch

diff --git a/t/t6031-bisect-skip-with-term.sh b/t/t6031-bisect-skip-with-term.sh
new file mode 100755
index 0000000000..f1e1c4c1a2
--- /dev/null
+++ b/t/t6031-bisect-skip-with-term.sh
@@ -0,0 +1,36 @@ 
+#!/bin/sh
+
+#
+# Copyright (c) 2021 Bagas Sanjaya
+#
+
+test_description='Tests skipping bisect which the bisection is started with --term* arguments'
+
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+# hash variables to be used in bisection test
+HASH_SKIPPED_FROM=
+HASH_SKIPPED_TO=
+
+# test repo initialization
+test_expect_success 'initialize testing repo with 20 commits' '
+	for i in $(test_seq 1 20); do
+		echo $i >>test &&
+		git add test && git commit -m "commit $i" &&
+		test_tick
+	done
+'
+
+# actual bisection test
+test_expect_success 'test moving HEAD when skip bisecting' '
+	git bisect start --term-new=ok --term-old=whoops HEAD HEAD~9 &&
+	HASH_SKIPPED_FROM=$(git rev-parse --verify HEAD) &&
+	git bisect skip &&
+	HASH_SKIPPED_TO=$(git rev-parse --verify HEAD) &&
+	test $HASH_SKIPPED_FROM != $HASH_SKIPPED_TO
+'
+
+test_done