Mercurial > hg > graal-jvmci-8
comparison mx/mx_graal.py @ 15655:ec29b2d3bdb4
mx unittest: add color support.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Wed, 14 May 2014 20:58:35 +0200 |
parents | 83c69954bbaa |
children | fcf6e5683082 |
comparison
equal
deleted
inserted
replaced
15654:4735aabe8444 | 15655:ec29b2d3bdb4 |
---|---|
955 for c in classes: | 955 for c in classes: |
956 f_testfile.write(c + '\n') | 956 f_testfile.write(c + '\n') |
957 f_testfile.close() | 957 f_testfile.close() |
958 harness(projectscp, vmArgs) | 958 harness(projectscp, vmArgs) |
959 | 959 |
960 def _unittest(args, annotations, prefixcp="", whitelist=None, verbose=False, enable_timing=False, regex=None): | 960 def _unittest(args, annotations, prefixcp="", whitelist=None, verbose=False, enable_timing=False, regex=None, color=False): |
961 mxdir = dirname(__file__) | 961 mxdir = dirname(__file__) |
962 name = 'JUnitWrapper' | 962 name = 'JUnitWrapper' |
963 javaSource = join(mxdir, name + '.java') | 963 javaSource = join(mxdir, name + '.java') |
964 javaClass = join(mxdir, name + '.class') | 964 javaClass = join(mxdir, name + '.class') |
965 testfile = os.environ.get('MX_TESTFILE', None) | 965 testfile = os.environ.get('MX_TESTFILE', None) |
974 coreArgs = [] | 974 coreArgs = [] |
975 if verbose: | 975 if verbose: |
976 coreArgs.append('-JUnitVerbose') | 976 coreArgs.append('-JUnitVerbose') |
977 if enable_timing: | 977 if enable_timing: |
978 coreArgs.append('-JUnitEnableTiming') | 978 coreArgs.append('-JUnitEnableTiming') |
979 if color: | |
980 coreArgs.append('-JUnitColor') | |
979 | 981 |
980 | 982 |
981 def harness(projectscp, vmArgs): | 983 def harness(projectscp, vmArgs): |
982 if _get_vm() != 'graal': | 984 if _get_vm() != 'graal': |
983 prefixArgs = ['-esa', '-ea'] | 985 prefixArgs = ['-esa', '-ea'] |
1004 --whitelist <file> run only testcases which are included | 1006 --whitelist <file> run only testcases which are included |
1005 in the given whitelist | 1007 in the given whitelist |
1006 --verbose enable verbose JUnit output | 1008 --verbose enable verbose JUnit output |
1007 --enable-timing enable JUnit test timing | 1009 --enable-timing enable JUnit test timing |
1008 --regex <regex> run only testcases matching a regular expression | 1010 --regex <regex> run only testcases matching a regular expression |
1011 --color enable colors output | |
1009 | 1012 |
1010 To avoid conflicts with VM options '--' can be used as delimiter. | 1013 To avoid conflicts with VM options '--' can be used as delimiter. |
1011 | 1014 |
1012 If filters are supplied, only tests whose fully qualified name | 1015 If filters are supplied, only tests whose fully qualified name |
1013 includes a filter as a substring are run. | 1016 includes a filter as a substring are run. |
1044 ) | 1047 ) |
1045 parser.add_argument('--whitelist', help='run testcases specified in whitelist only', metavar='<path>') | 1048 parser.add_argument('--whitelist', help='run testcases specified in whitelist only', metavar='<path>') |
1046 parser.add_argument('--verbose', help='enable verbose JUnit output', action='store_true') | 1049 parser.add_argument('--verbose', help='enable verbose JUnit output', action='store_true') |
1047 parser.add_argument('--enable-timing', help='enable JUnit test timing', action='store_true') | 1050 parser.add_argument('--enable-timing', help='enable JUnit test timing', action='store_true') |
1048 parser.add_argument('--regex', help='run only testcases matching a regular expression', metavar='<regex>') | 1051 parser.add_argument('--regex', help='run only testcases matching a regular expression', metavar='<regex>') |
1052 parser.add_argument('--color', help='enable color output', action='store_true') | |
1049 | 1053 |
1050 ut_args = [] | 1054 ut_args = [] |
1051 delimiter = False | 1055 delimiter = False |
1052 # check for delimiter | 1056 # check for delimiter |
1053 while len(args) > 0: | 1057 while len(args) > 0: |
1070 with open(join(_graal_home, parsed_args.whitelist)) as fp: | 1074 with open(join(_graal_home, parsed_args.whitelist)) as fp: |
1071 whitelist = [re.compile(fnmatch.translate(l.rstrip())) for l in fp.readlines() if not l.startswith('#')] | 1075 whitelist = [re.compile(fnmatch.translate(l.rstrip())) for l in fp.readlines() if not l.startswith('#')] |
1072 except IOError: | 1076 except IOError: |
1073 mx.log('warning: could not read whitelist: ' + parsed_args.whitelist) | 1077 mx.log('warning: could not read whitelist: ' + parsed_args.whitelist) |
1074 | 1078 |
1075 _unittest(args, ['@Test', '@Parameters'], whitelist=whitelist, verbose=parsed_args.verbose, enable_timing=parsed_args.enable_timing, regex=parsed_args.regex) | 1079 _unittest(args, ['@Test', '@Parameters'], whitelist=whitelist, verbose=parsed_args.verbose, enable_timing=parsed_args.enable_timing, regex=parsed_args.regex, color=parsed_args.color) |
1076 | 1080 |
1077 def shortunittest(args): | 1081 def shortunittest(args): |
1078 """alias for 'unittest --whitelist test/whitelist_shortunittest.txt'{0}""" | 1082 """alias for 'unittest --whitelist test/whitelist_shortunittest.txt'{0}""" |
1079 | 1083 |
1080 args = ['--whitelist', 'test/whitelist_shortunittest.txt'] + args | 1084 args = ['--whitelist', 'test/whitelist_shortunittest.txt'] + args |