Rev 2376: Review feedback. in file:///home/robertc/source/baz/benchmark-strace/
Robert Collins
robertc at robertcollins.net
Tue Mar 27 08:37:15 BST 2007
At file:///home/robertc/source/baz/benchmark-strace/
------------------------------------------------------------
revno: 2376
revision-id: robertc at robertcollins.net-20070327073712-6v27yeyl9unj6p9o
parent: robertc at robertcollins.net-20070327070732-jrx0o1jgqond0xpb
committer: Robert Collins <robertc at robertcollins.net>
branch nick: benchmark-strace
timestamp: Tue 2007-03-27 17:37:12 +1000
message:
Review feedback.
modified:
bzrlib/strace.py strace.py-20070323001526-6zquhhw8leb9m6j8-1
bzrlib/tests/test_strace.py test_strace.py-20070323001526-6zquhhw8leb9m6j8-2
=== modified file 'bzrlib/strace.py'
--- a/bzrlib/strace.py 2007-03-23 00:18:31 +0000
+++ b/bzrlib/strace.py 2007-03-27 07:37:12 +0000
@@ -26,10 +26,11 @@
# want to move feature to its own module though.
from bzrlib.tests import Feature
+
def strace(function, *args, **kwargs):
"""Invoke strace on function.
- :return: A StraceResult.
+ :return: a tuple: function-result, a StraceResult.
"""
# capture strace output to a file
log_file = tempfile.TemporaryFile()
@@ -43,7 +44,7 @@
stdout=log_file_fd)
# TODO? confirm its started (test suite should be sufficient)
# (can loop on proc.pid, but that may not indicate started and attached.)
- function(*args, **kwargs)
+ result = function(*args, **kwargs)
# stop strace
os.kill(proc.pid, signal.SIGQUIT)
proc.communicate()
@@ -51,7 +52,7 @@
log_file.seek(0)
log = log_file.read()
log_file.close()
- return StraceResult(log)
+ return result, StraceResult(log)
class StraceResult(object):
=== modified file 'bzrlib/tests/test_strace.py'
--- a/bzrlib/tests/test_strace.py 2007-03-23 00:18:31 +0000
+++ b/bzrlib/tests/test_strace.py 2007-03-27 07:37:12 +0000
@@ -53,15 +53,16 @@
strace(function, "a", "b", c="c")
self.assertEqual([("a", ("b",), {"c":"c"})], output)
- def test_strace_callable_gets_StraceResult(self):
+ def test_strace_callable_result(self):
def function():
- pass
- result = strace(function)
- self.assertIsInstance(result, StraceResult)
+ return "foo"
+ result, strace_result = strace(function)
+ self.assertEqual("foo", result)
+ self.assertIsInstance(strace_result, StraceResult)
def test_strace_result_has_raw_log(self):
"""Checks that a reasonable raw strace log was found by strace."""
def function():
self.build_tree(['myfile'])
- result = strace(function)
+ _, result = strace(function)
self.assertContainsRe(result.raw_log, 'myfile')
More information about the bazaar-commits
mailing list