Thread (107 messages) flat view 107 messages, 5 authors, 2021-03-11
STALE2005d

[PATCH 4/4] tests: get rid of $_x05 from the test suite

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-03-11 00:16:05
Subsystem: the rest · Maintainer: Linus Torvalds

Remove the last users of the $_x05 variable from the tests. It turns
out that all of these tests can be rewritten unambiguously to simply
use [0-9a-f]* instead.

In the case of the tree matching we're relying on there being a <TAB>
after the SHA (but a space between the modes and type), then in some
of the other tests here that an abbreviated SHA is at the start of the
line, etc.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
 t/t3101-ls-tree-dirname.sh          |  2 +-
 t/t3508-cherry-pick-many-commits.sh |  4 ++--
 t/t6006-rev-list-format.sh          | 12 +++++++-----
 t/t7600-merge.sh                    |  4 ++--
 t/test-lib.sh                       |  6 +-----
 5 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/t/t3101-ls-tree-dirname.sh b/t/t3101-ls-tree-dirname.sh
index 12bf31022a..110ebf7d52 100755
--- a/t/t3101-ls-tree-dirname.sh
+++ b/t/t3101-ls-tree-dirname.sh
@@ -187,7 +187,7 @@ EOF
 
 test_expect_success 'ls-tree --abbrev=5' '
 	git ls-tree --abbrev=5 $tree >current &&
-	sed -e "s/ $_x05[0-9a-f]*	/ X	/" <current >check &&
+	sed -e "s/ [0-9a-f]*	/ X	/" <current >check &&
 	cat >expected <<\EOF &&
 100644 blob X	1.txt
 100644 blob X	2.txt
diff --git a/t/t3508-cherry-pick-many-commits.sh b/t/t3508-cherry-pick-many-commits.sh
index e8375d1c97..1bf867d139 100755
--- a/t/t3508-cherry-pick-many-commits.sh
+++ b/t/t3508-cherry-pick-many-commits.sh
@@ -84,7 +84,7 @@ test_expect_success 'output to keep user entertained during multi-pick' '
 	git reset --hard first &&
 	test_tick &&
 	git cherry-pick first..fourth >actual &&
-	sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
+	sed -e "s/ [0-9a-f]*\\]/ OBJID]/" <actual >actual.fuzzy &&
 	test_line_count -ge 3 actual.fuzzy &&
 	test_cmp expected actual.fuzzy
 '
@@ -122,7 +122,7 @@ test_expect_success 'output during multi-pick indicates merge strategy' '
 	git reset --hard first &&
 	test_tick &&
 	git cherry-pick --strategy resolve first..fourth >actual &&
-	sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
+	sed -e "s/ [0-9a-f]*\\]/ OBJID]/" <actual >actual.fuzzy &&
 	test_cmp expected actual.fuzzy
 '
 
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 35a2f62392..ec65081e17 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -453,16 +453,18 @@ test_expect_success 'add SP before non-empty (2)' '
 '
 
 test_expect_success '--abbrev' '
-	echo SHORT SHORT SHORT >expect2 &&
 	echo LONG LONG LONG >expect3 &&
 	git log -1 --format="%h %h %h" HEAD >actual1 &&
 	git log -1 --abbrev=5 --format="%h %h %h" HEAD >actual2 &&
 	git log -1 --abbrev=5 --format="%H %H %H" HEAD >actual3 &&
-	sed -e "s/$OID_REGEX/LONG/g" -e "s/$_x05/SHORT/g" <actual2 >fuzzy2 &&
-	sed -e "s/$OID_REGEX/LONG/g" -e "s/$_x05/SHORT/g" <actual3 >fuzzy3 &&
-	test_cmp expect2 fuzzy2 &&
+	sed -e "s/$OID_REGEX/LONG/g" <actual3 >fuzzy3 &&
+	test_file_size actual2 >expect &&
+	# 3*5 SHAs + 3 separating spaces
+	echo 18 >actual &&
+	test_cmp expect actual &&
 	test_cmp expect3 fuzzy3 &&
-	! test_cmp actual1 actual2
+	! test_cmp actual1 actual2 &&
+	! test_cmp actual2 actual3
 '
 
 test_expect_success '%H is not affected by --abbrev-commit' '
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 1cbc9715a8..fec5a7b2dd 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -189,7 +189,7 @@ test_expect_success 'merge c0 with c1' '
 	verify_head "$c1" &&
 
 	git reflog -1 >reflog.actual &&
-	sed "s/$_x05[0-9a-f]*/OBJID/g" reflog.actual >reflog.fuzzy &&
+	sed "s/^[0-9a-f]*/OBJID/" <reflog.actual >reflog.fuzzy &&
 	test_cmp reflog.expected reflog.fuzzy
 '
 
@@ -220,7 +220,7 @@ test_expect_success 'merge from unborn branch' '
 	verify_head "$c1" &&
 
 	git reflog -1 >reflog.actual &&
-	sed "s/$_x05[0-9a-f][0-9a-f]/OBJID/g" reflog.actual >reflog.fuzzy &&
+	sed "s/^[0-9a-f]*/OBJID/g" reflog.actual >reflog.fuzzy &&
 	test_cmp reflog.expected reflog.fuzzy
 '
 
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 4d5ba558d3..aeb4b2da1c 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -511,7 +511,7 @@ SQ=\'
 # when case-folding filenames
 u200c=$(printf '\342\200\214')
 
-export _x05 LF u200c EMPTY_TREE EMPTY_BLOB ZERO_OID OID_REGEX
+export LF u200c EMPTY_TREE EMPTY_BLOB ZERO_OID OID_REGEX
 
 # Each test should start with something like this, after copyright notices:
 #
@@ -1380,10 +1380,6 @@ then
 	fi
 fi
 
-# Convenience
-# A regexp to match 5 hexdigits
-_x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
-
 test_oid_init
 
 ZERO_OID=$(test_oid zero)
-- 
2.31.0.rc1.213.gbfdb770ff55
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help