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

Re: [PATCH] chainlint.pl: recognize test bodies defined via heredoc

From
Jeff King <peff@peff.net>
Date
Jul 10, 2024, 07:06 UTC
Message-ID
<20240710070647.GA2048777@coredump.intra.peff.net>
In-Reply-To
<CAPig+cRXkOesS_ctvxY2X=rwesTzgrBB0=5fvQLQsG3hZVY9TQ@mail.gmail.com>
On Tue, Jul 09, 2024 at 11:02:01PM -0400, Eric Sunshine wrote:
Show 11 quoted lines
> On Tue, Jul 9, 2024 at 9:09 PM Jeff King <peff@peff.net> wrote:
> > The chainlint.pl parser chokes on CRLF line endings. So Windows CI
> > produces:
> >
> >   runneradmin@fv-az1390-742 MINGW64 /d/a/git/git/t
> >   # perl chainlint.pl chainlint/for-loop.test
> >   'nternal error scanning character '
> 
> As far as I understand, chainlint is disabled in the Windows CI. Did
> you manually re-enable it for testing? Or are you just running it
> manually in the Windows CI?

Neither. As far as I can tell, we still run the "check-chainlint" target as part of "make test", and that's what I saw fail. For instance:

  https://github.com/peff/git/actions/runs/9856301557/job/27213352807

Every one of the "win test" jobs failed, with the same outcome: running check-chainlint triggered the "internal scanning error".

Show 9 quoted lines
> Assuming you manually re-enabled chaintlint in the Windows CI for this
> testing or are running it manually, it may be the case that
> chainlint.pl has never been run in the Windows CI. Specifically,
> chainlint in Windows CI was disabled by a87e427e35 (ci: speed up
> Windows phase, 2019-01-29) which predates the switchover from
> chainlint.sed to chainlint.pl by d00113ec34 (t/Makefile: apply
> chainlint.pl to existing self-tests, 2022-09-01). So, it's quite
> possible that chainlint.pl has never run in Windows CI. But, perhaps
> I'm misunderstanding or missing some piece of information.

I think that commit would prevent it from running as part of the actual test scripts. But we'd still do check-chainlint to run the chainlint self-tests. And because it only sets "--no-chain-lint" in GIT_TEST_OPTS and not GIT_TEST_CHAIN_LINT=0, I think that the bulk run of chainlint.pl by t/Makefile is still run (and then ironically, when that is run the Makefile manually suppresses the per-script runs, so that --no-chain-lint option is truly doing nothing).

And I think is true even with the ci/run-test-slice.sh approach that the Windows tests use. They still drive it through "make", and just override the $(T) variable.

Show 9 quoted lines
> >   - why doesn't "PERLIO=:crlf make check-chainlint" work? It seems that
> >     perl spawned from "make" behaves differently. More mingw weirdness?
> 
> That could indeed be an msys2 issue. It will automatically convert
> colon ":" to semicolon ";" in environment variables since the PATH
> separator on Windows is ";", not ":" as it is on Unix. Moreover, the
> ":" to ";" switcheroo logic is not restricted only to PATH since there
> are other PATH-like variables in common use, so it's applied to all
> environment variables.

Ah, good thinking. I'm not sure if that's it, though. Just PERLIO=crlf should behave the same way (the ":" is technically a separator, and it is only a style suggestion that you prepend one). Likewise a space is supposed to be OK, too, so PERLIO="unix crlf" should work. But neither seems to work for me. So I'm still puzzled.

