Mercurial > hg > graal-jvmci-8
comparison mx/mx_graal.py @ 15503:c62e120e8cd9
Add TimingDecorator.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Mon, 05 May 2014 11:34:11 +0200 |
parents | a26be2c9b81b |
children | d250613801fb |
comparison
equal
deleted
inserted
replaced
15502:a26be2c9b81b | 15503:c62e120e8cd9 |
---|---|
944 for c in classes: | 944 for c in classes: |
945 f_testfile.write(c + '\n') | 945 f_testfile.write(c + '\n') |
946 f_testfile.close() | 946 f_testfile.close() |
947 harness(projectscp, vmArgs) | 947 harness(projectscp, vmArgs) |
948 | 948 |
949 def _unittest(args, annotations, prefixcp="", whitelist=None, verbose=False): | 949 def _unittest(args, annotations, prefixcp="", whitelist=None, verbose=False, enable_timing=False): |
950 mxdir = dirname(__file__) | 950 mxdir = dirname(__file__) |
951 name = 'JUnitWrapper' | 951 name = 'JUnitWrapper' |
952 javaSource = join(mxdir, name + '.java') | 952 javaSource = join(mxdir, name + '.java') |
953 javaClass = join(mxdir, name + '.class') | 953 javaClass = join(mxdir, name + '.class') |
954 testfile = os.environ.get('MX_TESTFILE', None) | 954 testfile = os.environ.get('MX_TESTFILE', None) |
955 if testfile is None: | 955 if testfile is None: |
956 (_, testfile) = tempfile.mkstemp(".testclasses", "graal") | 956 (_, testfile) = tempfile.mkstemp(".testclasses", "graal") |
957 os.close(_) | 957 os.close(_) |
958 corecp = mx.classpath(['com.oracle.graal.test']) | 958 corecp = mx.classpath(['com.oracle.graal.test']) |
959 coreArgs = ['-JUnitVerbose'] if verbose else [] | 959 coreArgs = [] |
960 if verbose: | |
961 coreArgs.append('-JUnitVerbose') | |
962 if enable_timing: | |
963 coreArgs.append('-JUnitEnableTiming') | |
960 | 964 |
961 def harness(projectscp, vmArgs): | 965 def harness(projectscp, vmArgs): |
962 if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource): | 966 if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource): |
963 subprocess.check_call([mx.java().javac, '-cp', projectscp, '-d', mxdir, javaSource]) | 967 subprocess.check_call([mx.java().javac, '-cp', projectscp, '-d', mxdir, javaSource]) |
964 if _get_vm() != 'graal': | 968 if _get_vm() != 'graal': |
984 Unittest options: | 988 Unittest options: |
985 | 989 |
986 --whitelist run only testcases which are included | 990 --whitelist run only testcases which are included |
987 in the given whitelist | 991 in the given whitelist |
988 --verbose enable verbose JUnit output | 992 --verbose enable verbose JUnit output |
993 --enable-timing enable JUnit test timing | |
989 | 994 |
990 To avoid conflicts with VM options '--' can be used as delimiter. | 995 To avoid conflicts with VM options '--' can be used as delimiter. |
991 | 996 |
992 If filters are supplied, only tests whose fully qualified name | 997 If filters are supplied, only tests whose fully qualified name |
993 includes a filter as a substring are run. | 998 includes a filter as a substring are run. |
1022 formatter_class=RawDescriptionHelpFormatter, | 1027 formatter_class=RawDescriptionHelpFormatter, |
1023 epilog=_unittestHelpSuffix, | 1028 epilog=_unittestHelpSuffix, |
1024 ) | 1029 ) |
1025 parser.add_argument('--whitelist', help='run testcases specified in whitelist only', metavar='<path>') | 1030 parser.add_argument('--whitelist', help='run testcases specified in whitelist only', metavar='<path>') |
1026 parser.add_argument('--verbose', help='enable verbose JUnit output', action='store_true') | 1031 parser.add_argument('--verbose', help='enable verbose JUnit output', action='store_true') |
1032 parser.add_argument('--enable-timing', help='enable JUnit test timing', action='store_true') | |
1027 | 1033 |
1028 ut_args = [] | 1034 ut_args = [] |
1029 delimiter = False | 1035 delimiter = False |
1030 # check for delimiter | 1036 # check for delimiter |
1031 while len(args) > 0: | 1037 while len(args) > 0: |
1048 with open(join(_graal_home, parsed_args.whitelist)) as fp: | 1054 with open(join(_graal_home, parsed_args.whitelist)) as fp: |
1049 whitelist = [re.compile(fnmatch.translate(l.rstrip())) for l in fp.readlines() if not l.startswith('#')] | 1055 whitelist = [re.compile(fnmatch.translate(l.rstrip())) for l in fp.readlines() if not l.startswith('#')] |
1050 except IOError: | 1056 except IOError: |
1051 mx.log('warning: could not read whitelist: ' + parsed_args.whitelist) | 1057 mx.log('warning: could not read whitelist: ' + parsed_args.whitelist) |
1052 | 1058 |
1053 _unittest(args, ['@Test', '@Parameters'], whitelist=whitelist, verbose=parsed_args.verbose) | 1059 _unittest(args, ['@Test', '@Parameters'], whitelist=whitelist, verbose=parsed_args.verbose, enable_timing=parsed_args.enable_timing) |
1054 | 1060 |
1055 def shortunittest(args): | 1061 def shortunittest(args): |
1056 """alias for 'unittest --whitelist test/whitelist_shortunittest.txt'{0}""" | 1062 """alias for 'unittest --whitelist test/whitelist_shortunittest.txt'{0}""" |
1057 | 1063 |
1058 args = ['--whitelist', 'test/whitelist_shortunittest.txt'] + args | 1064 args = ['--whitelist', 'test/whitelist_shortunittest.txt'] + args |