[Lldb-commits] [lldb] r372052 - [test] Fail gracefully if the regex doesn't match

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 16 16:49:42 PDT 2019


Author: jdevlieghere
Date: Mon Sep 16 16:49:42 2019
New Revision: 372052

URL: http://llvm.org/viewvc/llvm-project?rev=372052&view=rev
Log:
[test] Fail gracefully if the regex doesn't match

This test is failing on the Fedora bot (staging). Rather than failing
with an IndexError, we should trigger an assert and dump the log when
the regex doesn't match.

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/api/log/TestAPILog.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/api/log/TestAPILog.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/log/TestAPILog.py?rev=372052&r1=372051&r2=372052&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/log/TestAPILog.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/log/TestAPILog.py Mon Sep 16 16:49:42 2019
@@ -34,15 +34,20 @@ class APILogTestCase(TestBase):
         with open(logfile, 'r') as f:
             log = f.read()
 
-        # Find the debugger addr.
+        # Find the SBDebugger's address.
         debugger_addr = re.findall(
             r"lldb::SBDebugger::GetScriptingLanguage\(const char \*\) \(0x([0-9a-fA-F]+),",
-            log)[0]
+            log)
 
-        get_scripting_language = 'lldb::SBDebugger::GetScriptingLanguage(const char *) (0x{}, "")'.format(
-            debugger_addr)
-        create_target = 'lldb::SBDebugger::CreateTarget(const char *) (0x{}, "")'.format(
-            debugger_addr)
+        # Make sure we've found a match.
+        self.assertTrue(debugger_addr, log)
 
+        # Make sure the GetScriptingLanguage matches.
+        get_scripting_language = 'lldb::SBDebugger::GetScriptingLanguage(const char *) (0x{}, "")'.format(
+            debugger_addr[0])
         self.assertTrue(get_scripting_language in log, log)
+
+        # Make sure the address matches.
+        create_target = 'lldb::SBDebugger::CreateTarget(const char *) (0x{}, "")'.format(
+            debugger_addr[0])
         self.assertTrue(create_target in log, log)




More information about the lldb-commits mailing list