diff mbox series

[v4,12/39] t7201: abstract away SHA-1-specific constants

Message ID 20200726195424.626969-13-sandals@crustytoothpaste.net (mailing list archive)
State New, archived
Headers show
Series [v4,01/39] t: make test-bloom initialize repository | expand

Commit Message

brian m. carlson July 26, 2020, 7:53 p.m. UTC
Adjust the test so that it computes variables for object IDs instead of
using hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t7201-co.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Eric Sunshine July 26, 2020, 10:54 p.m. UTC | #1
On Sun, Jul 26, 2020 at 3:55 PM brian m. carlson
<sandals@crustytoothpaste.net> wrote:
> Adjust the test so that it computes variables for object IDs instead of
> using hard-coded hashes.
>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
> diff --git a/t/t7201-co.sh b/t/t7201-co.sh
> @@ -230,9 +230,10 @@ test_expect_success 'switch to another branch while carrying a deletion' '
>  test_expect_success 'checkout to detach HEAD (with advice declined)' '
>         git config advice.detachedHead false &&
> +       rev=$(git rev-parse --short renamer^) &&
>         git checkout -f renamer && git clean -f &&
>         git checkout renamer^ 2>messages &&
> -       test_i18ngrep "HEAD is now at 7329388" messages &&
> +       test_i18ngrep "HEAD is now at $rev" messages &&

This test computes (and uses) the value 'rev'...

> @@ -250,7 +251,7 @@ test_expect_success 'checkout to detach HEAD' '
>         GIT_TEST_GETTEXT_POISON=false git checkout renamer^ 2>messages &&
> -       grep "HEAD is now at 7329388" messages &&
> +       grep "HEAD is now at $rev" messages &&

... and then this separate test re-uses that value, which
unnecessarily couples these tests tightly. How about instead just
re-computing the value of 'rev' in the second test, which will make it
easier to run individual tests while skipping others.
diff mbox series

Patch

diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index b696bae5f5..d4fd760915 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -230,9 +230,10 @@  test_expect_success 'switch to another branch while carrying a deletion' '
 test_expect_success 'checkout to detach HEAD (with advice declined)' '
 
 	git config advice.detachedHead false &&
+	rev=$(git rev-parse --short renamer^) &&
 	git checkout -f renamer && git clean -f &&
 	git checkout renamer^ 2>messages &&
-	test_i18ngrep "HEAD is now at 7329388" messages &&
+	test_i18ngrep "HEAD is now at $rev" messages &&
 	test_line_count = 1 messages &&
 	H=$(git rev-parse --verify HEAD) &&
 	M=$(git show-ref -s --verify refs/heads/master) &&
@@ -250,7 +251,7 @@  test_expect_success 'checkout to detach HEAD' '
 	git config advice.detachedHead true &&
 	git checkout -f renamer && git clean -f &&
 	GIT_TEST_GETTEXT_POISON=false git checkout renamer^ 2>messages &&
-	grep "HEAD is now at 7329388" messages &&
+	grep "HEAD is now at $rev" messages &&
 	test_line_count -gt 1 messages &&
 	H=$(git rev-parse --verify HEAD) &&
 	M=$(git show-ref -s --verify refs/heads/master) &&