comparison mx/mx_graal.py @ 15114:2082889fc8f6

mx: add unittest option --baseline-whitelist.
author Josef Eisl <josef.eisl@jku.at>
date Tue, 15 Apr 2014 17:56:27 +0200
parents 4da162518b39
children 0c53453c4d5e
comparison
equal deleted inserted replaced
15113:4da162518b39 15114:2082889fc8f6
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 = """
903 Unittest options: 906 Unittest options:
904 907
905 --short-only run short testcases only 908 --short-only run short testcases only
906 --long-only run long 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
907 912
908 To avoid conflicts with VM options '--' can be used as delimiter. 913 To avoid conflicts with VM options '--' can be used as delimiter.
909 914
910 If filters are supplied, only tests whose fully qualified name 915 If filters are supplied, only tests whose fully qualified name
911 includes a filter as a substring are run. 916 includes a filter as a substring are run.
941 epilog=_unittestHelpSuffix, 946 epilog=_unittestHelpSuffix,
942 ) 947 )
943 group = parser.add_mutually_exclusive_group() 948 group = parser.add_mutually_exclusive_group()
944 group.add_argument('--short-only', action='store_true', help='run short testcases only') 949 group.add_argument('--short-only', action='store_true', help='run short testcases only')
945 group.add_argument('--long-only', action='store_true', help='run long 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')
946 952
947 ut_args = [] 953 ut_args = []
948 delimiter = False 954 delimiter = False
949 # check for delimiter 955 # check for delimiter
950 while len(args) > 0: 956 while len(args) > 0:
960 else: 966 else:
961 # parse all know arguments 967 # parse all know arguments
962 parsed_args, remaining_args = parser.parse_known_args(ut_args) 968 parsed_args, remaining_args = parser.parse_known_args(ut_args)
963 args = remaining_args + args 969 args = remaining_args + args
964 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
965 if parsed_args.long_only: 980 if parsed_args.long_only:
966 annotations = ['@LongTest', '@Parameters'] 981 annotations = ['@LongTest', '@Parameters']
967 elif parsed_args.short_only: 982 elif parsed_args.short_only:
968 annotations = ['@Test'] 983 annotations = ['@Test']
969 else: 984 else:
970 annotations = ['@Test', '@LongTest', '@Parameters'] 985 annotations = ['@Test', '@LongTest', '@Parameters']
971 986
972 _unittest(args, annotations) 987 _unittest(args, annotations, whitelist=whitelist)
973 988
974 def shortunittest(args): 989 def shortunittest(args):
975 """alias for 'unittest --short-only'{0}""" 990 """alias for 'unittest --short-only'{0}"""
976 991
977 args.insert(0, '--short-only') 992 args.insert(0, '--short-only')