[cfe-commits] r77766 - /cfe/trunk/utils/test/MultiTestRunner.py

Daniel Dunbar daniel at zuster.org
Fri Jul 31 20:35:41 PDT 2009


Author: ddunbar
Date: Fri Jul 31 22:35:40 2009
New Revision: 77766

URL: http://llvm.org/viewvc/llvm-project?rev=77766&view=rev
Log:
lit: Don't use threads when only running one test, or with -j 1.

Modified:
    cfe/trunk/utils/test/MultiTestRunner.py

Modified: cfe/trunk/utils/test/MultiTestRunner.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/test/MultiTestRunner.py?rev=77766&r1=77765&r2=77766&view=diff

==============================================================================
--- cfe/trunk/utils/test/MultiTestRunner.py (original)
+++ cfe/trunk/utils/test/MultiTestRunner.py Fri Jul 31 22:35:40 2009
@@ -190,6 +190,24 @@
 
     raise ValueError,"Unable to find config file %r" % kConfigName
 
+def runTests(opts, provider):
+    # If only using one testing thread, don't use threads at all; this lets us
+    # profile, among other things.
+    if opts.numThreads == 1:
+        t = Tester(provider)
+        t.run()
+        return
+
+    # Otherwise spin up the testing threads and wait for them to finish.
+    testers = [Tester(provider) for i in range(opts.numThreads)]
+    for t in testers:
+        t.start()
+    try:
+        for t in testers:
+            t.join()
+    except KeyboardInterrupt:
+        sys.exit(1)
+
 def main():
     global options
     from optparse import OptionParser, OptionGroup
@@ -323,19 +341,13 @@
         if not progressBar:
             print header
 
-    display = TestingProgressDisplay(opts, len(tests), progressBar)
-    provider = TestProvider(cfg, opts, tests, display)
+    # Don't create more threads than tests.
+    opts.numThreads = min(len(tests), opts.numThreads)
 
-    testers = [Tester(provider) for i in range(opts.numThreads)]
     startTime = time.time()
-    for t in testers:
-        t.start()
-    try:
-        for t in testers:
-            t.join()
-    except KeyboardInterrupt:
-        sys.exit(1)
-
+    display = TestingProgressDisplay(opts, len(tests), progressBar)
+    provider = TestProvider(cfg, opts, tests, display)
+    runTests(opts, provider)
     display.finish()
 
     if not opts.quiet:





More information about the cfe-commits mailing list