Rev 5726: Force test_tar_export to test that it outputs in binary. in http://bzr.arbash-meinel.com/branches/bzr/jam-integration

John Arbash Meinel john at arbash-meinel.com
Tue Mar 15 16:01:28 UTC 2011


At http://bzr.arbash-meinel.com/branches/bzr/jam-integration

------------------------------------------------------------
revno: 5726
revision-id: john at arbash-meinel.com-20110315160126-dh4dptdoutt235nk
parent: john at arbash-meinel.com-20110315102820-51wy8wjre5ol34mu
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: jam-integration
timestamp: Tue 2011-03-15 17:01:26 +0100
message:
  Force test_tar_export to test that it outputs in binary.
-------------- next part --------------
=== modified file 'bzrlib/tests/blackbox/test_export.py'
--- a/bzrlib/tests/blackbox/test_export.py	2011-03-14 23:18:48 +0000
+++ b/bzrlib/tests/blackbox/test_export.py	2011-03-15 16:01:26 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2010 Canonical Ltd
+# Copyright (C) 2005-2011 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,6 +29,7 @@
 
 from bzrlib import (
     export,
+    osutils,
     tests,
     )
 from bzrlib.tests import TestCaseWithTransport
@@ -38,8 +39,11 @@
 
     def test_tar_export(self):
         tree = self.make_branch_and_tree('tar')
-        self.build_tree(['tar/a'])
-        tree.add('a')
+        # On Windows, if we fail to set the binary bit, and a '\r' or '\n'
+        # ends up in the data stream, we will get corruption. Add a fair amount
+        # of random data, to help ensure there is at least one.
+        self.build_tree_contents([('tar/a', osutils.rand_chars(65536))])
+        tree.add(['a'])
         self.build_tree_contents([('tar/.bzrrules', '')])
         tree.add('.bzrrules')
         self.build_tree(['tar/.bzr-adir/', 'tar/.bzr-adir/afile'])
@@ -57,14 +61,16 @@
         ball = tarfile.open('test.tar.gz')
         # Make sure the tarball contains 'a', but does not contain
         # '.bzrignore'.
-        self.assertEqual(['test/a'], sorted(ball.getnames()))
+        self.assertEqual(['test/a'],
+                         sorted(ball.getnames()))
 
         if sys.version_info < (2, 5, 2) and sys.platform == 'darwin':
             raise tests.KnownFailure('python %r has a tar related bug, upgrade'
                                      % (sys.version_info,))
         out, err = self.run_bzr('export --format=tgz --root=test -')
         ball = tarfile.open('', fileobj=StringIO(out))
-        self.assertEqual(['test/a'], sorted(ball.getnames()))
+        self.assertEqual(['test/a'],
+                         sorted(ball.getnames()))
 
     def test_tar_export_unicode(self):
         self.requireFeature(tests.UnicodeFilenameFeature)



More information about the bazaar-commits mailing list