[llvm-commits] [llvm] r148362 - /llvm/trunk/utils/lit/lit/main.py

Daniel Dunbar daniel at zuster.org
Tue Jan 17 16:03:13 PST 2012


Author: ddunbar
Date: Tue Jan 17 18:03:12 2012
New Revision: 148362

URL: http://llvm.org/viewvc/llvm-project?rev=148362&view=rev
Log:
[lit] Add a --filter option which is useful when dealing with virtual test
paths.

Modified:
    llvm/trunk/utils/lit/lit/main.py

Modified: llvm/trunk/utils/lit/lit/main.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/main.py?rev=148362&r1=148361&r2=148362&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/main.py (original)
+++ llvm/trunk/utils/lit/lit/main.py Tue Jan 17 18:03:12 2012
@@ -429,6 +429,10 @@
     group.add_option("", "--shuffle", dest="shuffle",
                      help="Run tests in random order",
                      action="store_true", default=False)
+    group.add_option("", "--filter", dest="filter", metavar="EXPRESSION",
+                     help=("Only run tests with paths matching the given "
+                           "regular expression"),
+                     action="store", default=None)
     parser.add_option_group(group)
 
     group = OptionGroup(parser, "Debug and Experimental Options")
@@ -540,10 +544,24 @@
 
     # Select and order the tests.
     numTotalTests = len(tests)
+
+    # First, select based on the filter expression if given.
+    if opts.filter:
+        try:
+            rex = re.compile(opts.filter)
+        except:
+            parser.error("invalid regular expression for --filter: %r" % (
+                    opts.filter))
+        tests = [t for t in tests
+                 if rex.search(t.getFullName())]
+
+    # Then select the order.
     if opts.shuffle:
         random.shuffle(tests)
     else:
         tests.sort(key = lambda t: t.getFullName())
+
+    # Finally limit the number of tests, if desired.
     if opts.maxTests is not None:
         tests = tests[:opts.maxTests]
 





More information about the llvm-commits mailing list