[Buildroot] [PATCH 1/2] support/run-tests: move packages tests to packages directories
Ricardo Martincoski
ricardo.martincoski at gmail.com
Mon Oct 2 00:54:51 UTC 2017
Hello,
On Sun, Sep 17, 2017 at 04:52 AM, Yann E. MORIN wrote:
> On 2017-09-17 09:18 +0200, Yann E. MORIN spake thusly:
>> On 2017-09-17 02:20 -0300, Ricardo Martincoski spake thusly:
>> > On Sat, Sep 16, 2017 at 05:38 PM, Yann E. MORIN wrote:
> [--SNIP--]
>> > > + package = os.path.basename(dir)
>> > > + for file in files:
>> >
>> > You can import fnmatch to drastically reduce the number of regex compilations:
>> > for file in fnmatch.filter(files, '*.py'):
>> Wee! :-)
>
> In fact, no. At least, not in this state, because we do not want to
> match _any_ .py file; instead, we want to match only .py files that are
> named after the package.
We could use 2 filters. Instead of 8k+ regex compilations (one for each file
inside a package directory) we would run 2k+ fnmatch.filter (that probably
compile one regex, one per directory) and one regex compilation for each test
file in the package tree.
for file in fnmatch.filter(files, '*.py'):
if re.match("^{}.py$".format(package),file):
But well... the default python interpreter has a cache for regex (I don't know
its internals, just that it exists) and perhaps the change I suggested won't
make any difference in performance.
>
> But I guess I can make it to work with fnmatch nonetheless. ;-)
BTW, could you change the DEVELOPERS file in the same patch?
+F: package/*/*.py
F: support/testing/
I know it won't work for all possible files. 99% is enough for me.
Regards,
Ricardo
More information about the buildroot
mailing list