git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 05/10] describe tests: convert setup to use test_commit

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Feb 28, 2021, 19:54 UTC
Message-ID
<20210228195414.21372-6-avarab@gmail.com>
In-Reply-To
<20200223125102.6697-1-benno@bmevers.de>

Convert the setup of the describe tests to use test_commit when possible. This makes use of the new --annotated-tag option to test_commit.

Some of the setup here could simply be removed since the data being created wasn't important to any of the subsequent tests, so I've done so. E.g. assigning to the "one" variable was always useless, and just checking that we can describe HEAD after the first commit wasn't useful.

In the case of the "two" variable we could instead use the tag we just created. See 5312ab11fbf (Add describe test., 2007-01-13) for the initial version of this code. There's other cases here like redundant "test_tick" invocations, or the simplification of not echoing "X" to a file we're about to tag as "x", now we just use "x" in both cases.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t6120-describe.sh | 58 ++++++++++-----------------------------------
 1 file changed, 13 insertions(+), 45 deletions(-)
diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
index ef70c695be..8dc76f8e9e 100755
--- a/t/t6120-describe.sh
+++ b/t/t6120-describe.sh
@@ -30,64 +30,32 @@ check_describe () {
 }
 
 test_expect_success setup '
+	test_commit initial file one &&
+	test_commit second file two &&
+	test_commit third file three &&
+	test_commit --annotated-tag A file A &&
+	test_commit c file c &&
 
-	test_tick &&
-	echo one >file && git add file && git commit -m initial &&
-	one=$(git rev-parse HEAD) &&
-
-	git describe --always HEAD &&
-
-	test_tick &&
-	echo two >file && git add file && git commit -m second &&
-	two=$(git rev-parse HEAD) &&
-
-	test_tick &&
-	echo three >file && git add file && git commit -m third &&
-
-	test_tick &&
-	echo A >file && git add file && git commit -m A &&
-	test_tick &&
-	git tag -a -m A A &&
-
-	test_tick &&
-	echo c >file && git add file && git commit -m c &&
-	test_tick &&
-	git tag c &&
-
-	git reset --hard $two &&
-	test_tick &&
-	echo B >side && git add side && git commit -m B &&
-	test_tick &&
-	git tag -a -m B B &&
+	git reset --hard second &&
+	test_commit --annotated-tag B side B &&
 
 	test_tick &&
 	git merge -m Merged c &&
 	merged=$(git rev-parse HEAD) &&
 
-	git reset --hard $two &&
-	test_tick &&
-	echo D >another && git add another && git commit -m D &&
-	test_tick &&
-	git tag -a -m D D &&
-	test_tick &&
-	git tag -a -m R R &&
-
-	test_tick &&
-	echo DD >another && git commit -a -m another &&
+	git reset --hard second &&
+	test_commit --no-tag D another D &&
 
 	test_tick &&
-	git tag e &&
+	git tag -a -m R R &&
 
-	test_tick &&
-	echo DDD >another && git commit -a -m "yet another" &&
+	test_commit e another DD &&
+	test_commit --no-tag "yet another" another DDD &&
 
 	test_tick &&
 	git merge -m Merged $merged &&
 
-	test_tick &&
-	echo X >file && echo X >side && git add file side &&
-	git commit -m x
-
+	test_commit --no-tag x file
 '
 
 check_describe A-8-gHASH HEAD
-- 
2.31.0.rc0.116.g45ec00aa00
Previous: Junio C HamanoNext: Junio C Hamano
Message 26 of 34 in “describe: dont abort too early when searching tags”
  1. describe: dont abort too early when searching tagsBenno Evers, Feb 23, 2020
  2. Junio C HamanoFeb 24, 2020
  3. benno@bmevers.deFeb 25, 2020
  4. Junio C HamanoFeb 25, 2020
  5. 00/10 describe tests: refactor & fix recent broken testsÆvar Arnfjörð Bjarmason, Feb 28, 2021
  6. Junio C HamanoMar 9, 2021
  7. Junio C HamanoMar 12, 2021
  8. 0/5 describe test fixesÆvar Arnfjörð Bjarmason, Apr 12, 2021
  9. 1/5 describe tests: improve test for --work-tree & --dirtyÆvar Arnfjörð Bjarmason, Apr 12, 2021
  10. 3/5 describe tests: don't rely on err.actual from "check_describe"Ævar Arnfjörð Bjarmason, Apr 12, 2021
  11. 2/5 describe tests: refactor away from glob matchingÆvar Arnfjörð Bjarmason, Apr 12, 2021
  12. 4/5 describe tests: fix nested "test_expect_success" callÆvar Arnfjörð Bjarmason, Apr 12, 2021
  13. 5/5 describe tests: support -C in "check_describe"Ævar Arnfjörð Bjarmason, Apr 12, 2021
  14. 0/2 svn tests: trivial "set -e" in main body of test fixesÆvar Arnfjörð Bjarmason, Apr 12, 2021
  15. 1/2 svn tests: remove legacy re-setup from init-clone testÆvar Arnfjörð Bjarmason, Apr 12, 2021
  16. 2/2 svn tests: refactor away a "set -e" in test bodyÆvar Arnfjörð Bjarmason, Apr 12, 2021
  17. 01/10 describe tests: improve test for --work-tree & --dirtyÆvar Arnfjörð Bjarmason, Feb 28, 2021
  18. 02/10 describe tests: refactor away from glob matchingÆvar Arnfjörð Bjarmason, Feb 28, 2021
  19. Junio C HamanoMar 1, 2021
  20. 04/10 test-lib functions: add an --annotated-tag option to "test_commit"Ævar Arnfjörð Bjarmason, Feb 28, 2021
  21. Junio C HamanoMar 1, 2021
  22. Ævar Arnfjörð BjarmasonMar 2, 2021
  23. Junio C HamanoMar 3, 2021
  24. 03/10 describe tests: always assert empty stderr from "describe"Ævar Arnfjörð Bjarmason, Feb 28, 2021
  25. Junio C HamanoMar 1, 2021
  26. 05/10 describe tests: convert setup to use test_commitÆvar Arnfjörð Bjarmason, Feb 28, 2021
  27. Junio C HamanoMar 1, 2021
  28. 06/10 describe tests: fix nested "test_expect_success" callÆvar Arnfjörð Bjarmason, Feb 28, 2021
  29. 08/10 svn tests: remove legacy re-setup from init-clone testÆvar Arnfjörð Bjarmason, Feb 28, 2021
  30. 07/10 describe tests: support -C in "check_describe"Ævar Arnfjörð Bjarmason, Feb 28, 2021
  31. 09/10 svn tests: refactor away a "set -e" in test bodyÆvar Arnfjörð Bjarmason, Feb 28, 2021
  32. Eric WongFeb 28, 2021
  33. 10/10 test-lib: return 1 from test_expect_{success,failure}Ævar Arnfjörð Bjarmason, Feb 28, 2021
  34. Junio C HamanoMar 1, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.