[PATCH 16/22] tests: refactor a few tests to use "test_commit --append"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Refactor a few more tests to use the new "--append" option to
"test_commit". I added it for use in the mailmap tests, but this
demonstrates how useful it is in general.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
---
 t/t1412-reflog-loop.sh   |  7 ++-----
 t/t2012-checkout-last.sh | 12 +++---------
 t/t7810-grep.sh          | 18 +++---------------
 3 files changed, 8 insertions(+), 29 deletions(-)

diff --git a/t/t1412-reflog-loop.sh b/t/t1412-reflog-loop.sh
index 3acd895afb..977603f7f1 100755
--- a/t/t1412-reflog-loop.sh
+++ b/t/t1412-reflog-loop.sh
@@ -4,11 +4,8 @@ test_description='reflog walk shows repeated commits again'
 . ./test-lib.sh
 
 test_expect_success 'setup commits' '
-	test_tick &&
-	echo content >file && git add file && git commit -m one &&
-	git tag one &&
-	echo content >>file && git add file && git commit -m two &&
-	git tag two
+	test_commit one file content &&
+	test_commit --append two file content
 '
 
 test_expect_success 'setup reflog with alternating commits' '
diff --git a/t/t2012-checkout-last.sh b/t/t2012-checkout-last.sh
index e7ba8c505f..c95aa3e78f 100755
--- a/t/t2012-checkout-last.sh
+++ b/t/t2012-checkout-last.sh
@@ -5,13 +5,9 @@ test_description='checkout can switch to last branch and merge base'
 . ./test-lib.sh
 
 test_expect_success 'setup' '
-	echo hello >world &&
-	git add world &&
-	git commit -m initial &&
+	test_commit initial world hello &&
 	git branch other &&
-	echo "hello again" >>world &&
-	git add world &&
-	git commit -m second
+	test_commit --append second world "hello again"
 '
 
 test_expect_success '"checkout -" does not work initially' '
@@ -93,9 +89,7 @@ test_expect_success 'switch to twelfth from the last' '
 
 test_expect_success 'merge base test setup' '
 	git checkout -b another other &&
-	echo "hello again" >>world &&
-	git add world &&
-	git commit -m third
+	test_commit --append third world "hello again"
 '
 
 test_expect_success 'another...master' '
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index 991d5bd9c0..312e0f8cb4 100755
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
@@ -687,21 +687,9 @@ test_expect_success 'grep -C1 hunk mark between files' '
 '
 
 test_expect_success 'log grep setup' '
-	echo a >>file &&
-	test_tick &&
-	GIT_AUTHOR_NAME="With * Asterisk" \
-	GIT_AUTHOR_EMAIL="xyzzy@xxxxxxxxx" \
-	git commit -a -m "second" &&
-
-	echo a >>file &&
-	test_tick &&
-	git commit -a -m "third" &&
-
-	echo a >>file &&
-	test_tick &&
-	GIT_AUTHOR_NAME="Night Fall" \
-	GIT_AUTHOR_EMAIL="nitfol@xxxxxxxxxxx" \
-	git commit -a -m "fourth"
+	test_commit --append --author "With * Asterisk <xyzzy@xxxxxxxxx>" second file a &&
+	test_commit --append third file a &&
+	test_commit --append --author "Night Fall <nitfol@xxxxxxxxxxx>" fourth file a
 '
 
 test_expect_success 'log grep (1)' '
-- 
2.29.2.222.g5d2a92d10f8




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux