From d950fa7165de671258c8aa3aff396214fdf80014 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Fri, 17 Oct 2014 00:39:37 +0000 Subject: [PATCH] Made multi-line test case actions possible in the inline test cases. This makes them much more readable. llvm-svn: 220001 --- lldb/test/lang/c/struct_types/main.c | 7 +++++-- lldb/test/lldbinline.py | 34 ++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/lldb/test/lang/c/struct_types/main.c b/lldb/test/lang/c/struct_types/main.c index a4051a0..1ea1ba9 100644 --- a/lldb/test/lang/c/struct_types/main.c +++ b/lldb/test/lang/c/struct_types/main.c @@ -12,13 +12,16 @@ int main (int argc, char const *argv[]) int x; int y; char padding[0]; - }; //% self.expect("frame variable pt.padding[0]", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["pt.padding[0] = "]); self.expect("frame variable pt.padding[1]", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["pt.padding[1] = "]); self.expect("expression -- (pt.padding[0])", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["(char)", " = "]); self.expect("image lookup -t point_tag", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ['padding[]']) # Once rdar://problem/12566646 is fixed, this should display correctly + }; //% self.expect("frame variable pt.padding[0]", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["pt.padding[0] = "]) + //% self.expect("frame variable pt.padding[1]", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["pt.padding[1] = "]) + //% self.expect("expression -- (pt.padding[0])", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["(char)", " = "]) + //% self.expect("image lookup -t point_tag", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ['padding[]']) # Once rdar://problem/12566646 is fixed, this should display correctly struct rect_tag { struct point_tag bottom_left; struct point_tag top_right; }; - struct point_tag pt = { 2, 3, {} }; //% self. + struct point_tag pt = { 2, 3, {} }; struct rect_tag rect = {{1, 2, {}}, {3, 4, {}}}; return 0; //% self.expect("expression -- &pt == (struct point_tag*)0", substrs = ['false']) } diff --git a/lldb/test/lldbinline.py b/lldb/test/lldbinline.py index ad397b5..d832bde 100644 --- a/lldb/test/lldbinline.py +++ b/lldb/test/lldbinline.py @@ -21,25 +21,39 @@ class CommandParser: def parse_one_command(self, line): parts = line.split('//%') - if len(parts) != 2: - return None - else: - return parts[1].strip() # take off trailing whitespace + + command = None + new_breakpoint = True + + if len(parts) == 2: + command = parts[1].strip() # take off whitespace + new_breakpoint = parts[0].strip() != "" + + return (command, new_breakpoint) def parse_source_files(self, source_files): for source_file in source_files: file_handle = open(source_file) lines = file_handle.readlines() line_number = 0 + current_breakpoint = None # non-NULL means we're looking through whitespace to find additional commands for line in lines: line_number = line_number + 1 # 1-based, so we do this first - command = self.parse_one_command(line) + (command, new_breakpoint) = self.parse_one_command(line) + + if new_breakpoint: + current_breakpoint = None + if command != None: - breakpoint = {} - breakpoint['file_name'] = source_file - breakpoint['line_number'] = line_number - breakpoint['command'] = command - self.breakpoints.append(breakpoint) + if current_breakpoint == None: + current_breakpoint = {} + current_breakpoint['file_name'] = source_file + current_breakpoint['line_number'] = line_number + current_breakpoint['command'] = command + self.breakpoints.append(current_breakpoint) + else: + current_breakpoint['command'] = current_breakpoint['command'] + "\n" + command + print self.breakpoints def set_breakpoints(self, target): for breakpoint in self.breakpoints: -- 2.7.4