Update of /cvsroot/webware/Webware/MiddleKit/Tests
In directory sc8-pr-cvs1:/tmp/cvs-serv28114/Tests
Modified Files:
Test.py
Log Message:
- summarize test results and duration
Index: Test.py
===================================================================
RCS file: /cvsroot/webware/Webware/MiddleKit/Tests/Test.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** Test.py 6 Nov 2002 19:54:31 -0000 1.14
--- Test.py 6 Nov 2003 08:54:35 -0000 1.15
***************
*** 1,3 ****
--- 1,6 ----
#!/usr/bin/env python
+ import time
+ startTime = time.time()
+
import os, sys
from TestCommon import *
***************
*** 5,8 ****
--- 8,17 ----
+ class RunError(Exception):
+ """
+ Raised by Test.run() if the process exits with a non-zero status, which indicates an error.
+ """
+ pass
+
class Test:
***************
*** 28,41 ****
# We explicitly list the tests rather than scanning for them (via glob) in order to perform them in a certain order (simplest to most complex)
self.readArgs(args)
for self._modelName in self.modelNames():
print '*** %s ***\n' % self._modelName
if not self._modelName.endswith('.mkmodel'):
self._modelName += '.mkmodel'
! self.testDesign()
! self.testEmpty()
! self.insertSamples()
! self.testSamples()
! rmdir(workDir)
! print '\n'
def readArgs(self, args):
--- 37,71 ----
# We explicitly list the tests rather than scanning for them (via glob) in order to perform them in a certain order (simplest to most complex)
self.readArgs(args)
+ results = []
for self._modelName in self.modelNames():
print '*** %s ***\n' % self._modelName
if not self._modelName.endswith('.mkmodel'):
self._modelName += '.mkmodel'
! didFail = 0
! try:
! self.testDesign()
! self.testEmpty()
! self.insertSamples()
! self.testSamples()
! rmdir(workDir)
! print '\n'
! except RunError:
! didFail = 1
! results.append((self._modelName, didFail))
!
! # summarize the results of each test
! print 'RESULTS'
! print '-------'
! for name, didFail in results:
! if didFail:
! outcome = '*** FAILED ***'
! else:
! outcome = ' succeeded'
! print outcome, name
!
! # print duration for curiosity's sake
! print
! duration = time.time() - startTime
! print '%.0f seconds' % (duration)
def readArgs(self, args):
***************
*** 95,99 ****
def run(self, cmd):
! """ Self utility method to run a system command. """
print '<cmd>', cmd
sys.stdout.flush()
--- 125,139 ----
def run(self, cmd):
! """
! Self utility method to run a system command. If the command
! has a non-zero exit status, raises RunError. Otherwise,
! returns 0.
!
! Note that on Windows ME, os.system() always returns 0 even if
! the program was a Python program that exited via sys.exit(1) or
! an uncaught exception. On Windows XP Pro SP 1, this problem
! does not occur. Windows ME has plenty of other problems as
! well; avoid it.
! """
print '<cmd>', cmd
sys.stdout.flush()
***************
*** 103,110 ****
sys.stderr.flush()
! # @@ 2001-02-02 ce: we have a problem, at least on Windows ME,
! # that the return code of os.system() is always 0, even if
! # the program was a Python program exited via sys.exit(1)
#print '>> RETURN CODE =', returnCode
--- 143,151 ----
sys.stderr.flush()
! if returnCode:
! raise RunError, returnCode
!
#print '>> RETURN CODE =', returnCode
+ return returnCode
|