[Lldb-commits] [lldb] 349295f - [lldb/test] Allow indentation in inline tests
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 28 05:39:09 PDT 2021
Author: Pavel Labath
Date: 2021-10-28T14:39:02+02:00
New Revision: 349295fcf37ed1ff1ea98c18ea1b391741823916
URL: https://github.com/llvm/llvm-project/commit/349295fcf37ed1ff1ea98c18ea1b391741823916
DIFF: https://github.com/llvm/llvm-project/commit/349295fcf37ed1ff1ea98c18ea1b391741823916.diff
LOG: [lldb/test] Allow indentation in inline tests
This makes it possible to use for loops (and other language constructs)
in inline tests.
Differential Revision: https://reviews.llvm.org/D112706
Added:
lldb/test/API/test_utils/TestInlineTest.py
Modified:
lldb/packages/Python/lldbsuite/test/lldbinline.py
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/lldbinline.py b/lldb/packages/Python/lldbsuite/test/lldbinline.py
index 0d1cb24a54dfd..e8d4d4d62c1f6 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbinline.py
+++ b/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 @@ def parse_one_command(self, line):
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 @@ def parse_source_files(self, source_files):
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:
diff --git a/lldb/test/API/test_utils/TestInlineTest.py b/lldb/test/API/test_utils/TestInlineTest.py
new file mode 100644
index 0000000000000..21a3e2fd4bf2a
--- /dev/null
+++ b/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")])
More information about the lldb-commits
mailing list