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

Re: [PATCH 1/2] t/test-lib.sh: Let test_must_fail fail on signals only

From
Jeff King <peff@peff.net>
Date
Jul 17, 2008, 05:18 UTC
Message-ID
<20080717051833.GA3100@sigio.intra.peff.net>
In-Reply-To
<7v4p6qwezy.fsf@gitster.siamese.dyndns.org>
On Tue, Jul 15, 2008 at 10:54:25PM -0700, Junio C Hamano wrote:
> Anything that returns error() from its cmd_xxx() routine, for example,
> would end up exiting with (-1).  Is it "such bogus" error codes, though?

I think it is bogus, because it is being implicitly truncated to an unsigned 8-bit value (at least on Linux -- I have no idea what other platforms do). So your -1 is actually 255. Portably speaking, C defines only the macros EXIT_SUCCESS and EXIT_FAILURE; in practice, I don't know what is most common.

Bad side effects of not treating your exit codes as unsigned 8-bit integers:

  - the exit values are easily confused with other things, like signal
    death. As in this case. We have modified our checking code in the
    test scripts, but there may be other, less robust code out there.
  - other exit values can be mistaken as success. Obviously 256, -256,
    512, -512, etc all produce an erroneous "success". Now we aren't
    doing this, as we are using "-1", but it just seems a bit cleaner to
    be up front about what is happening (and the 255 we end up with is
    unnecessarily confusing; some documents, like this one:
      http://tldp.org/LDP/abs/html/exitcodes.html
    claim 255 as "out of range").

So what we are doing now isn't terrible, but since it was noted (and did in fact cause a problem!), I just expected a "let's stop doing that" patch in the original series.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 15 in “t/test-lib.sh: Let test_must_fail fail on signals only”
  1. 1/2 t/test-lib.sh: Let test_must_fail fail on signals onlyStephan Beyer, Jul 12, 2008
  2. 2/2 t/: Use "test_must_fail git" instead of "! git"Stephan Beyer, Jul 12, 2008
  3. Jakub NarebskiJul 12, 2008
  4. Stephan BeyerJul 12, 2008
  5. t9001: Use "test_must_fail git" instead of "! git"Stephan Beyer, Jul 12, 2008
  6. Jeff KingJul 16, 2008
  7. Junio C HamanoJul 16, 2008
  8. Jeff KingJul 17, 2008
  9. Junio C HamanoJul 17, 2008
  10. Jeff KingJul 17, 2008
  11. Junio C HamanoJul 17, 2008
  12. Jeff KingJul 17, 2008
  13. Johannes SixtJul 17, 2008
  14. Junio C HamanoJul 17, 2008
  15. Stephan BeyerJul 16, 2008

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.