/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_strace.py

  • Committer: John Arbash Meinel
  • Date: 2007-11-30 23:18:15 UTC
  • mto: This revision was merged to the branch mainline in revision 3072.
  • Revision ID: john@arbash-meinel.com-20071130231815-0r6ce70307kmv28r
Use a Graph.heads() check to determine if the ancestries are compatible.
Whether we should do nothing because source is already ahead,
raise an exception because we have diverged,
or move forward because the new revision is a tip revision.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
18
"""Tests for the strace-invoking support."""
19
19
 
20
20
import errno
21
21
import subprocess
22
 
import threading
23
22
 
24
 
from bzrlib import (
25
 
    tests,
26
 
    )
27
23
from bzrlib.strace import StraceFeature, strace_detailed, StraceResult
28
 
 
29
 
 
30
 
class TestStraceFeature(tests.TestCaseWithTransport):
 
24
from bzrlib.tests import TestCaseWithTransport
 
25
 
 
26
 
 
27
class TestStraceFeature(TestCaseWithTransport):
31
28
 
32
29
    def test_strace_detection(self):
33
30
        """Strace is available if its runnable."""
46
43
        self.assertEqual(found_strace, StraceFeature.available())
47
44
 
48
45
 
49
 
class TestStrace(tests.TestCaseWithTransport):
 
46
class TestStrace(TestCaseWithTransport):
50
47
 
51
48
    _test_needs_features = [StraceFeature]
52
49
 
53
 
    def _check_threads(self):
54
 
        # For bug #226769, it was decided that the strace tests should not be
55
 
        # run when more than one thread is active. A lot of tests are currently
56
 
        # leaking threads for good or bad reasons, once they are fixed or
57
 
        # strace itself is fixed (bug #103133), we can get rid of the
58
 
        # restriction.
59
 
        active = threading.activeCount()
60
 
        if active > 1: # There is always the main thread at least
61
 
            raise tests.KnownFailure(
62
 
                '%d active threads, bug #103133 needs to be fixed.' % active)
63
 
 
64
50
    def test_strace_callable_is_called(self):
65
 
        self._check_threads()
66
 
 
67
51
        output = []
68
52
        def function(positional, *args, **kwargs):
69
53
            output.append((positional, args, kwargs))
72
56
        self.assertEqual([("a", ("b",), {"c":"c"})], output)
73
57
 
74
58
    def test_strace_callable_result(self):
75
 
        self._check_threads()
76
 
 
77
59
        def function():
78
60
            return "foo"
79
61
        result, strace_result = strace_detailed(function,[], {},
83
65
 
84
66
    def test_strace_result_has_raw_log(self):
85
67
        """Checks that a reasonable raw strace log was found by strace."""
86
 
        self._check_threads()
87
 
 
88
68
        def function():
89
69
            self.build_tree(['myfile'])
90
70
        unused, result = strace_detailed(function, [], {},