comparison mx/mx_graal.py @ 16419:7520833c6e7f

eliminate JUnitWrapper
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Mon, 07 Jul 2014 11:54:49 -0700
parents 9fe3cb463079
children 680f52926754
comparison
equal deleted inserted replaced
16418:434888b63a15 16419:7520833c6e7f
25 # questions. 25 # questions.
26 # 26 #
27 # ---------------------------------------------------------------------------------------------------- 27 # ----------------------------------------------------------------------------------------------------
28 28
29 import os, stat, errno, sys, shutil, zipfile, tarfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing, StringIO, socket 29 import os, stat, errno, sys, shutil, zipfile, tarfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing, StringIO, socket
30 from os.path import join, exists, dirname, basename, getmtime 30 from os.path import join, exists, dirname, basename
31 from argparse import ArgumentParser, RawDescriptionHelpFormatter, REMAINDER 31 from argparse import ArgumentParser, RawDescriptionHelpFormatter, REMAINDER
32 from outputparser import OutputParser, ValuesMatcher 32 from outputparser import OutputParser, ValuesMatcher
33 import mx 33 import mx
34 import xml.dom.minidom 34 import xml.dom.minidom
35 import sanitycheck 35 import sanitycheck
983 mx.abort("Method specification is class#method: " + tests[0]) 983 mx.abort("Method specification is class#method: " + tests[0])
984 t, method = words 984 t, method = words
985 for c, p in candidates.iteritems(): 985 for c, p in candidates.iteritems():
986 if t in c: 986 if t in c:
987 found = True 987 found = True
988 # this code assumes a single test will be handled by GraalJUnitCore
989 classes.append(c + '#' + method) 988 classes.append(c + '#' + method)
990 projs.add(p.name) 989 projs.add(p.name)
991 if not found: 990 if not found:
992 mx.log('warning: no tests matched by substring "' + t) 991 mx.log('warning: no tests matched by substring "' + t)
993 else: 992 else:
1016 f_testfile.write(c + '\n') 1015 f_testfile.write(c + '\n')
1017 f_testfile.close() 1016 f_testfile.close()
1018 harness(projectsCp, vmArgs) 1017 harness(projectsCp, vmArgs)
1019 1018
1020 def _unittest(args, annotations, prefixCp="", whitelist=None, verbose=False, enable_timing=False, regex=None, color=False, eager_stacktrace=False, gc_after_test=False): 1019 def _unittest(args, annotations, prefixCp="", whitelist=None, verbose=False, enable_timing=False, regex=None, color=False, eager_stacktrace=False, gc_after_test=False):
1021 mxdir = dirname(__file__)
1022 name = 'JUnitWrapper'
1023 javaSource = join(mxdir, name + '.java')
1024 javaClass = join(mxdir, name + '.class')
1025 testfile = os.environ.get('MX_TESTFILE', None) 1020 testfile = os.environ.get('MX_TESTFILE', None)
1026 if testfile is None: 1021 if testfile is None:
1027 (_, testfile) = tempfile.mkstemp(".testclasses", "graal") 1022 (_, testfile) = tempfile.mkstemp(".testclasses", "graal")
1028 os.close(_) 1023 os.close(_)
1029 coreCp = mx.classpath(['com.oracle.graal.test']) 1024 coreCp = mx.classpath(['com.oracle.graal.test'])
1030
1031 if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource):
1032 subprocess.check_call([mx.java().javac, '-cp', coreCp, '-d', mxdir, javaSource])
1033 1025
1034 coreArgs = [] 1026 coreArgs = []
1035 if verbose: 1027 if verbose:
1036 coreArgs.append('-JUnitVerbose') 1028 coreArgs.append('-JUnitVerbose')
1037 if enable_timing: 1029 if enable_timing:
1067 if len(testclasses) == 1: 1059 if len(testclasses) == 1:
1068 # Execute Junit directly when one test is being run. This simplifies 1060 # Execute Junit directly when one test is being run. This simplifies
1069 # replaying the VM execution in a native debugger (e.g., gdb). 1061 # replaying the VM execution in a native debugger (e.g., gdb).
1070 vm(prefixArgs + vmArgs + ['-cp', cp, 'com.oracle.graal.test.GraalJUnitCore'] + coreArgs + testclasses) 1062 vm(prefixArgs + vmArgs + ['-cp', cp, 'com.oracle.graal.test.GraalJUnitCore'] + coreArgs + testclasses)
1071 else: 1063 else:
1072 vm(prefixArgs + vmArgs + ['-cp', cp + os.pathsep + mxdir, name] + [testfile] + coreArgs) 1064 vm(prefixArgs + vmArgs + ['-cp', cp, 'com.oracle.graal.test.GraalJUnitCore'] + coreArgs + ['@' + testfile])
1073 1065
1074 try: 1066 try:
1075 _run_tests(args, harness, annotations, testfile, whitelist, regex) 1067 _run_tests(args, harness, annotations, testfile, whitelist, regex)
1076 finally: 1068 finally:
1077 if os.environ.get('MX_TESTFILE') is None: 1069 if os.environ.get('MX_TESTFILE') is None: