Fix wrong parsing of faulthandler logs.

This commit is contained in:
Florian Bruhin 2015-02-19 22:45:37 +01:00
parent a41331a402
commit 14f2420500
2 changed files with 15 additions and 1 deletions

View File

@ -60,7 +60,7 @@ def parse_fatal_stacktrace(text):
# We got some invalid text. # We got some invalid text.
return ('', '') return ('', '')
else: else:
return (m.group(1), m.group(2)) return (m.group(1), m.group(3))
def get_fatal_crash_dialog(debug, data): def get_fatal_crash_dialog(debug, data):

View File

@ -40,6 +40,13 @@ Current thread 0x00007f09b538d700 (most recent call first):
File "filename", line 88 in func File "filename", line 88 in func
""" """
VALID_CRASH_TEXT_THREAD = """
Fatal Python error: Segmentation fault
_
Thread 0x00007fa135ac7700 (most recent call first):
File "", line 1 in testfunc
"""
INVALID_CRASH_TEXT = """ INVALID_CRASH_TEXT = """
Hello world! Hello world!
""" """
@ -56,6 +63,13 @@ class ParseFatalStacktraceTests(unittest.TestCase):
self.assertEqual(typ, "Segmentation fault") self.assertEqual(typ, "Segmentation fault")
self.assertEqual(func, 'testfunc') self.assertEqual(func, 'testfunc')
def test_valid_text_thread(self):
"""Test parse_fatal_stacktrace with a valid text #2."""
text = VALID_CRASH_TEXT_THREAD.strip().replace('_', ' ')
typ, func = crashdialog.parse_fatal_stacktrace(text)
self.assertEqual(typ, "Segmentation fault")
self.assertEqual(func, 'testfunc')
def test_valid_text_empty(self): def test_valid_text_empty(self):
"""Test parse_fatal_stacktrace with a valid text but empty function.""" """Test parse_fatal_stacktrace with a valid text but empty function."""
text = VALID_CRASH_TEXT_EMPTY.strip().replace('_', ' ') text = VALID_CRASH_TEXT_EMPTY.strip().replace('_', ' ')