[Pkg-bazaar-commits] ./bzr-builddeb/trunk r219: Make running the tests during the build much more robust.

James Westby jw+debian at jameswestby.net
Thu May 15 13:29:39 UTC 2008


------------------------------------------------------------
revno: 219
committer: James Westby <jw+debian at jameswestby.net>
branch nick: trunk
timestamp: Wed 2008-03-19 21:19:18 +0000
message:
  Make running the tests during the build much more robust.
removed:
  tests/test_version.py
added:
  run-tests.py
modified:
  debian/rules
  tests/__init__.py
  tests/test_import_dsc.py
-------------- next part --------------
=== modified file 'debian/rules'
--- a/debian/rules	2008-03-05 17:00:51 +0000
+++ b/debian/rules	2008-03-19 21:19:18 +0000
@@ -23,8 +23,7 @@
 	python$* setup.py build
 ifeq (,$(findstring nocheck,$(DEBBUILDOPTS)))
 ifeq (,$(findstring notest,$(DEBBUILDOPTS)))
-	[ -e builddeb ] || ln -s . builddeb
-	BZR_PLUGIN_PATH="$(CURDIR)" python$* /usr/bin/bzr selftest builddeb
+	python$* run-tests.py
 endif
 endif
 	touch $@
@@ -35,7 +34,6 @@
 	rm -f build-stamp install-all-stamp
 	rm -f $(html_docs)
 	rm -f README.html
-	rm -f builddeb
 
 	python setup.py clean --all
 	dh_clean

=== added file 'run-tests.py'
--- a/run-tests.py	1970-01-01 00:00:00 +0000
+++ b/run-tests.py	2008-03-19 21:19:18 +0000
@@ -0,0 +1,16 @@
+
+import sys
+
+sys.path.insert(0, "build/lib/bzrlib/plugins/")
+
+import builddeb
+
+suite = builddeb.test_suite()
+
+import unittest
+
+result = unittest.TextTestRunner(verbosity=2).run(suite)
+
+if not result.wasSuccessful():
+    raise sys.exit(1)
+

=== modified file 'tests/__init__.py'
--- a/tests/__init__.py	2008-03-06 15:46:17 +0000
+++ b/tests/__init__.py	2008-03-19 21:19:18 +0000
@@ -142,7 +142,6 @@
             'test_import_dsc',
             'test_repack_tarball_extra',
             'test_util',
-            'test_version',
             ]
     suite.addTest(loader.loadTestsFromModuleNames(["%s.%s" % (__name__, i)
                                             for i in testmod_names]))

=== modified file 'tests/test_import_dsc.py'
--- a/tests/test_import_dsc.py	2008-03-05 17:00:51 +0000
+++ b/tests/test_import_dsc.py	2008-03-19 21:19:18 +0000
@@ -21,6 +21,7 @@
 import gzip
 import os
 import shutil
+import sys
 import tarfile
 
 from bzrlib.config import ConfigObj
@@ -1204,77 +1205,78 @@
 class _TarInfo(tarfile.TarInfo):
     """Subclass TarInfo to stop it normalising its path. Sorry Mum."""
 
-    def tobuf(self, posix=False):
-        """Return a tar header as a string of 512 byte blocks.
-        """
-        buf = ""
-        type = self.type
-        prefix = ""
-
-        if self.name.endswith("/"):
-            type = tarfile.DIRTYPE
-
-        name = self.name
-
-        if type == tarfile.DIRTYPE:
-            # directories should end with '/'
-            name += "/"
-
-        linkname = self.linkname
-        if linkname:
-            # if linkname is empty we end up with a '.'
-            linkname = normpath(linkname)
-
-        if posix:
-            if self.size > tarfile.MAXSIZE_MEMBER:
-                raise ValueError("file is too large (>= 8 GB)")
-
-            if len(self.linkname) > tarfile.LENGTH_LINK:
-                raise ValueError("linkname is too long (>%d)" % (LENGTH_LINK))
-
-            if len(name) > tarfile.LENGTH_NAME:
-                prefix = name[:tarfile.LENGTH_PREFIX + 1]
-                while prefix and prefix[-1] != "/":
+if sys.version > (2, 4):
+        def tobuf(self, posix=False):
+            """Return a tar header as a string of 512 byte blocks.
+            """
+            buf = ""
+            type = self.type
+            prefix = ""
+
+            if self.name.endswith("/"):
+                type = tarfile.DIRTYPE
+
+            name = self.name
+
+            if type == tarfile.DIRTYPE:
+                # directories should end with '/'
+                name += "/"
+
+            linkname = self.linkname
+            if linkname:
+                # if linkname is empty we end up with a '.'
+                linkname = normpath(linkname)
+
+            if posix:
+                if self.size > tarfile.MAXSIZE_MEMBER:
+                    raise ValueError("file is too large (>= 8 GB)")
+
+                if len(self.linkname) > tarfile.LENGTH_LINK:
+                    raise ValueError("linkname is too long (>%d)" % (LENGTH_LINK))
+
+                if len(name) > tarfile.LENGTH_NAME:
+                    prefix = name[:tarfile.LENGTH_PREFIX + 1]
+                    while prefix and prefix[-1] != "/":
+                        prefix = prefix[:-1]
+
+                    name = name[len(prefix):]
                     prefix = prefix[:-1]
 
