Commit 80423e89 authored by Enrico Bacis's avatar Enrico Bacis Committed by Commit Bot

[test] Use glob expansion in test selection

The run_test.py tool test selection only expands asterisks at the end of
the test name. This CL introduces glob expansion in test selection
(asterisks are expanded anywhere in the path).

This is useful when tests that belong to the same area have different
prefixes. For example wasm cctests have two different prefixes:
'cctest/test-run-wasm*' and 'cctest/test-wasm*'. With this CL it is
possible to specify the selector 'cctest/*wasm*' to run them all.

R=machenbach@chromium.org

Change-Id: I1c7cc5136b21e71f3eaf69fb98d5dfd77d336e2a
Reviewed-on: https://chromium-review.googlesource.com/609000Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Enrico Bacis <enricobacis@google.com>
Cr-Commit-Position: refs/heads/master@{#47274}
parent 94196e4e
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import fnmatch
import imp import imp
import os import os
...@@ -237,13 +238,12 @@ class TestSuite(object): ...@@ -237,13 +238,12 @@ class TestSuite(object):
def FilterTestCasesByArgs(self, args): def FilterTestCasesByArgs(self, args):
"""Filter test cases based on command-line arguments. """Filter test cases based on command-line arguments.
An argument with an asterisk in the end will match all test cases args can be a glob: asterisks in any position of the argument
that have the argument as a prefix. Without asterisk, only exact matches represent zero or more characters. Without asterisks, only exact matches
will be used with the exeption of the test-suite name as argument. will be used with the exeption of the test-suite name as argument.
""" """
filtered = [] filtered = []
globs = [] globs = []
exact_matches = []
for a in args: for a in args:
argpath = a.split('/') argpath = a.split('/')
if argpath[0] != self.name: if argpath[0] != self.name:
...@@ -251,18 +251,11 @@ class TestSuite(object): ...@@ -251,18 +251,11 @@ class TestSuite(object):
if len(argpath) == 1 or (len(argpath) == 2 and argpath[1] == '*'): if len(argpath) == 1 or (len(argpath) == 2 and argpath[1] == '*'):
return # Don't filter, run all tests in this suite. return # Don't filter, run all tests in this suite.
path = '/'.join(argpath[1:]) path = '/'.join(argpath[1:])
if path[-1] == '*': globs.append(path)
path = path[:-1]
globs.append(path)
else:
exact_matches.append(path)
for t in self.tests: for t in self.tests:
for a in globs: for g in globs:
if t.path.startswith(a): if fnmatch.fnmatch(t.path, g):
filtered.append(t)
break
for a in exact_matches:
if t.path == a:
filtered.append(t) filtered.append(t)
break break
self.tests = filtered self.tests = filtered
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment