Author: David Spickett
Date: 2026-01-29T10:03:13Z
New Revision: 12dd34260eccf4937a4a66cad5702f74f8777b47

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

LOG: [lldb][test] Add tests for formatting of command option descriptions 
(#178235)

These test the existing behaviour before I work on #177570.
    
I chose "breakpoint set" because it has options with ANSI underlines
in the description.
    
The tests cover no ANSI (use-colour off) and with ANSI (use-color on).
The latter is where we have problems right now.

Added: 
    

Modified: 
    lldb/test/API/commands/help/TestHelp.py

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/commands/help/TestHelp.py 
b/lldb/test/API/commands/help/TestHelp.py
index d03924ecf8b27..15cb07b1f32e6 100644
--- a/lldb/test/API/commands/help/TestHelp.py
+++ b/lldb/test/API/commands/help/TestHelp.py
@@ -296,6 +296,62 @@ def test_help_option_group_format_options_usage(self):
             ],
         )
 
+    @no_debug_info_test
+    def test_help_option_description_terminal_width_no_ansi(self):
+        """Test that help on commands formats option descriptions acccording
+        to the terminal width."""
+        # Should fit on one line.
+        self.runCmd("settings set term-width 138")
+        self.expect(
+            "help breakpoint set",
+            matching=True,
+            patterns=[
+                r"\s+Set the breakpoint only in this shared library.  Can 
repeat this option multiple times to specify multiple shared libraries.\n"
+            ],
+        )
+
+        # Must be printed on two lines.
+        self.runCmd("settings set term-width 100")
+        self.expect(
+            "help breakpoint set",
+            matching=True,
+            patterns=[
+                r"\s+Set the breakpoint only in this shared library.  Can 
repeat this option multiple times\n"
+                r"\s+to specify multiple shared libraries.\n"
+            ],
+        )
+
+    @no_debug_info_test
+    def test_help_option_description_terminal_width_with_ansi(self):
+        """Test that help on commands formats option descriptions that include
+        ANSI codes acccording to the terminal width."""
+        self.runCmd("settings set use-color on")
+
+        # FIXME: lldb crashes when the width is exactly 135 - 
https://github.com/llvm/llvm-project/issues/177570
+
+        # Should fit on one line.
+        self.runCmd("settings set term-width 138")
+        self.expect(
+            "help breakpoint set",
+            matching=True,
+            patterns=[
+                # The "S" of "Set" is underlined.
+                r"\s+\x1b\[4mS\x1b\[0met the breakpoint only in this shared 
library.  Can repeat this option multiple times to specify multiple shared 
libraries.\n"
+            ],
+        )
+
+        # Must be printed on two lines.
+        # FIXME: Second line is truncated - 
https://github.com/llvm/llvm-project/issues/177570
+        self.runCmd("settings set term-width 100")
+        self.expect(
+            "help breakpoint set",
+            matching=True,
+            patterns=[
+                r"\s+\x1b\[4mS\x1b\[0met the breakpoint only in this shared 
library.  Can repeat this option\n"
+                r"\s+multiple times to specify multiple shared li\n"
+            ],
+        )
+
     @no_debug_info_test
     def test_help_shows_optional_short_options(self):
         """Test that optional short options are printed and that they are in


        
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to