Mercurial > hg > graal-jvmci-8
diff mx/mx_graal.py @ 15555:8c19ffc672fd
mx unittest: add support for regular expressions.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Thu, 08 May 2014 11:52:20 +0200 |
parents | d250613801fb |
children | cb2f3c49deb2 |
line wrap: on
line diff
--- a/mx/mx_graal.py Thu May 08 11:35:08 2014 +0200 +++ b/mx/mx_graal.py Thu May 08 11:52:20 2014 +0200 @@ -904,7 +904,7 @@ else: return [], args -def _run_tests(args, harness, annotations, testfile, whitelist): +def _run_tests(args, harness, annotations, testfile, whitelist, regex): vmArgs, tests = _extract_VM_args(args) @@ -939,6 +939,9 @@ if whitelist: classes = [c for c in classes if any((glob.match(c) for glob in whitelist))] + if regex: + classes = [c for c in classes if re.search(regex, c)] + if len(classes) != 0: f_testfile = open(testfile, 'w') for c in classes: @@ -946,7 +949,7 @@ f_testfile.close() harness(projectscp, vmArgs) -def _unittest(args, annotations, prefixcp="", whitelist=None, verbose=False, enable_timing=False): +def _unittest(args, annotations, prefixcp="", whitelist=None, verbose=False, enable_timing=False, regex=None): mxdir = dirname(__file__) name = 'JUnitWrapper' javaSource = join(mxdir, name + '.java') @@ -979,7 +982,7 @@ vm(prefixArgs + vmArgs + ['-cp', prefixcp + corecp + ':' + projectscp + os.pathsep + mxdir, name] + [testfile] + coreArgs) try: - _run_tests(args, harness, annotations, testfile, whitelist) + _run_tests(args, harness, annotations, testfile, whitelist, regex) finally: if os.environ.get('MX_TESTFILE') is None: os.remove(testfile) @@ -987,10 +990,11 @@ _unittestHelpSuffix = """ Unittest options: - --whitelist run only testcases which are included + --whitelist <file> run only testcases which are included in the given whitelist --verbose enable verbose JUnit output --enable-timing enable JUnit test timing + --regex <regex> run only testcases matching a regular expression To avoid conflicts with VM options '--' can be used as delimiter. @@ -1030,6 +1034,7 @@ parser.add_argument('--whitelist', help='run testcases specified in whitelist only', metavar='<path>') parser.add_argument('--verbose', help='enable verbose JUnit output', action='store_true') parser.add_argument('--enable-timing', help='enable JUnit test timing', action='store_true') + parser.add_argument('--regex', help='run only testcases matching a regular expression', metavar='<regex>') ut_args = [] delimiter = False @@ -1056,7 +1061,7 @@ except IOError: mx.log('warning: could not read whitelist: ' + parsed_args.whitelist) - _unittest(args, ['@Test', '@Parameters'], whitelist=whitelist, verbose=parsed_args.verbose, enable_timing=parsed_args.enable_timing) + _unittest(args, ['@Test', '@Parameters'], whitelist=whitelist, verbose=parsed_args.verbose, enable_timing=parsed_args.enable_timing, regex=parsed_args.regex) def shortunittest(args): """alias for 'unittest --whitelist test/whitelist_shortunittest.txt'{0}"""