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

Re: [PATCH v1 1/2] t0027: Correct raciness in NNO test

From
Johannes Sixt <j6t@kdbg.org>
Date
Aug 13, 2016, 16:50 UTC
Message-ID
<57AF4FCB.7090409@kdbg.org>
In-Reply-To
<1471020662-20746-1-git-send-email-tboegi@web.de>
Am 12.08.2016 um 18:51 schrieb tboegi@web.de:
Show 15 quoted lines
> From: Torsten Bögershausen <tboegi@web.de>
>
> When a non-reversible CRLF conversion is done in "git add",
> a warning is printed on stderr (or Git dies, depending on checksafe)
>
> The function commit_chk_wrnNNO() in t0027 was written to test this,
> but did the wrong thing: Instead of looking at the warning
> from "git add", it looked at the warning from "git commit".
>
> This is racy because "git commit" may not have to do CRLF conversion
> at all if it can use the sha1 value from the index (which depends on
> whether "add" and "commit" run in a single second).
>
> Correct this and replace the commit for each and every file with a commit
> of all files in one go.

The new test code does not only fix the race condition, but also tests different things, or prepares test cases in a different manner. I would have appreciated an explanation why this is necessary. Is it "on my machine, the race condition was triggered consistently for a bunch of tests, and so I recorded the wrong expected output in the test cases"?

Show 58 quoted lines
>
> The function commit_chk_wrnNNO() will to be renamed in a separate commit.
> Thanks to Jeff King <peff@peff.net> for analyzing t0027.
>
> Reported-By: Johannes Schindelin <Johannes.Schindelin@gmx.de>
> ---
>   t/t0027-auto-crlf.sh | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh
> index 2860d2d..ab6e962 100755
> --- a/t/t0027-auto-crlf.sh
> +++ b/t/t0027-auto-crlf.sh
> @@ -119,8 +119,7 @@ commit_chk_wrnNNO () {
>   		fname=${pfx}_$f.txt &&
>   		cp $f $fname &&
>   		printf Z >>"$fname" &&
> -		git -c core.autocrlf=$crlf add $fname 2>/dev/null &&
> -		git -c core.autocrlf=$crlf commit -m "commit_$fname" $fname >"${pfx}_$f.err" 2>&1
> +		git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err"
>   	done
>
>   	test_expect_success "commit NNO files crlf=$crlf attr=$attr LF" '
> @@ -394,11 +393,11 @@ test_expect_success 'commit files attr=crlf' '
>
>   #                 attr                    LF        CRLF      CRLFmixLF   LF_mix_CR   CRLFNUL
>   commit_chk_wrnNNO ""      ""      false   ""        ""        ""          ""          ""
> -commit_chk_wrnNNO ""      ""      true    LF_CRLF   ""        ""          ""          ""
> +commit_chk_wrnNNO ""      ""      true    ""        ""        ""          ""          ""
>   commit_chk_wrnNNO ""      ""      input   ""        ""        ""          ""          ""
>
> -commit_chk_wrnNNO "auto"  ""      false   "$WILC"   ""        ""          ""          ""
> -commit_chk_wrnNNO "auto"  ""      true    LF_CRLF   ""        ""          ""          ""
> +commit_chk_wrnNNO "auto"  ""      false   ""        ""        ""          ""          ""
> +commit_chk_wrnNNO "auto"  ""      true    ""        ""        ""          ""          ""
>   commit_chk_wrnNNO "auto"  ""      input   ""        ""        ""          ""          ""
>   for crlf in true false input
>   do
> @@ -408,7 +407,7 @@ do
>   	commit_chk_wrnNNO ""    lf      $crlf   ""       CRLF_LF    CRLF_LF      ""         CRLF_LF
>   	commit_chk_wrnNNO ""    crlf    $crlf   LF_CRLF   ""        LF_CRLF     LF_CRLF     ""
>   	commit_chk_wrnNNO auto  lf    	$crlf   ""        ""        ""          ""          ""
> -	commit_chk_wrnNNO auto  crlf  	$crlf   LF_CRLF   ""        ""          ""          ""
> +	commit_chk_wrnNNO auto  crlf  	$crlf   ""        ""        ""          ""          ""
>   	commit_chk_wrnNNO text  lf    	$crlf   ""       CRLF_LF    CRLF_LF     ""          CRLF_LF
>   	commit_chk_wrnNNO text  crlf  	$crlf   LF_CRLF   ""        LF_CRLF     LF_CRLF     ""
>   done
> @@ -417,7 +416,8 @@ commit_chk_wrnNNO "text"  ""      false   "$WILC"   "$WICL"   "$WAMIX"    "$WILC
>   commit_chk_wrnNNO "text"  ""      true    LF_CRLF   ""        LF_CRLF     LF_CRLF     ""
>   commit_chk_wrnNNO "text"  ""      input   ""        CRLF_LF   CRLF_LF     ""          CRLF_LF
>
> -test_expect_success 'create files cleanup' '
> +test_expect_success 'commit NNO and cleanup' '
> +	git commit -m "commit files on top of NNO" &&
>   	rm -f *.txt &&
>   	git -c core.autocrlf=false reset --hard
>   '
>
Previous: Junio C HamanoNext: Torsten Bögershausen
Message 21 of 45 in “t0027 racy?”
  1. Johannes SchindelinAug 8, 2016
  2. Jeff KingAug 8, 2016
  3. Torsten BögershausenAug 8, 2016
  4. Jeff KingAug 9, 2016
  5. Jeff KingAug 9, 2016
  6. Johannes SchindelinAug 9, 2016
  7. Torsten BögershausenAug 9, 2016
  8. Jeff KingAug 9, 2016
  9. Torsten BögershausenAug 9, 2016
  10. Jeff KingAug 9, 2016
  11. Torsten BögershausenAug 9, 2016
  12. Johannes SchindelinAug 10, 2016
  13. Torsten BögershausenAug 11, 2016
  14. Junio C HamanoAug 11, 2016
  15. Jeff KingAug 12, 2016
  16. 0/2 Fix conversion warningstboegi@web.de, Aug 12, 2016
  17. 2/2 convert: missing `LF will be replaced by CRLFtboegi@web.de, Aug 12, 2016
  18. Junio C HamanoAug 12, 2016
  19. 1/2 t0027: Correct raciness in NNO testtboegi@web.de, Aug 12, 2016
  20. Junio C HamanoAug 12, 2016
  21. Johannes SixtAug 13, 2016
  22. Torsten BögershausenAug 13, 2016
  23. Junio C HamanoAug 14, 2016
  24. 1/1 convert: Correct NNO tests and missing `LF will be replaced by CRLF`tboegi@web.de, Aug 13, 2016
  25. 0/1 convert: Correct NNO tests and missing `LF will be replaced by CRLF`tboegi@web.de, Aug 13, 2016
  26. Johannes SchindelinAug 17, 2016
  27. 0/1 Rename NotNormalized (NNO) into CRLF in indextboegi@web.de, Aug 19, 2016
  28. Junio C HamanoAug 19, 2016
  29. 1/1 t0027: Rename NotNormalized (NNO) into CRLF in indextboegi@web.de, Aug 19, 2016
  30. 1/2 git ls-files: text=auto eol=lf is supported in Git 2.10tboegi@web.de, Aug 25, 2016
  31. Junio C HamanoAug 25, 2016
  32. 0/3 Update eol documentationtboegi@web.de, Aug 25, 2016
  33. Junio C HamanoAug 25, 2016
  34. Jacob KellerAug 26, 2016
  35. Torsten BögershausenAug 26, 2016
  36. 2/2 gitattributes: Document the unified "auto" handlingtboegi@web.de, Aug 25, 2016
  37. Junio C HamanoAug 25, 2016
  38. 0/2 Adjust the documentation to the unified "auto" handlingtboegi@web.de, Aug 26, 2016
  39. 1/2 git ls-files: text=auto eol=lf is supported in Git 2.10tboegi@web.de, Aug 26, 2016
  40. 2/2 gitattributes: Document the unified "auto" handlingtboegi@web.de, Aug 26, 2016
  41. Junio C HamanoAug 26, 2016
  42. Johannes SchindelinAug 9, 2016
  43. Jeff KingAug 9, 2016
  44. Torsten BögershausenAug 8, 2016
  45. Johannes SchindelinAug 9, 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.