]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Sun Apr 29 03:28:44 BST 2012 david-sarah@jacaranda.org
authorDaira Hopwood <daira@jacaranda.org>
Thu, 5 Sep 2013 17:04:37 +0000 (18:04 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Thu, 5 Sep 2013 17:04:37 +0000 (18:04 +0100)
  * Make sure that foolscap.logging.log.setLogDir is called with a str (not unicode) path, v2. Includes test. fixes #1725

src/allmydata/node.py
src/allmydata/test/test_node.py

index eefce3d6a9d98ae50ec35b715bff52eef3bd987f..38cffe54549bfe56a4ef7073c4335d47564adf0a 100644 (file)
@@ -312,7 +312,7 @@ class Node(service.MultiService):
         self.tub.setOption("bridge-twisted-logs", True)
         incident_dir = os.path.join(self.basedir, "logs", "incidents")
         # this doesn't quite work yet: unit tests fail
-        foolscap.logging.log.setLogDir(incident_dir)
+        foolscap.logging.log.setLogDir(incident_dir.encode(get_filesystem_encoding()))
 
     def log(self, *args, **kwargs):
         return log.msg(*args, **kwargs)
index 24ec5714799d354c833cf03099231a55ab8dc88a..9d7a296f6452a269e87dd201854e880044b01ec4 100644 (file)
@@ -4,6 +4,8 @@ from twisted.trial import unittest
 from twisted.internet import defer
 from twisted.python import log
 
+from mock import patch
+
 from foolscap.api import flushEventualQueue
 from twisted.application import service
 from allmydata.node import Node, formatTimeTahoeStyle
@@ -101,3 +103,15 @@ class TestCase(testutil.SignalMixin, unittest.TestCase):
         st = os.stat(privdir)
         bits = stat.S_IMODE(st[stat.ST_MODE])
         self.failUnless(bits & 0001 == 0, bits)
+
+    @patch("foolscap.logging.log.setLogDir")
+    def test_logdir_is_str(self, mock_setLogDir):
+        basedir = "test_node/test_logdir_is_str"
+        fileutil.make_dirs(basedir)
+
+        def call_setLogDir(logdir):
+            self.failUnless(isinstance(logdir, str), logdir)
+        mock_setLogDir.side_effect = call_setLogDir
+
+        TestNode(basedir)
+        self.failUnless(mock_setLogDir.called)