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

Re: [PATCH] test-lib: some shells do not let $? propagate into an eval

From
Jeff King <peff@peff.net>
Date
May 6, 2010, 08:57 UTC
Message-ID
<20100506085720.GA31873@coredump.intra.peff.net>
In-Reply-To
<20100506084045.GA25917@progeny.tock>
On Thu, May 06, 2010 at 03:41:10AM -0500, Jonathan Nieder wrote:
Show 9 quoted lines
> I tried the cleanup_ret idea; test_run_ ended up looking like this:
> 
> 	test_cleanup=:
> 	eval >&3 2>&4 "$1"
> 	eval_ret=$?
> 	eval >&3 2>&4 ":; $test_cleanup"
> 	cleanup_ret=?
> 	(exit "$test_ret") && (exit "$cleanup_ret")
> 	eval_ret=$?

Maybe it is just me, but those last two lines would be much more readable as:

  if test "$eval_ret" = 0; then
    eval_ret=$cleanup_ret
  fi
assuming your "$test_ret" was supposed to be $eval_ret.
> That breaks the principle of keeping the ugliness in test_when_finished.
> So here’s the minimal fix.

I don't know that we have necessarily have that principle. The most important thing is that ugliness not escape to the test scripts themselves, where we have to write many thousands of (hopefully readable) lines.

But...
> -- 8< --
> Subject: test-lib: some shells do not let $? propagate into an eval
This fix looks fine to me, and I tested it on FreeBSD 8.0. So:
 Acked-by: Jeff King <peff@peff.net>
> I was also surprised to see this migrate to maint so quickly, but I
> was happy to see it broke early and loudly.

I think Junio is much more carefree with changes that only touch test infrastructure, as they cannot possibly be breaking git itself for anybody.

> Because there is some unhappiness with the feature[1], it might make

To clarify my position, I am not that negative on the feature. I just think it is a bit of a fool's errand, and I don't want to personally spend any time on making it happen. If you think it is worth proceeding and you can do so without breaking anything[1], I won't object.

[1] Yes, I am teasing you. But probably the complex part is now done, and you and others can use test_when_finished() at will now, and we can see if it actually makes anybody's life better.

-Peff
Previous: Jonathan NiederNext: Junio C Hamano
Message 6 of 11 in “1.7.2 cycle will open soon”
  1. Junio C HamanoMay 5, 2010
  2. Jeff KingMay 6, 2010
  3. Jonathan NiederMay 6, 2010
  4. Jeff KingMay 6, 2010
  5. test-lib: some shells do not let $? propagate into an evalJonathan Nieder, May 6, 2010
  6. Jeff KingMay 6, 2010
  7. Junio C HamanoMay 6, 2010
  8. Johannes SixtMay 6, 2010
  9. Jeff KingMay 6, 2010
  10. Jonathan NiederMay 6, 2010
  11. Johannes SixtMay 6, 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.