##// END OF EJS Templates
run-tests: allow whitelisting tests that should always run...
Augie Fackler -
r14493:5cc7905b default
parent child Browse files
Show More
@@ -104,12 +104,35 b' defaults = {'
104 104 'shell': ('HGTEST_SHELL', '/bin/sh'),
105 105 }
106 106
107 def parselistfiles(files, listtype, warn=True):
108 entries = dict()
109 for filename in files:
110 try:
111 path = os.path.expanduser(os.path.expandvars(filename))
112 f = open(path, "r")
113 except IOError, err:
114 if err.errno != errno.ENOENT:
115 raise
116 if warn:
117 print "warning: no such %s file: %s" % (listtype, filename)
118 continue
119
120 for line in f.readlines():
121 line = line.split('#', 1)[0].strip()
122 if line:
123 entries[line] = filename
124
125 f.close()
126 return entries
127
107 128 def parseargs():
108 129 parser = optparse.OptionParser("%prog [options] [tests]")
109 130
110 131 # keep these sorted
111 132 parser.add_option("--blacklist", action="append",
112 133 help="skip tests listed in the specified blacklist file")
134 parser.add_option("--whitelist", action="append",
135 help="always run tests listed in the specified whitelist file")
113 136 parser.add_option("-C", "--annotate", action="store_true",
114 137 help="output files annotated with coverage")
115 138 parser.add_option("--child", type="int",
@@ -247,25 +270,12 b' def parseargs():'
247 270 if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0):
248 271 parser.error('--py3k-warnings can only be used on Python 2.6+')
249 272 if options.blacklist:
250 blacklist = dict()
251 for filename in options.blacklist:
252 try:
253 path = os.path.expanduser(os.path.expandvars(filename))
254 f = open(path, "r")
255 except IOError, err:
256 if err.errno != errno.ENOENT:
257 raise
258 print "warning: no such blacklist file: %s" % filename
259 continue
260
261 for line in f.readlines():
262 line = line.split('#', 1)[0].strip()
263 if line:
264 blacklist[line] = filename
265
266 f.close()
267
268 options.blacklist = blacklist
273 options.blacklist = parselistfiles(options.blacklist, 'blacklist')
274 if options.whitelist:
275 options.whitelisted = parselistfiles(options.whitelist, 'whitelist',
276 warn=options.child is None)
277 else:
278 options.whitelisted = {}
269 279
270 280 return (options, args)
271 281
@@ -733,24 +743,25 b' def runone(options, test):'
733 743 else:
734 744 return None # not a supported test, don't record
735 745
736 if options.blacklist and test in options.blacklist:
737 skip("blacklisted")
738 return None
746 if not (options.whitelisted and test in options.whitelisted):
747 if options.blacklist and test in options.blacklist:
748 skip("blacklisted")
749 return None
739 750
740 if options.retest and not os.path.exists(test + ".err"):
741 ignore("not retesting")
742 return None
751 if options.retest and not os.path.exists(test + ".err"):
752 ignore("not retesting")
753 return None
743 754
744 if options.keywords:
745 fp = open(test)
746 t = fp.read().lower() + test.lower()
747 fp.close()
748 for k in options.keywords.lower().split():
749 if k in t:
750 break
751 else:
752 ignore("doesn't match keyword")
753 return None
755 if options.keywords:
756 fp = open(test)
757 t = fp.read().lower() + test.lower()
758 fp.close()
759 for k in options.keywords.lower().split():
760 if k in t:
761 break
762 else:
763 ignore("doesn't match keyword")
764 return None
754 765
755 766 vlog("# Test", test)
756 767
@@ -920,6 +931,14 b' def runchildren(options, tests):'
920 931 optcopy = dict(options.__dict__)
921 932 optcopy['jobs'] = 1
922 933
934 # Because whitelist has to override keyword matches, we have to
935 # actually load the whitelist in the children as well, so we allow
936 # the list of whitelist files to pass through and be parsed in the
937 # children, but not the dict of whitelisted tests resulting from
938 # the parse, used here to override blacklisted tests.
939 whitelist = optcopy['whitelisted'] or []
940 del optcopy['whitelisted']
941
923 942 blacklist = optcopy['blacklist'] or []
924 943 del optcopy['blacklist']
925 944 blacklisted = []
@@ -946,7 +965,7 b' def runchildren(options, tests):'
946 965 if not tests:
947 966 break
948 967 test = tests.pop()
949 if test in blacklist:
968 if test not in whitelist and test in blacklist:
950 969 blacklisted.append(test)
951 970 else:
952 971 job.append(test)
General Comments 0
You need to be logged in to leave comments. Login now