comparison mx/mx_graal.py @ 15327:25633b639fd7

mx: support simple filename globbing in whitelist
author Bernhard Urban <bernhard.urban@jku.at>
date Wed, 23 Apr 2014 14:59:05 +0200
parents 6e1d5f3e4615
children d89ed48ae349
comparison
equal deleted inserted replaced
15326:6e1d5f3e4615 15327:25633b639fd7
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
37 import json, textwrap 37 import json, textwrap
38 import fnmatch, re
38 39
39 # This works because when mx loads this file, it makes sure __file__ gets an absolute path 40 # This works because when mx loads this file, it makes sure __file__ gets an absolute path
40 _graal_home = dirname(dirname(__file__)) 41 _graal_home = dirname(dirname(__file__))
41 42
42 """ Used to distinguish an exported GraalVM (see 'mx export'). """ 43 """ Used to distinguish an exported GraalVM (see 'mx export'). """
859 if not found: 860 if not found:
860 mx.log('warning: no tests matched by substring "' + t) 861 mx.log('warning: no tests matched by substring "' + t)
861 projectscp = mx.classpath(projs) 862 projectscp = mx.classpath(projs)
862 863
863 if whitelist: 864 if whitelist:
864 classes = list(set(classes) & set(whitelist)) 865 classes = [c for c in classes if any([glob.match(c) for glob in whitelist])]
865 866
866 if len(classes) != 0: 867 if len(classes) != 0:
867 f_testfile = open(testfile, 'w') 868 f_testfile = open(testfile, 'w')
868 for c in classes: 869 for c in classes:
869 f_testfile.write(c + '\n') 870 f_testfile.write(c + '\n')
964 965
965 whitelist = None 966 whitelist = None
966 if parsed_args.whitelist: 967 if parsed_args.whitelist:
967 try: 968 try:
968 with open(join(_graal_home, parsed_args.whitelist)) as fp: 969 with open(join(_graal_home, parsed_args.whitelist)) as fp:
969 whitelist = [l.rstrip() for l in fp.readlines() if not l.startswith('#')] 970 whitelist = [re.compile(fnmatch.translate(l.rstrip())) for l in fp.readlines() if not l.startswith('#')]
970 except IOError: 971 except IOError:
971 mx.log('warning: could not read whitelist: ' + parsed_args.whitelist) 972 mx.log('warning: could not read whitelist: ' + parsed_args.whitelist)
972 973
973 _unittest(args, ['@Test', '@Parameters'], whitelist=whitelist) 974 _unittest(args, ['@Test', '@Parameters'], whitelist=whitelist)
974 975