[llvm-commits] [zorg] r141407 - /zorg/trunk/lnt/lnt/tests/nt.py

Daniel Dunbar daniel at zuster.org
Fri Oct 7 12:55:21 PDT 2011


Author: ddunbar
Date: Fri Oct  7 14:55:21 2011
New Revision: 141407

URL: http://llvm.org/viewvc/llvm-project?rev=141407&view=rev
Log:
LNT/nt: Factor out scan_for_test_modules(), and properly support --only-test inside LNTBased test directories.
 - Also, by default don't include example test directories.

Modified:
    zorg/trunk/lnt/lnt/tests/nt.py

Modified: zorg/trunk/lnt/lnt/tests/nt.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=141407&r1=141406&r2=141407&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/tests/nt.py (original)
+++ zorg/trunk/lnt/lnt/tests/nt.py Fri Oct  7 14:55:21 2011
@@ -34,6 +34,31 @@
 def timestamp():
     return datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
 
+def scan_for_test_modules(opts):
+    base_modules_path = os.path.join(opts.test_suite_root, 'LNTBased')
+    if opts.only_test is None:
+        test_modules_path = base_modules_path
+    elif opts.only_test.startswith('LNTBased'):
+        test_modules_path = os.path.join(opts.test_suite_root, opts.only_test)
+    else:
+        return
+
+    for dirpath,dirnames,filenames in os.walk(test_modules_path):
+        # Ignore the example tests, unless requested.
+        if not opts.include_test_examples and 'Examples' in dirnames:
+            dirnames.remove('Examples')
+
+        # Check if this directory defines a test module.
+        if 'TestModule' not in filenames:
+            continue
+
+        # If so, don't traverse any lower.
+        del dirnames[:]
+
+        # Add to the list of test modules.
+        assert dirpath.startswith(base_modules_path + '/')
+        yield dirpath[len(base_modules_path) + 1:]
+
 def execute_test_modules(test_log, test_modules, test_module_variables,
                          basedir, opts):
     # For now, we don't execute these in parallel, but we do forward the
@@ -510,14 +535,7 @@
     # Scan for LNT-based test modules.
     print >>sys.stderr, "%s: scanning for LNT-based test modules" % (
         timestamp(),)
-    test_modules = []
-    test_modules_path = os.path.join(opts.test_suite_root, 'LNTBased')
-    for dirpath,dirnames,filenames in os.walk(test_modules_path):
-        if 'TestModule' not in filenames:
-            continue
-
-        assert dirpath.startswith(test_modules_path + '/')
-        test_modules.append(dirpath[len(test_modules_path) + 1:])
+    test_modules = list(scan_for_test_modules(opts))
     print >>sys.stderr, "%s: found %d LNT-based test modules" % (
         timestamp(), len(test_modules))
 
@@ -968,6 +986,10 @@
         group.add_option("", "--only-test", dest="only_test", metavar="PATH",
                          help="Only run tests under PATH",
                          type=str, default=None)
+        group.add_option("", "--include-test-examples",
+                         dest="include_test_examples",
+                         help="Include test module examples [%default]",
+                         action="store_true", default=False)
         parser.add_option_group(group)
 
         group = OptionGroup(parser, "Test Execution")





More information about the llvm-commits mailing list