Rev 2570: Take Martin and Robert comments into account. in file:///v/home/vila/src/bugs/102019/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Jul 3 10:29:01 BST 2007


At file:///v/home/vila/src/bugs/102019/

------------------------------------------------------------
revno: 2570
revision-id: v.ladeuil+lp at free.fr-20070703092859-yl7j53209tfmhf7u
parent: v.ladeuil+lp at free.fr-20070702152123-hkfs15u2m87nxrcf
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 102019
timestamp: Tue 2007-07-03 11:28:59 +0200
message:
  Take Martin and Robert comments into account.
  
  * bzrlib/strace.py:
  (strace): is now a wrapper that calls strace_detailed.
  (strace_detailed): like strace before but with an option to
  disable following forked children without polluting the kwargs
  param.
  
  * bzrlib/tests/test_strace.py:
  (TestStrace.test_strace_callable_is_called,
  TestStrace.test_strace_callable_result,
  TestStrace.test_strace_result_has_raw_log): use strace_detailed
  while disabling following forked children, the syntax is a bit
  uglier but non-test users should never use anyway..
modified:
  bzrlib/strace.py               strace.py-20070323001526-6zquhhw8leb9m6j8-1
  bzrlib/tests/test_strace.py    test_strace.py-20070323001526-6zquhhw8leb9m6j8-2
-------------- next part --------------
=== modified file 'bzrlib/strace.py'
--- a/bzrlib/strace.py	2007-07-02 14:09:40 +0000
+++ b/bzrlib/strace.py	2007-07-03 09:28:59 +0000
@@ -33,16 +33,16 @@
 
     :return: a tuple: function-result, a StraceResult.
     """
+    return strace_detailed(function, args, kwargs)
+
+
+def strace_detailed(function, args, kwargs, follow_children=True):
     # FIXME: strace is buggy
     # (https://bugs.launchpad.net/ubuntu/+source/strace/+bug/103133) and the
     # test suite hangs if the '-f' is given to strace *and* more than one
-    # thread is running. The following allows the test suite to disable fork
-    # following to work around the bug.  It's a bit dirty to pollute the kwargs
-    # so we take a likely-to-be-unique name to avoid conflicts (*args and
-    # *kwargs are related to 'function'). It's also ugly, but the best
-    # alternative I can think of is to declare another function, which is ugly
-    # too.
-    follow_children = kwargs.pop('strace_follow_children', True)
+    # thread is running. Using follow_children=False allows the test suite to
+    # disable fork following to work around the bug.
+
     # capture strace output to a file
     log_file = tempfile.NamedTemporaryFile()
     log_file_fd = log_file.fileno()

=== modified file 'bzrlib/tests/test_strace.py'
--- a/bzrlib/tests/test_strace.py	2007-07-02 15:21:23 +0000
+++ b/bzrlib/tests/test_strace.py	2007-07-03 09:28:59 +0000
@@ -20,7 +20,7 @@
 import errno
 import subprocess
 
-from bzrlib.strace import StraceFeature, strace, StraceResult
+from bzrlib.strace import StraceFeature, strace_detailed, StraceResult
 from bzrlib.tests import TestCaseWithTransport
 
 
@@ -51,15 +51,15 @@
         output = []
         def function(positional, *args, **kwargs):
             output.append((positional, args, kwargs))
-        strace(function, "a", "b", c="c",
-               strace_follow_children=False)
+        strace_detailed(function, ["a", "b"], {"c": "c"},
+                        follow_children=False)
         self.assertEqual([("a", ("b",), {"c":"c"})], output)
 
     def test_strace_callable_result(self):
         def function():
             return "foo"
-        result, strace_result = strace(function,
-                                       strace_follow_children=False)
+        result, strace_result = strace_detailed(function,[], {},
+                                                follow_children=False)
         self.assertEqual("foo", result)
         self.assertIsInstance(strace_result, StraceResult)
 
@@ -67,5 +67,6 @@
         """Checks that a reasonable raw strace log was found by strace."""
         def function():
             self.build_tree(['myfile'])
-        unused, result = strace(function, strace_follow_children=False)
+        unused, result = strace_detailed(function, [], {},
+                                         follow_children=False)
         self.assertContainsRe(result.raw_log, 'myfile')



More information about the bazaar-commits mailing list