git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Brandon Casey <casey@nrlssc.navy.mil>
Cc: git@vger.kernel.org, erick.mattos@gmail.com, avarab@gmail.com,
	jrnieder@gmail.com, jaredhance@gmail.com, drafnel@gmail.com
Subject: Re: [PATCH] t/: work around one-shot variable assignment with test_must_fail
Date: Wed, 21 Jul 2010 12:29:28 -0700	[thread overview]
Message-ID: <7v1vawk50n.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <iU5XdZGtMeaspoCqSJIp6Y--60TPVkZUrm3SdW86dsTZkNYZWqbSppLBrMXyL1rVqqYtHm94ACo@cipher.nrlssc.navy.mil> (Brandon Casey's message of "Tue\, 20 Jul 2010 16\:55\:31 -0500")

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' '

  parent reply	other threads:[~2010-07-21 19:29 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-20 15:24 [PATCH] t/t3700: convert two uses of negation operator '!' to use test_must_fail Brandon Casey
2010-07-20 15:55 ` Ævar Arnfjörð Bjarmason
2010-07-20 16:32   ` Brandon Casey
2010-07-20 16:38     ` Jared Hance
2010-07-20 17:17       ` [PATCH] t/README: clarify test_must_fail description Brandon Casey
2010-07-20 18:00         ` Junio C Hamano
2010-07-20 18:06           ` Ævar Arnfjörð Bjarmason
2010-07-20 18:14             ` Jared Hance
2010-07-20 19:09               ` [PATCH] Convert "! git" to "test_must_fail" git Jared Hance
2010-07-20 19:42                 ` Brandon Casey
2010-07-20 19:48                   ` Jonathan Nieder
2010-07-20 19:59                     ` Brandon Casey
2010-07-20 23:18                   ` [PATCH v2] Convert "! git" to "test_must_fail git" Jared Hance
2010-07-20 18:34             ` [PATCH] t/README: clarify test_must_fail description Junio C Hamano
2010-07-20 18:43               ` Ævar Arnfjörð Bjarmason
2010-07-20 19:16                 ` Jonathan Nieder
2010-07-20 20:49                   ` Ævar Arnfjörð Bjarmason
2010-07-20 21:12                     ` Brandon Casey
2010-07-20 21:25                       ` Ævar Arnfjörð Bjarmason
2010-07-20 21:55                       ` [PATCH] t/: work around one-shot variable assignment with test_must_fail Brandon Casey
2010-07-20 23:19                         ` Erick Mattos
     [not found]                           ` <20100721000823.GD4282@burratino>
     [not found]                             ` <AANLkTinlXsbp0NdhmqvlrmBBqGuGOIkh6PzGYFnk05qv@mail.gmail.com>
     [not found]                               ` <20100721141140.GA12123@burratino>
     [not found]                                 ` <AANLkTinhyFD4RhLLxS-jj-oX5VWqGyy7AiXJ3VJlcU2W@mail.gmail.com>
2010-07-21 15:23                                   ` [PATCH] gitweb: clarify search results page when no matching commit found Jonathan Nieder
2010-07-21 17:51                                     ` Jakub Narebski
2010-07-21 19:50                                       ` [PATCH v2] " Jonathan Nieder
2010-07-21 15:32                           ` [PATCH] t/: work around one-shot variable assignment with test_must_fail Brandon Casey
2010-07-22  0:28                             ` Erick Mattos
2010-07-20 23:44                         ` Ævar Arnfjörð Bjarmason
2010-07-20 23:45                           ` Ævar Arnfjörð Bjarmason
2010-07-21  0:01                           ` Jonathan Nieder
2010-07-21  0:09                             ` Ævar Arnfjörð Bjarmason
2010-07-21  0:14                               ` Jonathan Nieder
2010-07-21  0:34                                 ` Ævar Arnfjörð Bjarmason
2010-07-21  1:05                                   ` git name-rev for fun and profit (Re: [PATCH] t/: work around one-shot variable assignment with test_must_fail) Jonathan Nieder
2010-07-21 11:32                                     ` Ævar Arnfjörð Bjarmason
2010-07-21 19:29                         ` Junio C Hamano [this message]
2010-07-22  0:32                           ` [PATCH] t/: work around one-shot variable assignment with test_must_fail Erick Mattos
2010-07-22 18:21                           ` Brandon Casey
2010-07-20 18:19           ` [PATCH] t/README: clarify test_must_fail description Brandon Casey
2010-07-20 17:52       ` [PATCH] t/t3700: convert two uses of negation operator '!' to use test_must_fail Ævar Arnfjörð Bjarmason
2010-07-20 18:25     ` Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v1vawk50n.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=casey@nrlssc.navy.mil \
    --cc=drafnel@gmail.com \
    --cc=erick.mattos@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jaredhance@gmail.com \
    --cc=jrnieder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).