-                name = name[len(prefix):]
-                prefix = prefix[:-1]
-
-                if not prefix or len(name) > tarfile.LENGTH_NAME:
-                    raise ValueError("name is too long")
-
-        else:
-            if len(self.linkname) > tarfile.LENGTH_LINK:
-                buf += self._create_gnulong(self.linkname,
-                                            tarfile.GNUTYPE_LONGLINK)
-
-            if len(name) > tarfile.LENGTH_NAME:
-                buf += self._create_gnulong(name, tarfile.GNUTYPE_LONGNAME)
-
-        parts = [
-            tarfile.stn(name, 100),
-            tarfile.itn(self.mode & 07777, 8, posix),
-            tarfile.itn(self.uid, 8, posix),
-            tarfile.itn(self.gid, 8, posix),
-            tarfile.itn(self.size, 12, posix),
-            tarfile.itn(self.mtime, 12, posix),
-            "        ", # checksum field
-            type,
-            tarfile.stn(self.linkname, 100),
-            tarfile.stn(tarfile.MAGIC, 6),
-            tarfile.stn(tarfile.VERSION, 2),
-            tarfile.stn(self.uname, 32),
-            tarfile.stn(self.gname, 32),
-            tarfile.itn(self.devmajor, 8, posix),
-            tarfile.itn(self.devminor, 8, posix),
-            tarfile.stn(prefix, 155)
-        ]
-
-        buf += "".join(parts).ljust(tarfile.BLOCKSIZE, tarfile.NUL)
-        chksum = tarfile.calc_chksums(buf[-tarfile.BLOCKSIZE:])[0]
-        buf = buf[:-364] + "%06o\0" % chksum + buf[-357:]
-        self.buf = buf
-        return buf
+                    if not prefix or len(name) > tarfile.LENGTH_NAME:
+                        raise ValueError("name is too long")
+
+            else:
+                if len(self.linkname) > tarfile.LENGTH_LINK:
+                    buf += self._create_gnulong(self.linkname,
+                                                tarfile.GNUTYPE_LONGLINK)
+
+                if len(name) > tarfile.LENGTH_NAME:
+                    buf += self._create_gnulong(name, tarfile.GNUTYPE_LONGNAME)
+
+            parts = [
+                tarfile.stn(name, 100),
+                tarfile.itn(self.mode & 07777, 8, posix),
+                tarfile.itn(self.uid, 8, posix),
+                tarfile.itn(self.gid, 8, posix),
+                tarfile.itn(self.size, 12, posix),
+                tarfile.itn(self.mtime, 12, posix),
+                "        ", # checksum field
+                type,
+                tarfile.stn(self.linkname, 100),
+                tarfile.stn(tarfile.MAGIC, 6),
+                tarfile.stn(tarfile.VERSION, 2),
+                tarfile.stn(self.uname, 32),
+                tarfile.stn(self.gname, 32),
+                tarfile.itn(self.devmajor, 8, posix),
+                tarfile.itn(self.devminor, 8, posix),
+                tarfile.stn(prefix, 155)
+            ]
+
+            buf += "".join(parts).ljust(tarfile.BLOCKSIZE, tarfile.NUL)
+            chksum = tarfile.calc_chksums(buf[-tarfile.BLOCKSIZE:])[0]
+            buf = buf[:-364] + "%06o\0" % chksum + buf[-357:]
+            self.buf = buf
+            return buf
 
 # vim: sw=2 sts=2 ts=2 
 

=== removed file 'tests/test_version.py'
--- a/tests/test_version.py	2008-03-05 17:00:51 +0000
+++ b/tests/test_version.py	1970-01-01 00:00:00 +0000
@@ -1,33 +0,0 @@
-#    test_version.py -- Testsuite for builddeb version
-#    Copyright (C) 2007 James Westby <jw+debian at jameswestby.net>
-#    
-#    This file is part of bzr-builddeb.
-#
-#    bzr-builddeb is free software; you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation; either version 2 of the License, or
-#    (at your option) any later version.
-#
-#    bzr-builddeb is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with bzr-builddeb; if not, write to the Free Software
-#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-#
-
-from bzrlib.plugins.builddeb import version
-
-import bzrlib
-from bzrlib.tests import TestCase, KnownFailure
-
-class VersionTests(TestCase):
-
-  def test_version_matches(self):
-    """An abused test case to warn when the version doesn't match bzrlib."""
-    if version.version_info != bzrlib.version_info:
-      raise KnownFailure("builddeb version doesn't match bzrlib version")
-
-# vim: ts=2 sts=2 sw=2



More information about the Pkg-bazaar-commits mailing list