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

Re: [PATCH v2 1/3] diff-highlight: add some tests.

From
Jeff King <peff@peff.net>
Date
Aug 19, 2016, 14:51 UTC
Message-ID
<20160819145123.73hf7ffysy53l3kz@sigill.intra.peff.net>
In-Reply-To
<20160819144235.GA29458@tci.corp.yp.com>
On Fri, Aug 19, 2016 at 07:42:35AM -0700, Brian Henderson wrote:
Show 20 quoted lines
> > > +# PERL is required, but assumed to be present, although not necessarily modern
> > > +# some tests require 5.8
> > > +test_expect_success PERL 'name' 'true'
> > 
> > If the platform lacks PERL prerequisite, this will simply be
> > skipped, and if the platform has it, it will always succeed.
> > 
> > I am not sure what you are trying to achieve by having this line
> > here.
> 
> I originally didn't have this line, and my comment was referring to the
> t/README which says
> 
>    Even without the PERL prerequisite, tests can assume there is a
>    usable perl interpreter at $PERL_PATH, though it need not be
>    particularly modern.
> 
> There is current functionality in diff-highlight which requires at least
> perl 5.8 (the utf8 functions). I was going to add a test for this as
> well, but I'm not super comfy with multibyte chars.

Yeah, I'd agree this test would want the PERL prereq. It is not just using perl for one-liners in support of the script; it is testing major perl functionality that should be skipped if we do not have a modern perl available.

> Eric recommended adding this line, what do you think?
> 
> would `test_set_prereq PERL` be better?

test_set_prereq is for telling the test scripts that we _have_ perl, but what I think this script wants to do is test "do we have perl?" and abort otherwise. The way to do that is:

  if ! test_have_prereq PERL
  then
	skip_all='skipping diff-highlight tests; perl not available'
	test_done
  fi
Show 8 quoted lines
> > > +test_expect_success 'diff-highlight does not highlight whole line' '
> > > +	dh_test \
> > > +		"aaa\nbbb\nccc\n" \
> > > +		"aaa\n000\nccc\n"
> > > +'
> 
> This (at least to me) is desired. See comment for `sub
> is_pair_interesting`
Yeah, that is an intentional behavior, and makes sense to test.
Show 10 quoted lines
> > > +test_expect_success 'diff-highlight does not highlight mismatched hunk size' '
> > > +	dh_test \
> > > +		"aaa\nbbb\n" \
> > > +		"aaa\nb0b\nccc\n"
> > > +'
> 
> This is undesired behavior, but currently implemented for simplicity,
> see `sub show_hunk`
> 
> Do they need comments or something?

Undesired behavior should generally not be tested for. It just makes life harder for somebody when they make a change that violates it, and they have to figure out "oh, but it's _good_ that I changed that, the tests were wrong" (or more likely "I didn't fix it, but it's just broken in a different way, and neither is preferable").

If you want to document known shortcomings, the best thing to do is show what you'd _like_ to have happen, and mark it as test_expect_failure; the test scripts show this as a known-breakage, and somebody later who fixes it can flip the "failure" to "success".

-Peff
Previous: Brian HendersonNext: Brian Henderson
Message 16 of 24 in “diff-highlight: add support for git log --graph output.”
  1. 0/3 diff-highlight: add support for git log --graph output.Brian Henderson, Jul 30, 2016
  2. 3/3 diff-highlight: add support for --graph output.Brian Henderson, Jul 30, 2016
  3. Junio C HamanoAug 1, 2016
  4. diff-highlight: Add comment for our assumption about --graph output.Brian Henderson, Aug 4, 2016
  5. 2/3 diff-highlight: add failing test for handling --graph output.Brian Henderson, Jul 30, 2016
  6. 1/3 diff-highlight: add some tests.Brian Henderson, Jul 30, 2016
  7. Eric WongAug 10, 2016
  8. Brian HendersonAug 15, 2016
  9. Junio C HamanoAug 15, 2016
  10. 0/3 diff-highlight: add support for git log --graph output.Brian Henderson, Aug 17, 2016
  11. 2/3 diff-highlight: add failing test for handling --graph output.Brian Henderson, Aug 17, 2016
  12. Junio C HamanoAug 17, 2016
  13. 1/3 diff-highlight: add some tests.Brian Henderson, Aug 17, 2016
  14. Junio C HamanoAug 17, 2016
  15. Brian HendersonAug 19, 2016
  16. Jeff KingAug 19, 2016
  17. Brian HendersonAug 19, 2016
  18. 3/3 diff-highlight: add support for --graph output.Brian Henderson, Aug 17, 2016
  19. Jeff KingAug 19, 2016
  20. Eric WongAug 19, 2016
  21. Jeff KingAug 19, 2016
  22. Lars SchneiderAug 15, 2016
  23. Junio C HamanoAug 16, 2016
  24. Lars SchneiderAug 24, 2016

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.