mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[lit] Change regex filter to ignore case
Make regex filter `--filter=REGEX` option more lenient via `re.IGNORECASE`. Reviewed By: yln Differential Revision: https://reviews.llvm.org/D68834 llvm-svn: 374601
This commit is contained in:
parent
49d1bdc990
commit
7efdea3492
@ -152,6 +152,7 @@ def parse_args():
|
||||
default=False)
|
||||
selection_group.add_argument("--filter",
|
||||
metavar="REGEX",
|
||||
type=_case_insensitive_regex,
|
||||
help="Only run tests with paths matching the given regular expression",
|
||||
default=os.environ.get("LIT_FILTER"))
|
||||
selection_group.add_argument("--num-shards",
|
||||
@ -201,14 +202,22 @@ def parse_args():
|
||||
return opts
|
||||
|
||||
def _positive_int(arg):
|
||||
desc = "requires positive integer, but found '{}'"
|
||||
try:
|
||||
n = int(arg)
|
||||
except ValueError:
|
||||
raise _arg_error('positive integer', arg)
|
||||
raise _error(desc, arg)
|
||||
if n <= 0:
|
||||
raise _arg_error('positive integer', arg)
|
||||
raise _error(desc, arg)
|
||||
return n
|
||||
|
||||
def _arg_error(desc, arg):
|
||||
msg = "requires %s, but found '%s'" % (desc, arg)
|
||||
def _case_insensitive_regex(arg):
|
||||
import re
|
||||
try:
|
||||
return re.compile(arg, re.IGNORECASE)
|
||||
except re.error as reason:
|
||||
raise _error("invalid regular expression: '{}', {}", arg, reason)
|
||||
|
||||
def _error(desc, *args):
|
||||
msg = desc.format(*args)
|
||||
return argparse.ArgumentTypeError(msg)
|
||||
|
@ -10,7 +10,6 @@ from __future__ import absolute_import
|
||||
import os
|
||||
import platform
|
||||
import random
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import tempfile
|
||||
@ -115,7 +114,7 @@ def main_with_tmp(builtinParameters):
|
||||
numTotalTests = len(run.tests)
|
||||
|
||||
if opts.filter:
|
||||
filter_tests(run, opts)
|
||||
run.tests = [t for t in run.tests if opts.filter.search(t.getFullName())]
|
||||
|
||||
order_tests(run, opts)
|
||||
|
||||
@ -277,15 +276,6 @@ def print_suites_or_tests(run, opts):
|
||||
# Exit.
|
||||
sys.exit(0)
|
||||
|
||||
def filter_tests(run, opts):
|
||||
try:
|
||||
rex = re.compile(opts.filter)
|
||||
except:
|
||||
parser.error("invalid regular expression for --filter: %r" % (
|
||||
opts.filter))
|
||||
run.tests = [result_test for result_test in run.tests
|
||||
if rex.search(result_test.getFullName())]
|
||||
|
||||
def order_tests(run, opts):
|
||||
if opts.shuffle:
|
||||
random.shuffle(run.tests)
|
||||
|
@ -1,17 +1,13 @@
|
||||
# RUN: %{lit} %{inputs}/discovery | FileCheck --check-prefix=CHECK-BASIC %s
|
||||
# CHECK-BASIC: Testing: 5 tests
|
||||
|
||||
# Check that regex-filtering works
|
||||
# Check that regex-filtering works, is case-insensitive, and can be configured via env var.
|
||||
#
|
||||
# RUN: %{lit} --filter 'o[a-z]e' %{inputs}/discovery | FileCheck --check-prefix=CHECK-FILTER %s
|
||||
# RUN: %{lit} --filter 'O[A-Z]E' %{inputs}/discovery | FileCheck --check-prefix=CHECK-FILTER %s
|
||||
# RUN: env LIT_FILTER='o[a-z]e' %{lit} %{inputs}/discovery | FileCheck --check-prefix=CHECK-FILTER %s
|
||||
# CHECK-FILTER: Testing: 2 of 5 tests
|
||||
|
||||
# Check that regex-filtering based on environment variables work.
|
||||
#
|
||||
# RUN: env LIT_FILTER='o[a-z]e' %{lit} %{inputs}/discovery | FileCheck --check-prefix=CHECK-FILTER-ENV %s
|
||||
# CHECK-FILTER-ENV: Testing: 2 of 5 tests
|
||||
|
||||
|
||||
# Check that maximum counts work
|
||||
#
|
||||
# RUN: %{lit} --max-tests 3 %{inputs}/discovery | FileCheck --check-prefix=CHECK-MAX %s
|
||||
|
Loading…
Reference in New Issue
Block a user