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

Re: [PATCH] t3070: make chain lint tester happy

From
Jeff King <peff@peff.net>
Date
Mar 25, 2023, 06:37 UTC
Message-ID
<20230325063731.GB562387@coredump.intra.peff.net>
In-Reply-To
<3714ba2f6528c38eb9c438126316a08b0cefca7c.1679696180.git.git@grubix.eu>
On Fri, Mar 24, 2023 at 11:17:11PM +0100, Michael J Gruber wrote:
Show 7 quoted lines
> 1f2e05f0b7 ("wildmatch: fix exponential behavior", 2023-03-20)
> introduced a new test with a background process. Backgrounding
> necessarily gives a result of 0, so that a seemingly broken && chain is
> not really broken.
> 
> Adjust t3070 slightly so that our chain list test recognizes the
> construct for what it is and does not raise a false positive.

Good catch. While I agree that there's no missed exit code here, I'd say that this is more than just a false positive. If there were any lines above the "&", like:

  foo &&
  bar &
  pid=$! &&
  ...etc...

then we'd be losing the exit value of "foo". It's OK here because the backgrounded command is the first line of the test, but it definitely violates our guidelines.

Which isn't to say that your patch needs to do anything differently. I just wondered if it meant we should be improving the chain linter, but I think it is doing the right thing to alert us here.

Show 20 quoted lines
> diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh
> index b91a7cb712..4dd42df38c 100755
> --- a/t/t3070-wildmatch.sh
> +++ b/t/t3070-wildmatch.sh
> @@ -432,10 +432,12 @@ match 0 1 0 1 'z' '[Z-y]'
>  match 1 1 1 1 'Z' '[Z-y]'
>  
>  test_expect_success 'matching does not exhibit exponential behavior' '
> -	test-tool wildmatch wildmatch \
> -		aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab \
> -		"*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a" &
> -	pid=$! &&
> +	{
> +		test-tool wildmatch wildmatch \
> +			aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab \
> +			"*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a" &
> +		pid=$!
> +	} &&
>  	sleep 2 &&
>  	! kill $!

This looks like the right solution. I do wonder how Phillip managed to miss it, though, since the test script complains loudly.

-Peff
Previous: Michael J GruberNext: Eric Sunshine
Message 5 of 22 in “wildmatch: fix exponential behavior”
  1. 0/3 wildmatch: fix exponential behaviorPhillip Wood, Mar 20, 2023
  2. 2/3 wildmatch: avoid undefined behaviorPhillip Wood, Mar 20, 2023
  3. 1/3 wildmatch: fix exponential behaviorPhillip Wood, Mar 20, 2023
  4. t3070: make chain lint tester happyMichael J Gruber, Mar 24, 2023
  5. Jeff KingMar 25, 2023
  6. Eric SunshineMar 25, 2023
  7. Jeff KingMar 25, 2023
  8. Jeff KingMar 25, 2023
  9. Eric SunshineMar 25, 2023
  10. Jeff KingMar 25, 2023
  11. Jeff KingMar 25, 2023
  12. Eric SunshineMar 25, 2023
  13. Jeff KingMar 25, 2023
  14. Eric SunshineMar 25, 2023
  15. Phillip WoodMar 26, 2023
  16. Michael J GruberMar 26, 2023
  17. Eric SunshineMar 25, 2023
  18. Jeff KingMar 25, 2023
  19. 3/3 wildmatch: hide internal return valuesPhillip Wood, Mar 20, 2023
  20. Junio C HamanoMar 20, 2023
  21. Derrick StoleeMar 23, 2023
  22. Phillip WoodMar 24, 2023

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.