[Lldb-commits] [PATCH] D112706: [lldb/test] Allow indentation in inline tests

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 28 05:39:20 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG349295fcf37e: [lldb/test] Allow indentation in inline tests (authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D112706?vs=382991&id=383000#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112706/new/

https://reviews.llvm.org/D112706

Files:
  lldb/packages/Python/lldbsuite/test/lldbinline.py
  lldb/test/API/test_utils/TestInlineTest.py


Index: lldb/test/API/test_utils/TestInlineTest.py
===================================================================
--- /dev/null
+++ lldb/test/API/test_utils/TestInlineTest.py
@@ -0,0 +1,33 @@
+from lldbsuite.test.lldbinline import CommandParser
+from lldbsuite.test.lldbtest import Base
+import textwrap
+
+
+class TestCommandParser(Base):
+
+    mydir = Base.compute_mydir(__file__)
+
+    def test_indentation(self):
+        """Test indentation handling"""
+        filename = self.getBuildArtifact("test_file.cpp")
+        with open(filename, "w") as f:
+            f.write(textwrap.dedent("""\
+                    int q;
+                    int w; //% first break
+                    int e;
+                    int r; //% second break
+                    //% continue second
+                    //%   continuing indented
+                      //% not indented
+                    int t; //% third break
+                    """))
+        p = CommandParser()
+        p.parse_source_files([filename])
+
+        def bkpt(line, cmd):
+            return {'file_name': filename, 'line_number': line, 'command': cmd}
+        self.assertEqual(
+            p.breakpoints, [
+                bkpt(2, 'first break'),
+                bkpt(4, 'second break\ncontinue second\n  continuing indented\nnot indented'),
+                bkpt(8, "third break")])
Index: lldb/packages/Python/lldbsuite/test/lldbinline.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbinline.py
+++ lldb/packages/Python/lldbsuite/test/lldbinline.py
@@ -3,6 +3,7 @@
 
 # System modules
 import os
+import textwrap
 
 # Third-party modules
 import io
@@ -38,7 +39,7 @@
         new_breakpoint = True
 
         if len(parts) == 2:
-            command = parts[1].strip()  # take off whitespace
+            command = parts[1].rstrip()
             new_breakpoint = parts[0].strip() != ""
 
         return (command, new_breakpoint)
@@ -68,6 +69,8 @@
                     else:
                         current_breakpoint['command'] = current_breakpoint[
                             'command'] + "\n" + command
+        for bkpt in self.breakpoints:
+            bkpt['command'] = textwrap.dedent(bkpt['command'])
 
     def set_breakpoints(self, target):
         for breakpoint in self.breakpoints:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112706.383000.patch
Type: text/x-patch
Size: 2352 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211028/f631b2da/attachment-0001.bin>


More information about the lldb-commits mailing list