comparison mx/mx_graal.py @ 15169:0ba58961ba14

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 16 Apr 2014 19:00:14 +0200
parents 2082889fc8f6
children 0c53453c4d5e
comparison
equal deleted inserted replaced
15168:78530cbd8940 15169:0ba58961ba14
26 # 26 #
27 # ---------------------------------------------------------------------------------------------------- 27 # ----------------------------------------------------------------------------------------------------
28 28
29 import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing, StringIO 29 import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing, StringIO
30 from os.path import join, exists, dirname, basename, getmtime 30 from os.path import join, exists, dirname, basename, getmtime
31 from argparse import ArgumentParser, 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
36 import itertools 36 import itertools
826 if defaultAllVMArgs: 826 if defaultAllVMArgs:
827 return args, [] 827 return args, []
828 else: 828 else:
829 return [], args 829 return [], args
830 830
831 def _run_tests(args, harness, annotations, testfile): 831 def _run_tests(args, harness, annotations, testfile, whitelist):
832 832
833 833
834 vmArgs, tests = _extract_VM_args(args) 834 vmArgs, tests = _extract_VM_args(args)
835 for t in tests: 835 for t in tests:
836 if t.startswith('-'): 836 if t.startswith('-'):
858 projs.add(p.name) 858 projs.add(p.name)
859 if not found: 859 if not found:
860 mx.log('warning: no tests matched by substring "' + t) 860 mx.log('warning: no tests matched by substring "' + t)
861 projectscp = mx.classpath(projs) 861 projectscp = mx.classpath(projs)
862 862
863 if whitelist:
864 classes = list(set(classes) & set(whitelist))
865
863 if len(classes) != 0: 866 if len(classes) != 0:
864 f_testfile = open(testfile, 'w') 867 f_testfile = open(testfile, 'w')
865 for c in classes: 868 for c in classes:
866 f_testfile.write(c + '\n') 869 f_testfile.write(c + '\n')
867 f_testfile.close() 870 f_testfile.close()
868 harness(projectscp, vmArgs) 871 harness(projectscp, vmArgs)
869 872
870 def _unittest(args, annotations, prefixcp=""): 873 def _unittest(args, annotations, prefixcp="", whitelist=None):
871 mxdir = dirname(__file__) 874 mxdir = dirname(__file__)
872 name = 'JUnitWrapper' 875 name = 'JUnitWrapper'
873 javaSource = join(mxdir, name + '.java') 876 javaSource = join(mxdir, name + '.java')
874 javaClass = join(mxdir, name + '.class') 877 javaClass = join(mxdir, name + '.class')
875 testfile = os.environ.get('MX_TESTFILE', None) 878 testfile = os.environ.get('MX_TESTFILE', None)
892 vm(prefixArgs + vmArgs + ['-cp', prefixcp + projectscp, 'org.junit.runner.JUnitCore'] + testclasses) 895 vm(prefixArgs + vmArgs + ['-cp', prefixcp + projectscp, 'org.junit.runner.JUnitCore'] + testclasses)
893 else: 896 else:
894 vm(prefixArgs + vmArgs + ['-cp', prefixcp + projectscp + os.pathsep + mxdir, name] + [testfile]) 897 vm(prefixArgs + vmArgs + ['-cp', prefixcp + projectscp + os.pathsep + mxdir, name] + [testfile])
895 898
896 try: 899 try:
897 _run_tests(args, harness, annotations, testfile) 900 _run_tests(args, harness, annotations, testfile, whitelist)
898 finally: 901 finally:
899 if os.environ.get('MX_TESTFILE') is None: 902 if os.environ.get('MX_TESTFILE') is None:
900 os.remove(testfile) 903 os.remove(testfile)
901 904
902 _unittestHelpSuffix = """ 905 _unittestHelpSuffix = """
906 Unittest options:
907
908 --short-only run short testcases only
909 --long-only run long testcases only
910 --baseline-whitelist run only testcases which are known to
911 work with the baseline compiler
912
913 To avoid conflicts with VM options '--' can be used as delimiter.
903 914
904 If filters are supplied, only tests whose fully qualified name 915 If filters are supplied, only tests whose fully qualified name
905 includes a filter as a substring are run. 916 includes a filter as a substring are run.
906 917
907 For example, this command line: 918 For example, this command line:
926 """ 937 """
927 938
928 def unittest(args): 939 def unittest(args):
929 """run the JUnit tests (all testcases){0}""" 940 """run the JUnit tests (all testcases){0}"""
930 941
931 _unittest(args, ['@Test', '@LongTest', '@Parameters']) 942 parser = ArgumentParser(prog='mx unittest',
943 description='run the JUnit tests',
944 add_help=False,
945 formatter_class=RawDescriptionHelpFormatter,
946 epilog=_unittestHelpSuffix,
947 )
948 group = parser.add_mutually_exclusive_group()
949 group.add_argument('--short-only', action='store_true', help='run short testcases only')
950 group.add_argument('--long-only', action='store_true', help='run long testcases only')
951 parser.add_argument('--baseline-whitelist', action='store_true', help='run baseline testcases only')
952
953 ut_args = []
954 delimiter = False
955 # check for delimiter
956 while len(args) > 0:
957 arg = args.pop(0)
958 if arg == '--':
959 delimiter = True
960 break
961 ut_args.append(arg)
962
963 if delimiter:
964 # all arguments before '--' must be recognized
965 parsed_args = parser.parse_args(ut_args)
966 else:
967 # parse all know arguments
968 parsed_args, remaining_args = parser.parse_known_args(ut_args)
969 args = remaining_args + args
970
971 whitelist = None
972 if parsed_args.baseline_whitelist:
973 baseline_whitelist_file = 'test/baseline_whitelist.txt'
974 try:
975 with open(join(_graal_home, baseline_whitelist_file)) as fp:
976 whitelist = [l.rstrip() for l in fp.readlines()]
977 except IOError:
978 mx.log('warning: could not read baseline whitelist: ' + baseline_whitelist_file)
979
980 if parsed_args.long_only:
981 annotations = ['@LongTest', '@Parameters']
982 elif parsed_args.short_only:
983 annotations = ['@Test']
984 else:
985 annotations = ['@Test', '@LongTest', '@Parameters']
986
987 _unittest(args, annotations, whitelist=whitelist)
932 988
933 def shortunittest(args): 989 def shortunittest(args):
934 """run the JUnit tests (short testcases only){0}""" 990 """alias for 'unittest --short-only'{0}"""
935 991
936 _unittest(args, ['@Test']) 992 args.insert(0, '--short-only')
993 unittest(args)
937 994
938 def longunittest(args): 995 def longunittest(args):
939 """run the JUnit tests (long testcases only){0}""" 996 """alias for 'unittest --long-only'{0}"""
940 997
941 _unittest(args, ['@LongTest', '@Parameters']) 998 args.insert(0, '--long-only')
999 unittest(args)
942 1000
943 def buildvms(args): 1001 def buildvms(args):
944 """build one or more VMs in various configurations""" 1002 """build one or more VMs in various configurations"""
945 1003
946 vmsDefault = ','.join(_vmChoices.keys()) 1004 vmsDefault = ','.join(_vmChoices.keys())
1782 'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'], 1840 'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'],
1783 'specjbb2013': [specjbb2013, '[VM options] [-- [SPECjbb2013 options]]'], 1841 'specjbb2013': [specjbb2013, '[VM options] [-- [SPECjbb2013 options]]'],
1784 'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'], 1842 'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'],
1785 'gate' : [gate, '[-options]'], 1843 'gate' : [gate, '[-options]'],
1786 'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'], 1844 'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'],
1787 'unittest' : [unittest, '[VM options] [filters...]', _unittestHelpSuffix], 1845 'unittest' : [unittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix],
1788 'longunittest' : [longunittest, '[VM options] [filters...]', _unittestHelpSuffix], 1846 'longunittest' : [longunittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix],
1789 'shortunittest' : [shortunittest, '[VM options] [filters...]', _unittestHelpSuffix], 1847 'shortunittest' : [shortunittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix],
1790 'jacocoreport' : [jacocoreport, '[output directory]'], 1848 'jacocoreport' : [jacocoreport, '[output directory]'],
1791 'site' : [site, '[-options]'], 1849 'site' : [site, '[-options]'],
1792 'vm': [vm, '[-options] class [args...]'], 1850 'vm': [vm, '[-options] class [args...]'],
1793 'vmg': [vmg, '[-options] class [args...]'], 1851 'vmg': [vmg, '[-options] class [args...]'],
1794 'vmfg': [vmfg, '[-options] class [args...]'], 1852 'vmfg': [vmfg, '[-options] class [args...]'],