tests: add -k to test scripts matching keywords
authorMatt Mackall <mpm@selenic.com>
Mon, 12 Oct 2009 14:52:53 -0500
changeset 9582 a25af3af941c
parent 9581 3b93032516b3
child 9583 0491be4448bf
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").
tests/run-tests.py
--- 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