[commit: testsuite] master: Run all the 'alone' tests at the end of the testsuite run (40b039b)

Ian Lynagh <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/testsuite

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/40b039bd46276168e08b9ce278920720e32313cf

>---------------------------------------------------------------

commit 40b039bd46276168e08b9ce278920720e32313cf
Author: Ian Lynagh <[email protected]>
Date:   Thu Oct 11 14:34:46 2012 +0100

    Run all the 'alone' tests at the end of the testsuite run
    
    This is more efficient than having to wait for all threads to finish
    before each 'alone' test.

>---------------------------------------------------------------

 driver/runtests.py |    5 ++++-
 driver/testlib.py  |   42 ++++++++++++++++++++++--------------------
 2 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/driver/runtests.py b/driver/runtests.py
index bc93355..66e3bf4 100644
--- a/driver/runtests.py
+++ b/driver/runtests.py
@@ -260,13 +260,16 @@ for file in t_files:
 # Now run all the tests
 if config.use_threads:
     t.running_threads=0
-for oneTest in allTests:
+for oneTest in parallelTests:
     oneTest()
 if config.use_threads:
     t.thread_pool.acquire()
     while t.running_threads>0:
         t.thread_pool.wait()
     t.thread_pool.release()
+config.use_threads = False
+for oneTest in aloneTests:
+    oneTest()
         
 summary(t, sys.stdout)
 
diff --git a/driver/testlib.py b/driver/testlib.py
index 58e2534..881abfc 100644
--- a/driver/testlib.py
+++ b/driver/testlib.py
@@ -549,31 +549,22 @@ def newTestDir( dir ):
 # -----------------------------------------------------------------------------
 # Actually doing tests
 
-allTests = []
+parallelTests = []
+aloneTests = []
 allTestNames = set([])
 
-def runTest (opts, name, setup, func, args):
-    n = 1
-
-    if type(setup) is types.ListType:
-       setup = composes(setup)
-
-    setup(opts)
-
-    if opts.alone:
-        n = config.threads
-
+def runTest (opts, name, func, args):
     ok = 0
 
     if config.use_threads:
         t.thread_pool.acquire()
         try:
-            while config.threads<(t.running_threads+n):
+            while config.threads<(t.running_threads+1):
                 t.thread_pool.wait()
-            t.running_threads = t.running_threads+n
+            t.running_threads = t.running_threads+1
             ok=1
             t.thread_pool.release()
-            thread.start_new_thread(test_common_thread, (n, name, opts, func, args))
+            thread.start_new_thread(test_common_thread, (name, opts, func, args))
         except:
             if not ok:
                 t.thread_pool.release()
@@ -583,23 +574,34 @@ def runTest (opts, name, setup, func, args):
 # name  :: String
 # setup :: TestOpts -> IO ()
 def test (name, setup, func, args):
-    global allTests
+    global aloneTests
+    global parallelTests
     global allTestNames
     if name in allTestNames:
         framework_fail(name, 'duplicate', 'There are multiple tests with this name')
     myTestOpts = copy.copy(thisdir_testopts)
-    allTests += [lambda : runTest(myTestOpts, name, setup, func, args)]
+
+    if type(setup) is types.ListType:
+       setup = composes(setup)
+
+    setup(myTestOpts)
+
+    thisTest = lambda : runTest(myTestOpts, name, func, args)
+    if myTestOpts.alone:
+        aloneTests.append(thisTest)
+    else:
+        parallelTests.append(thisTest)
     allTestNames.add(name)
 
 if config.use_threads:
-    def test_common_thread(n, name, opts, func, args):
+    def test_common_thread(name, opts, func, args):
         t.lock.acquire()
         try:
             test_common_work(name,opts,func,args)
         finally:
             t.lock.release()
             t.thread_pool.acquire()
-            t.running_threads = t.running_threads - n
+            t.running_threads = t.running_threads - 1
             t.thread_pool.notify()
             t.thread_pool.release()
 
@@ -745,7 +747,7 @@ def do_test(name, way, func, args):
     full_name = name + '(' + way + ')'
 
     try:
-        print '=====>', full_name, t.total_tests, 'of', len(allTests), \
+        print '=====>', full_name, t.total_tests, 'of', len(allTestNames), \
                         str([t.n_unexpected_passes,   \
                              t.n_unexpected_failures, \
                              t.n_framework_failures])
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.