Show 14 quoted lines
> > I'm tempted to just do this:
> >
> >         while (my $path = $next_script->()) {
> >                 $nscripts++;
> >                 my $fh;
> > -               unless (open($fh, "<", $path)) {
> > +               unless (open($fh, "<:unix:crlf", $path)) {
> >
> > It feels like a hack, but it makes the parser's assumptions explicit,
> > and it should just work everywhere.
> 
> Yep, if this makes it work, then it seems like a good way forward,
> especially since I don't think there's any obvious way to work around
> the ":" to ";" switcheroo performed by msys2.

OK, I'll add that to my series, then. The fact that we weren't really _intending_ to run chainlint there makes me tempted to just punt and disable it. But AFAICT we have been running it for a while, and it could benefit people on Windows (though it is a bit funky that we do a full check-chainlint in each slice). And I suspect disabling it reliably might be a trickier change than what I wrote above anyway. ;)

-Peff
Previous: Eric SunshineNext: Eric Sunshine
Message 43 of 65 in “here-doc test bodies”
  1. 0/2 here-doc test bodiesJeff King, Jul 1, 2024
  2. 1/2 test-lib: allow test snippets as here-docsJeff King, Jul 1, 2024
  3. Eric SunshineJul 1, 2024
  4. Junio C HamanoJul 1, 2024
  5. Jeff KingJul 2, 2024
  6. Jeff KingJul 2, 2024
  7. Eric SunshineJul 2, 2024
  8. Jeff KingJul 6, 2024
  9. Jeff KingJul 2, 2024
  10. Eric SunshineJul 2, 2024
  11. Jeff KingJul 6, 2024
  12. Eric SunshineJul 2, 2024
  13. Eric SunshineJul 2, 2024
  14. Eric SunshineJul 2, 2024
  15. Jeff KingJul 6, 2024
  16. Jeff KingJul 6, 2024
  17. Eric SunshineJul 6, 2024
  18. Eric SunshineJul 6, 2024
  19. Jeff KingJul 6, 2024
  20. Eric SunshineJul 6, 2024
  21. Jeff KingJul 6, 2024
  22. 2/2 t: convert some here-doc test bodiesJeff King, Jul 1, 2024
  23. chainlint.pl: recognize test bodies defined via heredocEric Sunshine, Jul 2, 2024
  24. Jeff KingJul 6, 2024
  25. 1/3 chainlint.pl: fix line number reportingJeff King, Jul 6, 2024
  26. Eric SunshineJul 8, 2024
  27. Jeff KingJul 8, 2024
  28. 2/3 t/chainlint: add test_expect_success call to test snippetsJeff King, Jul 6, 2024
  29. Jeff KingJul 6, 2024
  30. Eric SunshineJul 8, 2024
  31. 3/3 t/chainlint: add tests for test body in heredocJeff King, Jul 6, 2024
  32. Eric SunshineJul 8, 2024
  33. Jeff KingJul 8, 2024
  34. Junio C HamanoJul 6, 2024
  35. Jeff KingJul 6, 2024
  36. Eric SunshineJul 8, 2024
  37. Jeff KingJul 8, 2024
  38. Eric SunshineJul 8, 2024
  39. Eric SunshineJul 8, 2024
  40. Jeff KingJul 10, 2024
  41. Jeff KingJul 10, 2024
  42. Eric SunshineJul 10, 2024
  43. Jeff KingJul 10, 2024
  44. Eric SunshineJul 10, 2024
  45. Eric SunshineJul 8, 2024
  46. Jeff KingJul 8, 2024
  47. Eric SunshineJul 8, 2024
  48. Jeff KingJul 10, 2024
  49. Eric SunshineJul 10, 2024
  50. 0/9 here-doc test bodies (now with 100% more chainlinting)Jeff King, Jul 10, 2024
  51. 1/9 chainlint.pl: add test_expect_success call to test snippetsJeff King, Jul 10, 2024
  52. 2/9 chainlint.pl: only start threads if jobs > 1Jeff King, Jul 10, 2024
  53. 3/9 chainlint.pl: do not spawn more threads than we have scriptsJeff King, Jul 10, 2024
  54. 4/9 chainlint.pl: force CRLF conversion when opening input filesJeff King, Jul 10, 2024
  55. 5/9 chainlint.pl: check line numbers in expected outputJeff King, Jul 10, 2024
  56. Eric SunshineAug 21, 2024
  57. Jeff KingAug 21, 2024
  58. Eric SunshineAug 21, 2024
  59. 6/9 chainlint.pl: recognize test bodies defined via heredocJeff King, Jul 10, 2024
  60. 7/9 chainlint.pl: add tests for test body in heredocJeff King, Jul 10, 2024
  61. 8/9 test-lib: allow test snippets as here-docsJeff King, Jul 10, 2024
  62. 9/9 t: convert some here-doc test bodiesJeff King, Jul 10, 2024
  63. 10/9 t/.gitattributes: ignore whitespace in chainlint expect filesJeff King, Jul 10, 2024
  64. Junio C HamanoJul 10, 2024
  65. Eric SunshineAug 21, 2024

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.