[PATCH 2 of 2] tests: add new test for #! shbang lines

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Apr 13 02:58:11 EDT 2016


On 04/08/2016 07:34 AM, Yuya Nishihara wrote:
> On Wed, 06 Apr 2016 20:26:37 -0500, timeless wrote:
>> # HG changeset patch
>> # User timeless <timeless at mozdev.org>
>> # Date 1459969752 0
>> #      Wed Apr 06 19:09:12 2016 +0000
>> # Node ID 16e6523533e263430f06ffd785c921a114268199
>> # Parent  0a413e125a885f3b5349aa8aaa8d7285fbcbdd3e
>> tests: add new test for #! shbang lines
>                               ^^^^^^
>                               perhaps sh"e"bang is more common

I agree with yuyua here, I've changed this to shebang.

>> * use #!/bin/sh not e.g. #!/usr/bin/sh
>> * use #!/usr/bin/env python not e.g. #!/usr/bin/python
>>
>> diff --git a/tests/test-check-execute.t b/tests/test-check-shbang.t
>> copy from tests/test-check-execute.t
>> copy to tests/test-check-shbang.t
>> --- a/tests/test-check-execute.t
>> +++ b/tests/test-check-shbang.t
>> @@ -1,23 +1,13 @@
>> -#require test-repo execbit
>> +#require test-repo
>>   
>>     $ cd "`dirname "$TESTDIR"`"
>>   
>> -look for python scripts without the execute bit
>> +look for python scripts that do not use /usr/bin/env
>>   
>> -  $ hg files 'set:**.py and not exec() and grep(r"^#!.*?python")'
>> +  $ hg files 'set:grep(r"^#!.*?python") and not grep(r"^#!/usr/bin/env python")'
>>     [1]
>>   
>> -look for python scripts with execute bit but not shebang
>> +look for shell scripts that do not use /bin/sh
>>   
>> -  $ hg files 'set:**.py and exec() and not grep(r"^#!.*?python")'
>> +  $ hg files 'set:grep(r"^#!.*/bin/sh") and not grep(r"^#!/bin/sh")'
>>     [1]
> My two cents, should we integrate this into check-code.py?

Maybe, but the python shebang are not tested in checkcode either so I 
think it is fine to take this one as is.

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list