[PATCH 7 of 7 v2] tests: add test-check-execute.t

Yuya Nishihara yuya at tcha.org
Tue Dec 29 20:31:17 CST 2015


On Mon, 28 Dec 2015 13:26:41 -0500, timeless wrote:
> Yuya Nishihara wrote:
> >> +#require test-repo
> >
> > It needs execbit to be skipped on Windows.
> 
> I don't think so.
> 
> I tested w/ a FAT filesystem on OS X, and the set:exec() fileset
> properly returned only files w/ +x from the repo, even though they all
> appear to have +x according to ls.

That only applies to committed files. If you add a new file on FAT, it can't
be marked as an executable.

That said, do you think Windows people should be blamed if they add an
executable with no executable bit? If so, no "#require execbit" would make
sense.

> >> +look for python scripts without the execute bit
> >> +
> >> +  $ hg files 'set:(**.py) and not exec()' 2> /dev/null | \
> >> +  > xargs -n1 egrep -n -H '(env |/)python'|grep ':1:' | \
> >> +  > cat
> >
> > You can use grep() fileset.
> 
> I can't. grep() doesn't give me line numbers.
> I'm not asking "does this file have `env python`/`python`, I'm asking
> "does the first line of this file have that" -- I'm doing that using
> `-n` and :1: (the -H is to handle the case where there's only one
> file).

grep() uses re.search(), in which MULTILINE is off by default. "^" only
matches the first line. You can also use "\A".

https://docs.python.org/2.7/library/re.html

FWIW, '(env |/)python' doesn't work on Windows because of "/".


More information about the Mercurial-devel mailing list