~ubuntu-branches/ubuntu/natty/bzr/natty-proposed

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_crash.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2010-08-07 00:54:52 UTC
  • mfrom: (1.4.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100807005452-g4zb99ezl3xn44r4
Tags: 2.2.0-1
* New upstream release.
 + Adds support for setting timestamps to originating revisions.
   Closes: #473450
 + Removes remaining string exception. Closes: #585193, LP: #586926
 + Add C extension to work around Python issue 1628205. LP: #583941,
   Closes: #577110
 + Avoids showing progress bars when --quiet is used. Closes: #542105,
   LP: #320035
 + No longer creates ~/.bazaar as root when run under sudo. LP: #376388
 + 'bzr commit' now supports -p as alternative for --show-diff. LP: #571467
 + 'bzr add' no longer adds .THIS/.BASE/.THEIRS files unless
   explicitly requested. LP: #322767
 + When parsing patch files, Bazaar now supports diff lines before each
   patch. LP: #502076
 + WorkingTrees now no longer requires using signal.signal, so can
   be used in a threaded environment. LP: #521989
 + An assertion error is no longer triggered when pushing to a pre-1.6
   Bazaar server. LP: #528041
* Bump standards version to 3.9.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from StringIO import StringIO
19
19
import sys
20
20
 
 
21
 
 
22
import os
 
23
 
 
24
 
21
25
from bzrlib import (
 
26
    config,
22
27
    crash,
 
28
    osutils,
 
29
    symbol_versioning,
23
30
    tests,
24
31
    )
25
32
 
26
33
from bzrlib.tests import features
27
34
 
28
35
 
29
 
class TestApportReporting(tests.TestCase):
 
36
class TestApportReporting(tests.TestCaseInTempDir):
30
37
 
31
38
    _test_needs_features = [features.apport]
32
39
 
33
 
    def test_apport_report_contents(self):
 
40
    def test_apport_report(self):
 
41
        crash_dir = osutils.joinpath((self.test_base_dir, 'crash'))
 
42
        os.mkdir(crash_dir)
 
43
        os.environ['APPORT_CRASH_DIR'] = crash_dir
 
44
        self.assertEquals(crash_dir, config.crash_dir())
 
45
 
 
46
        stderr = StringIO()
 
47
 
34
48
        try:
35
49
            raise AssertionError("my error")
36
50
        except AssertionError, e:
37
51
            pass
38
 
        outf = StringIO()
39
 
        crash._write_apport_report_to_file(sys.exc_info(), outf)
40
 
        report = outf.getvalue()
41
 
 
42
 
        self.assertContainsRe(report, '(?m)^BzrVersion:')
43
 
        # should be in the traceback
 
52
 
 
53
        crash_filename = crash.report_bug_to_apport(sys.exc_info(),
 
54
            stderr)
 
55
 
 
56
        # message explaining the crash
 
57
        self.assertContainsRe(stderr.getvalue(),
 
58
            "    apport-bug %s" % crash_filename)
 
59
 
 
60
        crash_file = open(crash_filename)
 
61
        try:
 
62
            report = crash_file.read()
 
63
        finally:
 
64
            crash_file.close()
 
65
 
 
66
        self.assertContainsRe(report,
 
67
            '(?m)^BzrVersion:') # should be in the traceback
44
68
        self.assertContainsRe(report, 'my error')
45
69
        self.assertContainsRe(report, 'AssertionError')
46
 
        self.assertContainsRe(report, 'test_apport_report_contents')
 
70
        # see https://bugs.launchpad.net/bzr/+bug/528114
 
71
        self.assertContainsRe(report, 'ExecutablePath')
 
72
        self.assertContainsRe(report, 'test_apport_report')
47
73
        # should also be in there
48
74
        self.assertContainsRe(report, '(?m)^CommandLine:')