~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_strace.py

  • Committer: Vincent Ladeuil
  • Date: 2007-07-03 09:28:59 UTC
  • mto: (2584.1.1 Aaron's integration)
  • mto: This revision was merged to the branch mainline in revision 2585.
  • Revision ID: v.ladeuil+lp@free.fr-20070703092859-yl7j53209tfmhf7u
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..

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import errno
21
21
import subprocess
22
22
 
23
 
from bzrlib.strace import StraceFeature, strace, StraceResult
 
23
from bzrlib.strace import StraceFeature, strace_detailed, StraceResult
24
24
from bzrlib.tests import TestCaseWithTransport
25
25
 
26
26
 
51
51
        output = []
52
52
        def function(positional, *args, **kwargs):
53
53
            output.append((positional, args, kwargs))
54
 
        strace(function, "a", "b", c="c",
55
 
               strace_follow_children=False)
 
54
        strace_detailed(function, ["a", "b"], {"c": "c"},
 
55
                        follow_children=False)
56
56
        self.assertEqual([("a", ("b",), {"c":"c"})], output)
57
57
 
58
58
    def test_strace_callable_result(self):
59
59
        def function():
60
60
            return "foo"
61
 
        result, strace_result = strace(function,
62
 
                                       strace_follow_children=False)
 
61
        result, strace_result = strace_detailed(function,[], {},
 
62
                                                follow_children=False)
63
63
        self.assertEqual("foo", result)
64
64
        self.assertIsInstance(strace_result, StraceResult)
65
65
 
67
67
        """Checks that a reasonable raw strace log was found by strace."""
68
68
        def function():
69
69
            self.build_tree(['myfile'])
70
 
        unused, result = strace(function, strace_follow_children=False)
 
70
        unused, result = strace_detailed(function, [], {},
 
71
                                         follow_children=False)
71
72
        self.assertContainsRe(result.raw_log, 'myfile')