changeset 9582:a25af3af941c

tests: add -k to test scripts matching keywords argument is a space-separated list of keywords that are searched for in the name and body of each test. This makes it easy to run only tests related to tags, hgweb, revert, etc. (eg -k "tag hgweb revert").
author Matt Mackall <mpm@selenic.com>
date Mon, 12 Oct 2009 14:52:53 -0500
parents 3b93032516b3
children 0491be4448bf
files tests/run-tests.py
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Fri Oct 09 16:27:05 2009 +0200
+++ b/tests/run-tests.py	Mon Oct 12 14:52:53 2009 -0500
@@ -90,6 +90,8 @@
     parser.add_option("-j", "--jobs", type="int",
         help="number of jobs to run in parallel"
              " (default: $%s or %d)" % defaults['jobs'])
+    parser.add_option("-k", "--keywords",
+        help="run tests matching keywords")
     parser.add_option("--keep-tmpdir", action="store_true",
         help="keep temporary directory after running tests"
              " (best used with --tmpdir)")
@@ -688,10 +690,21 @@
 
         skips = []
         fails = []
+
         for test in tests:
             if options.retest and not os.path.exists(test + ".err"):
                 skipped += 1
                 continue
+
+            if options.keywords:
+                t = open(test).read().lower() + test.lower()
+                for k in options.keywords.lower().split():
+                    if k in t:
+                        break
+                else:
+                    skipped +=1
+                    continue
+
             ret = runone(options, test, skips, fails)
             if ret is None:
                 skipped += 1