[PATCH 2 of 3 RFC] run-tests: add a "--blacklist target" option to skip predefined test lists

Nicolas Dumazet nicdumz at gmail.com
Fri Nov 27 21:40:11 CST 2009


# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits at gmail.com>
# Date 1259371509 -32400
# Node ID 90a923818bb2076141e61cec7d513c6b5730dfed
# Parent  a9df69e0a8a019fb34911c8b4b14f602620a1137
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 *"

diff --git a/tests/blacklist b/tests/blacklist
new file mode 100644
--- /dev/null
+++ b/tests/blacklist
@@ -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.
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -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


More information about the Mercurial-devel mailing list