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

Re: [PATCH 2/5] t0061: Add tests

From
Frans Klaver <fransklaver@gmail.com>
Date
Jan 25, 2012, 06:47 UTC
Message-ID
<op.v8mntno90aolir@keputer>
In-Reply-To
<20120124225636.GF8222@burratino>

On Tue, 24 Jan 2012 23:56:36 +0100, Jonathan Nieder <jrnieder@gmail.com> wrote:

Show 9 quoted lines
>> +>empty
>> +
>> +cat >incorrect-interpreter-script <<-EOF
>> +#!someinterpreter
>> +cat hello-script
>> +EOF
>> +>empty
>
> What is the point of repreatedly writing an empty file named "empty"?

There isn't. I copied it along with the hello-script lines and didn't pay it much heed. I'll remove the excessive '>empty's.

Show 5 quoted lines
> I think this would be easier to read and maintain if scripts not
> shared between multiple tests were written in the body of the relevant
> tests.  For example, that way it is easier to remember to remove a
> helper script if the relevant test assertion changes to no longer need
> it.
Makes sense. I'll reorder.
Show 27 quoted lines
>
> [...]
>> @@ -26,7 +44,7 @@ test_expect_success 'run_command can run a command' '
>>  	test_cmp empty err
>>  '
>>
>>  test_expect_success POSIXPERM 'run_command reports EACCES' '
>>  	cat hello-script >hello.sh &&
>>  	chmod -x hello.sh &&
>>  	test_must_fail test-run-command run-command ./hello.sh 2>err &&
> [...]
>> +test_expect_success POSIXPERM 'run_command reports EACCES, search path  
>> perms' '
>> +	mkdir -p inaccessible &&
>> +	PATH=$(pwd)/inaccessible:$PATH &&
>> +	export PATH &&
>> +
>> +	cat hello-script >inaccessible/hello.sh &&
>> +	chmod 400 inaccessible &&
>> +	test_must_fail test-run-command run-command hello.sh 2>err &&
>> +	chmod 755 inaccessible &&
>> +
>> +	grep "fatal: cannot exec.*hello.sh" err
>> +'
>
> (*) These tests would be easier to understand if squashed with the
> relevant later patch in the series that changes the error message.
You mean "Elaborate execvp error checking"?
Show 29 quoted lines
> Maybe they could be less repetitive that way, too.
>
> 	test_expect_success POSIXPERM 'diagnose command in inaccessible part of  
> $PATH' '
> 		mkdir -p subdir &&
> 		cat hello-script >subdir/hello.sh &&
> 		chmod +x subdir/hello.sh &&
> 		chmod -x subdir &&
> 		(
> 			PATH=$(pwd)/inaccessible:$PATH &&
> 			test_must_fail test-run-command run-command hello.sh 2>err
> 		) &&
> 		test_i18ngrep ...
> 	'
>
> [...]
>> +test_expect_success POSIXPERM 'run_command reports EACCES, interpreter  
>> fails' '
>> +	cat incorrect-interpreter-script >hello.sh &&
>> +	chmod +x hello.sh &&
>> +	chmod -x someinterpreter &&
>> +	test_must_fail test-run-command run-command ./hello.sh 2>err &&
>> +
>> +	grep "fatal: cannot exec.*hello.sh" err
>> +'
>
> Is this the common case?  Why would my interpreter be in the designated
> spot but not marked executable?  Is there some other motivating
> example?  (I'm genuinely curious; it's ok if the answer is "no".)

I wouldn't think so. This particular one is addressing a concern raised by Johannes Sixt in reaction to a patch from Junio.

http://article.gmane.org/gmane.comp.version-control.git/171848
Show 21 quoted lines
>
> [...]
>> +
>> +test_expect_failure POSIXPERM 'run_command reports ENOENT,  
>> interpreter' '
>> +	cat non-existing-interpreter >hello.sh &&
>> +	chmod +x hello.sh &&
>> +	test_must_fail test-run-command start-command-ENOENT ./hello.sh 2>err  
>> &&
>> +
>> +	grep "error: cannot exec.*hello.sh" err
>> +'
>
> Maybe:
>
> 	test_expect_success POSIXPERM 'diagnose missing interpreter' '
> 		echo "#!/nonexistent/interpreter" >hello.sh &&
> 		chmod +x hello.sh &&
> 		test_must_fail test-run-command run-command hello.sh 2>err &&
> 		test_i18ngrep ...
> 	'
Will check.
> Hope that helps,
> Jonathan
Previous: Jonathan NiederNext: Frans Klaver
Message 11 of 31 in “Add execvp failure diagnostics”
  1. 0/6 Add execvp failure diagnosticsFrans Klaver, Jan 24, 2012
  2. 1/5 t0061: Fix incorrect indentationFrans Klaver, Jan 24, 2012
  3. Junio C HamanoJan 24, 2012
  4. Jonathan NiederJan 24, 2012
  5. Frans KlaverJan 25, 2012
  6. Junio C HamanoJan 25, 2012
  7. Frans KlaverJan 25, 2012
  8. Frans KlaverJan 25, 2012
  9. 2/5 t0061: Add testsFrans Klaver, Jan 24, 2012
  10. Jonathan NiederJan 24, 2012
  11. Frans KlaverJan 25, 2012
  12. 3/5 run-command: Elaborate execvp error checkingFrans Klaver, Jan 24, 2012
  13. Jonathan NiederJan 24, 2012
  14. Frans KlaverJan 25, 2012
  15. Jonathan NiederJan 25, 2012
  16. Frans KlaverJan 25, 2012
  17. Johannes SixtJan 25, 2012
  18. Frans KlaverJan 25, 2012
  19. 4/5 run-command: Warn if PATH entry cannot be searchedFrans Klaver, Jan 24, 2012
  20. 5/5 run-command: Error out if interpreter not foundFrans Klaver, Jan 24, 2012
  21. Jonathan NiederJan 24, 2012
  22. Frans KlaverJan 25, 2012
  23. Johannes SixtJan 25, 2012
  24. Frans KlaverJan 25, 2012
  25. Junio C HamanoJan 26, 2012
  26. Frans KlaverJan 27, 2012
  27. Jonathan NiederJan 27, 2012
  28. Frans KlaverJan 27, 2012
  29. Jonathan NiederJan 27, 2012
  30. Frans KlaverJan 27, 2012
  31. Frans KlaverFeb 4, 2012

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.