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

Re: [PATCH 3/3] t3503: test cherry picking and reverting root commits

From
Jeff King <peff@peff.net>
Date
May 12, 2011, 12:37 UTC
Message-ID
<20110512123703.GA21078@sigill.intra.peff.net>
In-Reply-To
<4DCBD087.90302@viscovery.net>
On Thu, May 12, 2011 at 02:20:23PM +0200, Johannes Sixt wrote:
Show 13 quoted lines
> Am 5/12/2011 13:10, schrieb Jeff King:
> > +test_expect_success 'cherry-pick a root commit with an external strategy' '
> > +
> > +	git cherry-pick --strategy=resolve master &&
> > +	test first = $(cat file1)
> 
> What if file1 does not exist? Then cat fails loudly. But this does not
> fail the entire command immediately; rather, the test command fails, but
> not because of a non-equality, but because of an invalid usage ("syntax
> error"). IOW, the test does the right thing, but for the wrong reason.
> 
> Yes, an earlier test gave a bad precedent, and the following fixup (to
> be squashed in) fixes it, too.

Yeah, sorry, I blindly copied the earlier test without thinking. If we are going to tweak, my preference is actually to use test_cmp. And while we're at it, I should be using test_path_is_missing.

So:
diff --git a/t/t3503-cherry-pick-root.sh b/t/t3503-cherry-pick-root.sh
index 1f9ed67..9aefe3a 100755
--- a/t/t3503-cherry-pick-root.sh
+++ b/t/t3503-cherry-pick-root.sh
@@ -23,28 +23,30 @@ test_expect_success setup '
 test_expect_success 'cherry-pick a root commit' '
 
 	git cherry-pick master &&
-	test first = $(cat file1)
+	echo first >expect &&
+	test_cmp expect file1
 
 '
 
 test_expect_success 'revert a root commit' '
 
 	git revert master &&
-	! test -f file1
+	test_path_is_missing file1
 
 '
 
 test_expect_success 'cherry-pick a root commit with an external strategy' '
 
 	git cherry-pick --strategy=resolve master &&
-	test first = $(cat file1)
+	echo first >expect &&
+	test_cmp expect file1
 
 '
 
 test_expect_success 'revert a root commit with an external strategy' '
 
 	git revert --strategy=resolve master &&
-	! test -f file1
+	test_path_is_missing file1
 
 '
 
Previous: Johannes SixtNext: Jeff King
Message 10 of 12 in “git cherry-pick --strategy=resolve segfaults if picking a root commit”
  1. Sebastian SchuberthMay 12, 2011
  2. Jeff KingMay 12, 2011
  3. Jeff KingMay 12, 2011
  4. 1/3 cherry-pick: handle root commits with external strategiesJeff King, May 12, 2011
  5. Sebastian SchuberthMay 12, 2011
  6. 2/3 revert: allow reverting a root commitJeff King, May 12, 2011
  7. Sebastian SchuberthMay 12, 2011
  8. 3/3 t3503: test cherry picking and reverting root commitsJeff King, May 12, 2011
  9. Johannes SixtMay 12, 2011
  10. Jeff KingMay 12, 2011
  11. Jeff KingMay 16, 2011
  12. Junio C HamanoMay 16, 2011

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.