Rev 4874: Now that we return files directly from the working tree in http://bazaar.launchpad.net/~jameinel/bzr/2.1.0b4-win32-diff-failure

John Arbash Meinel john at arbash-meinel.com
Tue Dec 8 21:37:53 GMT 2009


At http://bazaar.launchpad.net/~jameinel/bzr/2.1.0b4-win32-diff-failure

------------------------------------------------------------
revno: 4874
revision-id: john at arbash-meinel.com-20091208213736-vje7ublg3xzp1bs2
parent: pqm at pqm.ubuntu.com-20091207223256-9e6l1vc6h3jc2eqs
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1.0b4-win32-diff-failure
timestamp: Tue 2009-12-08 15:37:36 -0600
message:
  Now that we return files directly from the working tree
  the windows 'attrib' test needed to be updated.
  If we used the working tree for both old and new, then the test wasn't
  really testing what we expected, which was that the newly generated
  content was readable.
  
  But using basis_tree gets us that. Also, test that the content is
  properly marked as readonly, and that we have available content from
  the working tree.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_diff.py'
--- a/bzrlib/tests/test_diff.py	2009-12-01 11:08:28 +0000
+++ b/bzrlib/tests/test_diff.py	2009-12-08 21:37:36 +0000
@@ -1337,20 +1337,26 @@
         tree.commit('old tree')
         tree.lock_read()
         self.addCleanup(tree.unlock)
+        basis_tree = tree.basis_tree()
+        basis_tree.lock_read()
+        self.addCleanup(basis_tree.unlock)
         diff_obj = DiffFromTool(['python', '-c',
                                  'print "@old_path @new_path"'],
-                                tree, tree, output)
+                                basis_tree, tree, output)
         diff_obj._prepare_files('file-id', 'file', 'file')
-        self.assertReadableByAttrib(diff_obj._root, 'old\\file', r'old\\file')
-        self.assertReadableByAttrib(diff_obj._root, 'new\\file', r'new\\file')
+        # The old content should be readonly
+        self.assertReadableByAttrib(diff_obj._root, 'old\\file',
+                                    r'R.*old\\file$')
+        # The new content should use the tree object, not a 'new' file anymore
+        self.assertEndsWith(tree.basedir, 'work/tree')
+        self.assertReadableByAttrib(tree.basedir, 'file', r'work\\tree\\file$')
 
     def assertReadableByAttrib(self, cwd, relpath, regex):
         proc = subprocess.Popen(['attrib', relpath],
                                 stdout=subprocess.PIPE,
                                 cwd=cwd)
-        proc.wait()
-        result = proc.stdout.read()
-        self.assertContainsRe(result, regex)
+        (result, err) = proc.communicate()
+        self.assertContainsRe(result.replace('\r\n', '\n'), regex)
 
     def test_prepare_files(self):
         output = StringIO()



More information about the bazaar-commits mailing list