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

Re: [PATCH 2/3] test: improve rebase -q test

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Jun 10, 2013, 20:19 UTC
Message-ID
<20130610201933.GI2091@goldbirke>
In-Reply-To
<51B623DA.4050802@kdbg.org>
On Mon, Jun 10, 2013 at 09:07:06PM +0200, Johannes Sixt wrote:
Show 10 quoted lines
> Am 10.06.2013 19:27, schrieb SZEDER Gábor:
> > My main motivation is that, like in your example, in the bash prompt
> > tests I only have to check a single line of output, but because of
> > debuggability I always did:
> > 
> >   echo "(master)" >expected
> >   __git_ps1 >actual
> >   test_cmp expected actual
> 
> Chained by &&, I presume.
Sure.
Show 9 quoted lines
> > With such a helper function this could be reduced to a single line:
> > 
> >   test_string_equal "(master)" "$(__git_ps1)"
> > 
> > without loss of functionality
> 
> Not quite: A non-zero exit code of the $(__git_ps1) is lost. (It
> probably doesn't matter here, but it certainly does if the command is
> $(git rev-parse foo) or similar.)

Ouch, indeed. Yeah, the exit code doesn't matter for the prompt tests (I mean for __git_ps1() tests, but maybe it does matter for some __gitdir() tests), but I suppose it does matter everywhere else where the same construct is used. We could still do

  actual="$(git foo)" &&
  test_string_equal "good" "$actual"

to preserve and check the exit code, and this is still one line shorter, but overall not that appealing anymore.

However. The git command's exit code is lost the same way in 'test good = $(git foo)' constructs, too, and plenty of such constructs are all over the test suite. Shouldn't we avoid using such constucts then?

Gábor
Previous: Johannes SixtNext: Junio C Hamano
Message 19 of 24 in “Trivial patches”
  1. 0/3 Trivial patchesFelipe Contreras, Jun 7, 2013
  2. 1/3 sequencer: trivial fixFelipe Contreras, Jun 7, 2013
  3. Junio C HamanoJun 7, 2013
  4. Felipe ContrerasJun 7, 2013
  5. 2/3 test: improve rebase -q testFelipe Contreras, Jun 7, 2013
  6. Duy NguyenJun 8, 2013
  7. Felipe ContrerasJun 8, 2013
  8. Junio C HamanoJun 9, 2013
  9. Felipe ContrerasJun 9, 2013
  10. Junio C HamanoJun 9, 2013
  11. Felipe ContrerasJun 9, 2013
  12. Junio C HamanoJun 9, 2013
  13. Felipe ContrerasJun 9, 2013
  14. SZEDER GáborJun 10, 2013
  15. Junio C HamanoJun 10, 2013
  16. Felipe ContrerasJun 10, 2013
  17. SZEDER GáborJun 10, 2013
  18. Johannes SixtJun 10, 2013
  19. SZEDER GáborJun 10, 2013
  20. Junio C HamanoJun 10, 2013
  21. Philip OakleyJun 9, 2013
  22. Junio C HamanoJun 9, 2013
  23. Jeff KingJun 10, 2013
  24. 3/3 submodule: remove unnecessary checkFelipe Contreras, Jun 7, 2013

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.