[Lldb-commits] [lldb] d71d1a9 - [lldb/Test] Add `use_colors` argument to the PExpect.launch wrapper

Med Ismail Bennani via lldb-commits lldb-commits at lists.llvm.org
Wed May 18 18:22:58 PDT 2022


Author: Med Ismail Bennani
Date: 2022-05-18T18:22:46-07:00
New Revision: d71d1a947bee1247e952f22c13ad3ed3d041e36a

URL: https://github.com/llvm/llvm-project/commit/d71d1a947bee1247e952f22c13ad3ed3d041e36a
DIFF: https://github.com/llvm/llvm-project/commit/d71d1a947bee1247e952f22c13ad3ed3d041e36a.diff

LOG: [lldb/Test] Add `use_colors` argument to the PExpect.launch wrapper

This patch adds a new `use_colors` argument to the PExpect.launch
method.

As the name suggests, it allows the user to conditionally enable color
support in the debugger, which can be helpful to test functionalities that
rely on that, like progress reporting. It defaults to False.

Differential Revision: https://reviews.llvm.org/D125915

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>

Added: 
    

Modified: 
    lldb/packages/Python/lldbsuite/test/lldbpexpect.py

Removed: 
    


################################################################################
diff  --git a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
index de8f819e2552a..fe44c86d14f2f 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
@@ -24,16 +24,20 @@ def expect_prompt(self):
         self.child.expect_exact(self.PROMPT)
 
     def launch(self, executable=None, extra_args=None, timeout=60,
-               dimensions=None, run_under=None, post_spawn=None):
+               dimensions=None, run_under=None, post_spawn=None,
+               use_colors=False):
         logfile = getattr(sys.stdout, 'buffer',
                             sys.stdout) if self.TraceOn() else None
 
         args = []
         if run_under is not None:
             args += run_under
-        args += [lldbtest_config.lldbExec, '--no-lldbinit', '--no-use-colors']
+        args += [lldbtest_config.lldbExec, '--no-lldbinit']
+        if not use_colors:
+            args += '--no-use-colors'
         for cmd in self.setUpCommands():
-            args += ['-O', cmd]
+            if use_colors and "use-color false" not in cmd:
+                args += ['-O', cmd]
         if executable is not None:
             args += ['--file', executable]
         if extra_args is not None:
@@ -54,8 +58,9 @@ def launch(self, executable=None, extra_args=None, timeout=60,
             post_spawn()
         self.expect_prompt()
         for cmd in self.setUpCommands():
-            self.child.expect_exact(cmd)
-            self.expect_prompt()
+            if use_colors and "use-color false" not in cmd:
+                self.child.expect_exact(cmd)
+                self.expect_prompt()
         if executable is not None:
             self.child.expect_exact("target create")
             self.child.expect_exact("Current executable set to")


        


More information about the lldb-commits mailing list