[Pkg-bazaar-commits] ./bzr/unstable r726: - more rearrangement of blackbox tests

Martin Pool mbp at sourcefrog.net
Fri Apr 10 08:20:51 UTC 2009


------------------------------------------------------------
revno: 726
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Tue 2005-06-21 17:57:11 +1000
message:
  - more rearrangement of blackbox tests
modified:
  bzrlib/selftest/__init__.py
  bzrlib/selftest/blackbox.py
-------------- next part --------------
=== modified file 'bzrlib/selftest/__init__.py'
--- a/bzrlib/selftest/__init__.py	2005-06-21 06:10:18 +0000
+++ b/bzrlib/selftest/__init__.py	2005-06-21 07:57:11 +0000
@@ -44,6 +44,7 @@
             buf = pipe.read()
             if buf:
                 out += buf
+                self.log(buf)
             else:
                 break
         rc = pipe.close()
@@ -55,7 +56,7 @@
 
     def log(self, msg):
         """Log a message to a progress file"""
-        print >>TEST_LOG, msg
+        print >>self.TEST_LOG, msg
                
 
 
@@ -96,9 +97,11 @@
     suite = TestSuite()
     tl = TestLoader()
 
-    for m in bzrlib.selftest.whitebox, bzrlib.selftest.blackbox:
+    for m in bzrlib.selftest.whitebox, :
         suite.addTest(tl.loadTestsFromModule(m))
 
+    suite.addTest(bzrlib.selftest.blackbox.suite())
+
     for m in bzrlib.store, bzrlib.inventory, bzrlib.branch, bzrlib.osutils, \
             bzrlib.commands:
         suite.addTest(DocTestSuite(m))
@@ -115,11 +118,10 @@
     import time
     import os
     
-    global TEST_LOG
     log_filename = os.path.abspath('testbzr.log')
-    TEST_LOG = open(log_filename, 'wt', buffering=1) # line buffered
+    TestBase.TEST_LOG = open(log_filename, 'wt', buffering=1) # line buffered
 
-    print >>TEST_LOG, "bzr tests run at " + time.ctime()
+    print >>TestBase.TEST_LOG, "bzr tests run at " + time.ctime()
     print '%-30s %s' % ('test log', log_filename)
 
 
@@ -127,16 +129,19 @@
     import os
     import shutil
     
-    global ORIG_DIR, TEST_DIR
-    ORIG_DIR = os.getcwdu()
-    TEST_DIR = os.path.abspath("testbzr.tmp")
-
-    print '%-30s %s' % ('running tests in', TEST_DIR)
-
-    if os.path.exists(TEST_DIR):
-        shutil.rmtree(TEST_DIR)
-    os.mkdir(TEST_DIR)
-    os.chdir(TEST_DIR)    
+    TestBase.ORIG_DIR = os.getcwdu()
+    TestBase.TEST_DIR = os.path.abspath("testbzr.tmp")
+
+    print '%-30s %s' % ('running tests in', TestBase.TEST_DIR)
+
+    if os.path.exists(TestBase.TEST_DIR):
+        shutil.rmtree(TestBase.TEST_DIR)
+    os.mkdir(TestBase.TEST_DIR)
+    os.chdir(TestBase.TEST_DIR)
+
+    # make a fake bzr directory there to prevent any tests propagating
+    # up onto the source directory's real branch
+    os.mkdir(os.path.join(TestBase.TEST_DIR, '.bzr'))
 
     
 

=== modified file 'bzrlib/selftest/blackbox.py'
--- a/bzrlib/selftest/blackbox.py	2005-06-21 06:12:45 +0000
+++ b/bzrlib/selftest/blackbox.py	2005-06-21 07:57:11 +0000
@@ -34,15 +34,42 @@
     def runTest(self):
         # output is intentionally passed through to stdout so that we
         # can see the version being tested
+        print
         self.runcmd(['bzr', 'version'])
-
-
-# class InTempBranch(TestBase):
-#     """Base class for tests run in a temporary branch."""
-#     def setUp():
-#     def tearDown()
-
-
-# class InitBranch(TestBase):
-#     def runTest(self):
-        
+        print
+
+
+
+class InTempBranch(TestBase):
+    """Base class for tests run in a temporary branch."""
+    def setUp(self):
+        import os
+        self.branch_dir = os.path.join(self.TEST_DIR, self.__class__.__name__)
+        os.mkdir(self.branch_dir)
+        os.chdir(self.branch_dir)
+        
+    def tearDown(self):
+        import os
+        os.chdir(self.TEST_DIR)
+
+
+class InitBranch(InTempBranch):
+    def runTest(self):
+        import os
+        print "%s running in %s" % (self, os.getcwdu())
+        self.runcmd(['bzr', 'init'])
+        
+        
+
+
+# lists all tests from this module in the best order to run them.  we
+# do it this way rather than just discovering them all because it
+# allows us to test more basic functions first where failures will be
+# easiest to understand.
+
+def suite():
+    from unittest import TestSuite
+    s = TestSuite()
+    s.addTests([TestVersion(),
+                InitBranch()])
+    return s



More information about the Pkg-bazaar-commits mailing list