1
# Copyright (C) 2009, 2010, 2011 Canonical Ltd
1
# Copyright (C) 2009, 2010 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
18
from StringIO import StringIO
23
25
from bzrlib import (
38
40
def test_apport_report(self):
39
41
crash_dir = osutils.joinpath((self.test_base_dir, 'crash'))
40
42
os.mkdir(crash_dir)
41
self.overrideEnv('APPORT_CRASH_DIR', crash_dir)
43
os.environ['APPORT_CRASH_DIR'] = crash_dir
42
44
self.assertEquals(crash_dir, config.crash_dir())
47
{'example': ['Failed to load plugin foo']})
49
46
stderr = StringIO()
70
67
'(?m)^BzrVersion:') # should be in the traceback
71
68
self.assertContainsRe(report, 'my error')
72
69
self.assertContainsRe(report, 'AssertionError')
73
# see https://bugs.launchpad.net/bzr/+bug/528114
74
self.assertContainsRe(report, 'ExecutablePath')
75
70
self.assertContainsRe(report, 'test_apport_report')
76
71
# should also be in there
77
72
self.assertContainsRe(report, '(?m)^CommandLine:')
78
self.assertContainsRe(
80
'Failed to load plugin foo')
83
class TestNonApportReporting(tests.TestCase):
84
"""Reporting of crash-type bugs without apport.
86
This should work in all environments.
89
def setup_fake_plugins(self):
91
fake = plugin.PlugIn('fake_plugin', plugin)
92
fake.version_info = lambda: (1, 2, 3)
93
return {"fake_plugin": fake}
94
self.overrideAttr(plugin, 'plugins', fake_plugins)
96
def test_report_bug_legacy(self):
97
self.setup_fake_plugins()
100
raise AssertionError("my error")
101
except AssertionError, e:
103
crash.report_bug_legacy(sys.exc_info(), err_file)
104
report = err_file.getvalue()
106
"bzr: ERROR: exceptions.AssertionError: my error",
107
r"Traceback \(most recent call last\):",
108
r"plugins: fake_plugin\[1\.2\.3\]",
110
self.assertContainsRe(