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

Re: [PATCH 10/10] t: make 'test_i18ngrep' more informative on failure

From
Jeff King <peff@peff.net>
Date
Jan 26, 2018, 18:50 UTC
Message-ID
<20180126185007.GG27618@sigill.intra.peff.net>
In-Reply-To
<20180126123708.21722-11-szeder.dev@gmail.com>
On Fri, Jan 26, 2018 at 01:37:08PM +0100, SZEDER Gábor wrote:
Show 9 quoted lines
> When 'test_i18ngrep' can't find the expected pattern, it exits
> completely silently; when its negated form does find the pattern that
> shouldn't be there, it prints the matching line(s) but otherwise exits
> without any error message.  This leaves the developer puzzled about
> what could have gone wrong.
> 
> Make 'test_i18ngrep' more informative on failure by printing an error
> message including the invoked 'grep' command and the contents of the
> file it had to scan through.

I think this is an improvement. You can also use "-x" to get a better sense of exactly which command failed, but I have never been sad to see more verbose output from failing tests by default. :)

Show 16 quoted lines
> Note that this "dump the scanned file" part is not quite perfect, as
> it dumps only the file specified as the function's last positional
> parameter, thus assuming that there is only a single file parameter.
> I think that's a reasonable assumption to make, one that holds true in
> the current code base.  And even if someone were to scan multiple
> files at once in the future, the worst thing that could happen is that
> the verbose error message won't include the contents of all those
> files, only the last one.  Alas, we can't really do any better than
> this, because checking whether the other positional parameters match a
> filename can result in false positives: 't3400-rebase.sh' and
> 't3404-rebase-interactive.sh' contain one test each, where the
> 'test_i18ngrep's pattern verbatimely matches a file in the trash
> directory.  Note that the absence of a file parameter is not an issue,
> because the lint check added in the previous commit ensures that
> 'test_i18ngrep' never reads from its standard input, consequently
> there must be a file parameter.

Heh, this makes me support even more the "last one must be a file" rule that Junio suggested for the linting check.

-Peff
Previous: SZEDER GáborNext: SZEDER Gábor
Message 11 of 49 in “'test_i18ngrep'-related fixes and improvements”
  1. 00/10 'test_i18ngrep'-related fixes and improvementsSZEDER Gábor, Jan 26, 2018
  2. 01/10 t5541: add 'test_i18ngrep's missing filename parameterSZEDER Gábor, Jan 26, 2018
  3. Jeff KingJan 26, 2018
  4. Jeff KingJan 26, 2018
  5. 04/10 t4001: don't run 'git status' upstream of a pipeSZEDER Gábor, Jan 26, 2018
  6. 07/10 t: move 'test_i18ncmp' and 'test_i18ngrep' to 'test-lib-functions.sh'SZEDER Gábor, Jan 26, 2018
  7. Junio C HamanoJan 26, 2018
  8. Jeff KingJan 26, 2018
  9. SZEDER GáborJan 26, 2018
  10. 10/10 t: make 'test_i18ngrep' more informative on failureSZEDER Gábor, Jan 26, 2018
  11. Jeff KingJan 26, 2018
  12. SZEDER GáborJan 26, 2018
  13. Jeff KingJan 26, 2018
  14. SZEDER GáborJan 26, 2018
  15. Jeff KingJan 26, 2018
  16. 06/10 t5536: let 'test_i18ngrep' read the file without redirectionSZEDER Gábor, Jan 26, 2018
  17. 09/10 t: make sure that 'test_i18ngrep' got enough parametersSZEDER Gábor, Jan 26, 2018
  18. Jeff KingJan 26, 2018
  19. Eric SunshineJan 26, 2018
  20. 05/10 t5510: consolidate 'grep' and 'test_i18ngrep' patternsSZEDER Gábor, Jan 26, 2018
  21. Junio C HamanoJan 26, 2018
  22. SZEDER GáborJan 26, 2018
  23. Junio C HamanoJan 26, 2018
  24. 08/10 t: forbid piping into 'test_i18ngrep'SZEDER Gábor, Jan 26, 2018
  25. Junio C HamanoJan 26, 2018
  26. Junio C HamanoJan 26, 2018
  27. Jeff KingJan 26, 2018
  28. SZEDER GáborJan 26, 2018
  29. Junio C HamanoJan 26, 2018
  30. Jeff KingJan 26, 2018
  31. 02/10 t5812: add 'test_i18ngrep's missing filename parameterSZEDER Gábor, Jan 26, 2018
  32. Jeff KingJan 26, 2018
  33. SZEDER GáborFeb 7, 2018
  34. Jeff KingFeb 7, 2018
  35. Simon RuderichJan 30, 2018
  36. 03/10 t6022: don't run 'git merge' upstream of a pipeSZEDER Gábor, Jan 26, 2018
  37. Jeff KingJan 26, 2018
  38. 0/9 'test_i18ngrep'-related fixes and improvementsSZEDER Gábor, Feb 8, 2018
  39. 1/9 t5541: add 'test_i18ngrep's missing filename parameterSZEDER Gábor, Feb 8, 2018
  40. 4/9 t4001: don't run 'git status' upstream of a pipeSZEDER Gábor, Feb 8, 2018
  41. 8/9 t: validate 'test_i18ngrep's parametersSZEDER Gábor, Feb 8, 2018
  42. Jeff KingFeb 8, 2018
  43. 9/9 t: make 'test_i18ngrep' more informative on failureSZEDER Gábor, Feb 8, 2018
  44. 5/9 t5510: consolidate 'grep' and 'test_i18ngrep' patternsSZEDER Gábor, Feb 8, 2018
  45. 6/9 t5536: let 'test_i18ngrep' read the file without redirectionSZEDER Gábor, Feb 8, 2018
  46. 7/9 t: move 'test_i18ncmp' and 'test_i18ngrep' to 'test-lib-functions.sh'SZEDER Gábor, Feb 8, 2018
  47. 2/9 t5812: add 'test_i18ngrep's missing filename parameterSZEDER Gábor, Feb 8, 2018
  48. 3/9 t6022: don't run 'git merge' upstream of a pipeSZEDER Gábor, Feb 8, 2018
  49. Jeff KingFeb 8, 2018

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.