File tree 2 files changed +37
-1
lines changed
packages/Python/lldbsuite/test
2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 3
3
4
4
# System modules
5
5
import os
6
+ import textwrap
6
7
7
8
# Third-party modules
8
9
import io
@@ -38,7 +39,7 @@ def parse_one_command(self, line):
38
39
new_breakpoint = True
39
40
40
41
if len (parts ) == 2 :
41
- command = parts [1 ].strip () # take off whitespace
42
+ command = parts [1 ].rstrip ()
42
43
new_breakpoint = parts [0 ].strip () != ""
43
44
44
45
return (command , new_breakpoint )
@@ -68,6 +69,8 @@ def parse_source_files(self, source_files):
68
69
else :
69
70
current_breakpoint ['command' ] = current_breakpoint [
70
71
'command' ] + "\n " + command
72
+ for bkpt in self .breakpoints :
73
+ bkpt ['command' ] = textwrap .dedent (bkpt ['command' ])
71
74
72
75
def set_breakpoints (self , target ):
73
76
for breakpoint in self .breakpoints :
Original file line number Diff line number Diff line change
1
+ from lldbsuite .test .lldbinline import CommandParser
2
+ from lldbsuite .test .lldbtest import Base
3
+ import textwrap
4
+
5
+
6
+ class TestCommandParser (Base ):
7
+
8
+ mydir = Base .compute_mydir (__file__ )
9
+
10
+ def test_indentation (self ):
11
+ """Test indentation handling"""
12
+ filename = self .getBuildArtifact ("test_file.cpp" )
13
+ with open (filename , "w" ) as f :
14
+ f .write (textwrap .dedent ("""\
15
+ int q;
16
+ int w; //% first break
17
+ int e;
18
+ int r; //% second break
19
+ //% continue second
20
+ //% continuing indented
21
+ //% not indented
22
+ int t; //% third break
23
+ """ ))
24
+ p = CommandParser ()
25
+ p .parse_source_files ([filename ])
26
+
27
+ def bkpt (line , cmd ):
28
+ return {'file_name' : filename , 'line_number' : line , 'command' : cmd }
29
+ self .assertEqual (
30
+ p .breakpoints , [
31
+ bkpt (2 , 'first break' ),
32
+ bkpt (4 , 'second break\n continue second\n continuing indented\n not indented' ),
33
+ bkpt (8 , "third break" )])
You can’t perform that action at this time.
0 commit comments