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

Re: [PATCH] t/: work around one-shot variable assignment with test_must_fail

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 21, 2010, 19:29 UTC
Message-ID
<7v1vawk50n.fsf@alter.siamese.dyndns.org>
In-Reply-To
<iU5XdZGtMeaspoCqSJIp6Y--60TPVkZUrm3SdW86dsTZkNYZWqbSppLBrMXyL1rVqqYtHm94ACo@cipher.nrlssc.navy.mil>
Brandon Casey <casey@nrlssc.navy.mil> writes:
> No time to investigate, but here is an example patch and the
> results of running the affected tests.  Looks like reflog may
> be creating a reflog when it is not supposed to.

Your later analysis is correct; "git reflog show <branch>" does not complain when there is no reflog for <branch>, which might or might not be a bug.

Because these tests are not about behaviour of "git reflog show" command, let's do this for now.

Thanks.
-- >8 --
Subject: tests: correct "does reflog exist" tests

These two tests were not about how "git reflog show <branch>" exits when there is no reflog, but were about whether "checkout" and "branch" create or not create reflog when creating a new <branch>, update the tests to check it in a more direct way, namely using "git rev-parse --verify".

Also lose tests based on "test -f .git/logs/refs/heads/<branch>" from nearby, to avoid exposing this particular implementation detail unnecessarily.

---
 t/t2017-checkout-orphan.sh |   47 +++++++------------------------------------
 t/t3200-branch.sh          |   13 ++---------
 2 files changed, 11 insertions(+), 49 deletions(-)
diff --git a/t/t2017-checkout-orphan.sh b/t/t2017-checkout-orphan.sh
index 81cb393..2d2f63f 100755
--- a/t/t2017-checkout-orphan.sh
+++ b/t/t2017-checkout-orphan.sh
@@ -68,65 +68,34 @@ test_expect_success '--orphan makes reflog by default' '
 	git checkout master &&
 	git config --unset core.logAllRefUpdates &&
 	git checkout --orphan delta &&
-	! test -f .git/logs/refs/heads/delta &&
-	(
-		PAGER= &&
-		export PAGER &&
-		test_must_fail git reflog show delta
-	) &&
+	test_must_fail git rev-parse --verify delta@{0} &&
 	git commit -m Delta &&
-	test -f .git/logs/refs/heads/delta &&
-	PAGER= git reflog show delta
+	git rev-parse --verify delta@{0}
 '
 
 test_expect_success '--orphan does not make reflog when core.logAllRefUpdates = false' '
 	git checkout master &&
 	git config core.logAllRefUpdates false &&
 	git checkout --orphan epsilon &&
-	! test -f .git/logs/refs/heads/epsilon &&
-	(
-		PAGER= &&
-		export PAGER &&
-		test_must_fail git reflog show epsilon
-	) &&
+	test_must_fail git rev-parse --verify epsilon@{0} &&
 	git commit -m Epsilon &&
-	! test -f .git/logs/refs/heads/epsilon &&
-	(
-		PAGER= &&
-		export PAGER &&
-		test_must_fail git reflog show epsilon
-	)
+	test_must_fail git rev-parse --verify epsilon@{0}
 '
 
 test_expect_success '--orphan with -l makes reflog when core.logAllRefUpdates = false' '
 	git checkout master &&
 	git checkout -l --orphan zeta &&
-	test -f .git/logs/refs/heads/zeta &&
-	(
-		PAGER= &&
-		export PAGER &&
-		test_must_fail git reflog show zeta
-	) &&
+	test_must_fail git rev-parse --verify zeta@{0} &&
 	git commit -m Zeta &&
-	PAGER= git reflog show zeta
+	git rev-parse --verify zeta@{0}
 '
 
 test_expect_success 'giving up --orphan not committed when -l and core.logAllRefUpdates = false deletes reflog' '
 	git checkout master &&
 	git checkout -l --orphan eta &&
-	test -f .git/logs/refs/heads/eta &&
-	(
-		PAGER= &&
-		export PAGER &&
-		test_must_fail git reflog show eta
-	) &&
+	test_must_fail git rev-parse --verify eta@{0} &&
 	git checkout master &&
