[Pkg-bazaar-commits] ./bzr/unstable r296: - better reports from testbzr when it fails

Martin Pool mbp at sourcefrog.net
Fri Apr 10 07:51:45 UTC 2009


------------------------------------------------------------
revno: 296
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Thu 2005-04-28 18:50:42 +1000
message:
  - better reports from testbzr when it fails
modified:
  NEWS
  testbzr
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2005-04-26 10:37:53 +0000
+++ b/NEWS	2005-04-28 08:50:42 +0000
@@ -5,6 +5,10 @@
     * New 'bzr whoami --email' option shows only the email component
       of the user identification, from Jo Vermeulen.
 
+  TESTING:
+
+    * Converted black-box test suites from Bourne shell into Python. 
+
 
 bzr-0.0.4  2005-04-22
 

=== modified file 'testbzr'
--- a/testbzr	2005-04-28 07:07:06 +0000
+++ b/testbzr	2005-04-28 08:50:42 +0000
@@ -24,7 +24,7 @@
 
 This replaces the previous test.sh which was not very portable."""
 
-import sys, os
+import sys, os, traceback
 
 try:
     import shutil
@@ -35,6 +35,10 @@
     sys.exit(1)
 
 
+class CommandFailed(Exception):
+    pass
+
+
 def runcmd(cmd):
     """run one command and check the output.
 
@@ -47,7 +51,7 @@
     logfile.write('$ %r\n' % cmd)
     retcode = call(cmd, stdout=logfile, stderr=logfile)
     if retcode != 0:
-        raise Exception("test failed: %r returned %r" % (cmd, retcode))
+        raise CommandFailed("test failed: %r returned %r" % (cmd, retcode))
 
 
 def progress(msg):
@@ -65,13 +69,22 @@
 logfile = open('bzr-test.log', 'wt')
 
 
-os.mkdir(TESTDIR)
-os.chdir(TESTDIR)
-
-
-progress("testing introductory commands")
-runcmd("bzr version")
-runcmd("bzr help")
-runcmd("bzr --help")
-
-progress("all tests passed!")
+try: 
+    os.mkdir(TESTDIR)
+    os.chdir(TESTDIR)
+
+
+    progress("testing introductory commands")
+    runcmd("bzr version")
+    runcmd("bzr help")
+    runcmd("bzr --helpx")
+
+    progress("all tests passed!")
+except Exception, e:
+    sys.stderr.write('*' * 50 + '\n'
+                     + 'testbzr: tests failed\n'
+                     + 'see bzr-test.log for more information\n'
+                     + '*' * 50 + '\n')
+    logfile.write('tests failed!\n')
+    traceback.print_exc(None, logfile)
+    sys.exit(1)



More information about the Pkg-bazaar-commits mailing list