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)


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to