changeset 9959:b37b060d84c7

run-tests: add a "--blacklist target" option to skip predefined test lists Rely on a ConfigParser file, tests/blacklist, to define blacklist targets. This allows exposing specific test suites for testing incomplete/particular features, e.g. "run-tests.py --blacklist inotify-failures --inotify *"
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Sat, 28 Nov 2009 10:25:09 +0900
parents 777c1df76ef4
children 652064640e98
files tests/blacklist tests/run-tests.py
diffstat 2 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/blacklist	Sat Nov 28 10:25:09 2009 +0900
@@ -0,0 +1,14 @@
+# ConfigParser format
+# Definitions of blacklists for run-tests.py
+#
+# Identify in config sections a list of tests you want to be skipped.
+# Section names are meant to be used as targets for run-tests.py --blacklist
+# option.
+# "test-" prefixes should be omitted from test names. Values are not used.
+#
+# e.g. if your file looks like:
+## [example]
+## hgrc =
+## help = "this string is not used"
+# then calling "run-tests.py --blacklist example" will exclude test-hgrc and
+# test-help from the list of tests to run.
--- a/tests/run-tests.py	Tue Nov 17 18:50:39 2009 +0900
+++ b/tests/run-tests.py	Sat Nov 28 10:25:09 2009 +0900
@@ -41,6 +41,7 @@
 # completes fairly quickly, includes both shell and Python scripts, and
 # includes some scripts that run daemon processes.)
 
+from ConfigParser import ConfigParser
 import difflib
 import errno
 import optparse
@@ -132,6 +133,9 @@
         help="enable Py3k warnings on Python 2.6+")
     parser.add_option("--inotify", action="store_true",
         help="enable inotify extension when running tests")
+    parser.add_option("--blacklist", action="append",
+        help="skip tests listed in the specified section of "
+             "the blacklist file")
 
     for option, default in defaults.items():
         defaults[option] = int(os.environ.get(*default))
@@ -197,6 +201,14 @@
     if options.py3k_warnings:
         if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0):
             parser.error('--py3k-warnings can only be used on Python 2.6+')
+    if options.blacklist:
+        configparser = ConfigParser()
+        configparser.read("blacklist")
+        blacklist = dict()
+        for section in options.blacklist:
+            for (item, value) in configparser.items(section):
+                blacklist["test-" + item] = section
+        options.blacklist = blacklist
 
     return (options, args)
 
@@ -730,6 +742,13 @@
         fails = []
 
         for test in tests:
+            if options.blacklist:
+                section = options.blacklist.get(test)
+                if section is not None:
+                    skips.append((test, "blacklisted (%s section)" % section))
+                    skipped += 1
+                    continue
+
             if options.retest and not os.path.exists(test + ".err"):
                 skipped += 1
                 continue