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

Re: [PATCH 3/6] t5516 (fetch-push): introduce mk_test_with_name()

From
Jeff King <peff@peff.net>
Date
Mar 20, 2013, 18:58 UTC
Message-ID
<20130320185844.GB30165@sigill.intra.peff.net>
In-Reply-To
<20130320184157.GO3655@google.com>
On Wed, Mar 20, 2013 at 11:41:57AM -0700, Jonathan Nieder wrote:
Show 11 quoted lines
> Ramkumar Ramachandra wrote:
> > Jonathan Nieder wrote:
> 
> >> I dunno.  The helper functions at the top of this test are already
> >> intimidating, so I guess I am looking for a way to avoid making that
> >> problem worse.
> [...]
> > My patch does not make the situation worse in any way:
> 
> Um, yes it does.  It adds another function to learn to an already
> intimidating list.

Personally I do not find the set of helper functions intimidating. I tend to read the tests in a top-down manner: a test is interesting (usually because it fails), and then I want to see what it is doing, so I look at any functions it calls, and so forth.

What I usually find _much_ harder to debug is when there is hidden state leftover from other tests. So even though it is longer to write, I would much rather see:

  test_expect_success 'check that frob only affects foo' '
          set_state_of foo &&
          set_state_of bar &&
          git frob &&
          check_state_of foo &&
          check_state_of bar
  '

than for the test to assume the state of "foo" or "bar" prior to the test. And I think helper functions can help make writing those sorts of pre-conditions more reasonable (and without looking too hard, I think t5516 does an OK job of that).

Related to that is when the helper functions operate on hidden state. In this instance, we have tests that do things like:

    mk_empty &&
    git push testrepo refs/heads/master:refs/remotes/origin/master

and as a reader I say "wait, what's in testrepo?". I can follow mk_empty and see that it hardcodes testrepo, but it is even better if the function and its arguments are named in a way that I don't have to. So even though it is more typing, I would argue that:

  mk_empty testrepo &&
  git push testrepo ...
is better, because the test script is more readable as a unit.

None of this is that huge a deal to me (and yet I seem to have written a page about it :) ), but I figure while we are bikeshedding about test style...

-Peff
Previous: Jonathan NiederNext: Junio C Hamano
Message 13 of 33 in “Support triangular workflows”
  1. 0/6 Support triangular workflowsRamkumar Ramachandra, Mar 20, 2013
  2. 1/6 remote.c: simplify a bit of code using git_config_string()Ramkumar Ramachandra, Mar 20, 2013
  3. Jonathan NiederMar 20, 2013
  4. Ramkumar RamachandraMar 20, 2013
  5. 2/6 t5516 (fetch-push): update test descriptionRamkumar Ramachandra, Mar 20, 2013
  6. Jonathan NiederMar 20, 2013
  7. Ramkumar RamachandraMar 20, 2013
  8. Jonathan NiederMar 20, 2013
  9. 3/6 t5516 (fetch-push): introduce mk_test_with_name()Ramkumar Ramachandra, Mar 20, 2013
  10. Jonathan NiederMar 20, 2013
  11. Ramkumar RamachandraMar 20, 2013
  12. Jonathan NiederMar 20, 2013
  13. Jeff KingMar 20, 2013
  14. Junio C HamanoMar 20, 2013
  15. Jonathan NiederMar 20, 2013
  16. 4/6 remote.c: introduce a way to have different remotes for fetch/pushRamkumar Ramachandra, Mar 20, 2013
  17. Jonathan NiederMar 20, 2013
  18. Junio C HamanoMar 20, 2013
  19. Ramkumar RamachandraMar 20, 2013
  20. Junio C HamanoMar 20, 2013
  21. 5/6 remote.c: introduce remote.pushdefaultRamkumar Ramachandra, Mar 20, 2013
  22. Jonathan NiederMar 20, 2013
  23. Junio C HamanoMar 20, 2013
  24. Ramkumar RamachandraMar 20, 2013
  25. 6/6 remote.c: introduce branch.<name>.pushremoteRamkumar Ramachandra, Mar 20, 2013
  26. Tay Ray ChuanMar 20, 2013
  27. Ramkumar RamachandraMar 20, 2013
  28. Tay Ray ChuanMar 20, 2013
  29. Ramkumar RamachandraMar 22, 2013
  30. Philip OakleyMar 20, 2013
  31. Ramkumar RamachandraMar 22, 2013
  32. Junio C HamanoMar 22, 2013
  33. Ramkumar RamachandraMar 23, 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.