-	! test -f .git/logs/refs/heads/eta &&
-	(
-		PAGER= &&
-		export PAGER &&
-		test_must_fail git reflog show eta
-	)
+	test_must_fail git rev-parse --verify eta@{0}
 '
 
 test_expect_success '--orphan is rejected with an existing name' '
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index bf7747d..f54a533 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -228,28 +228,21 @@ test_expect_success 'checkout -b makes reflog by default' '
 	git checkout master &&
 	git config --unset core.logAllRefUpdates &&
 	git checkout -b alpha &&
-	test -f .git/logs/refs/heads/alpha &&
-	PAGER= git reflog show alpha
+	git rev-parse --verify alpha@{0}
 '
 
 test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates = false' '
 	git checkout master &&
 	git config core.logAllRefUpdates false &&
 	git checkout -b beta &&
-	! test -f .git/logs/refs/heads/beta &&
-	(
-		PAGER= &&
-		export PAGER &&
-		test_must_fail git reflog show beta
-	)
+	test_must_fail git rev-parse --verify beta@{0}
 '
 
 test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' '
 	git checkout master &&
 	git checkout -lb gamma &&
 	git config --unset core.logAllRefUpdates &&
-	test -f .git/logs/refs/heads/gamma &&
-	PAGER= git reflog show gamma
+	git rev-parse --verify gamma@{0}
 '
 
 test_expect_success 'avoid ambiguous track' '
Previous: Ævar Arnfjörð BjarmasonNext: Erick Mattos
Message 32 of 40 in “t/t3700: convert two uses of negation operator '!' to use test_must_fail”
  1. t/t3700: convert two uses of negation operator '!' to use test_must_failBrandon Casey, Jul 20, 2010
  2. Ævar Arnfjörð BjarmasonJul 20, 2010
  3. Brandon CaseyJul 20, 2010
  4. Jared HanceJul 20, 2010
  5. t/README: clarify test_must_fail descriptionBrandon Casey, Jul 20, 2010
  6. Junio C HamanoJul 20, 2010
  7. Ævar Arnfjörð BjarmasonJul 20, 2010
  8. Jared HanceJul 20, 2010
  9. Convert "! git" to "test_must_fail" git.Jared Hance, Jul 20, 2010
  10. Brandon CaseyJul 20, 2010
  11. Jonathan NiederJul 20, 2010
  12. Brandon CaseyJul 20, 2010
  13. Convert "! git" to "test_must_fail git"Jared Hance, Jul 20, 2010
  14. Junio C HamanoJul 20, 2010
  15. Ævar Arnfjörð BjarmasonJul 20, 2010
  16. Jonathan NiederJul 20, 2010
  17. Ævar Arnfjörð BjarmasonJul 20, 2010
  18. Brandon CaseyJul 20, 2010
  19. Ævar Arnfjörð BjarmasonJul 20, 2010
  20. t/: work around one-shot variable assignment with test_must_failBrandon Casey, Jul 20, 2010
  21. Erick MattosJul 20, 2010
  22. Brandon CaseyJul 21, 2010
  23. Erick MattosJul 22, 2010
  24. Ævar Arnfjörð BjarmasonJul 20, 2010
  25. Ævar Arnfjörð BjarmasonJul 20, 2010
  26. Jonathan NiederJul 21, 2010
  27. Ævar Arnfjörð BjarmasonJul 21, 2010
  28. Jonathan NiederJul 21, 2010
  29. Ævar Arnfjörð BjarmasonJul 21, 2010
  30. git name-rev for fun and profit (Re: [PATCH] t/: work around one-shot variable assignment with test_must_fail)Jonathan Nieder, Jul 21, 2010
  31. Ævar Arnfjörð BjarmasonJul 21, 2010
  32. Junio C HamanoJul 21, 2010
  33. Erick MattosJul 22, 2010
  34. Brandon CaseyJul 22, 2010
  35. Brandon CaseyJul 20, 2010
  36. Ævar Arnfjörð BjarmasonJul 20, 2010
  37. Ævar Arnfjörð BjarmasonJul 20, 2010
  38. gitweb: clarify search results page when no matching commit foundJonathan Nieder, Jul 21, 2010
  39. Jakub NarebskiJul 21, 2010
  40. gitweb: clarify search results page when no matching commit foundJonathan Nieder, Jul 21, 2010

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.