DavidSpickett created this revision.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This adds a few targeted tests to make sure that when refactoring
this function later I don't break these properties.

Some are tested in passing elsewhere but this makes it more
obvious what went wrong when it fails.

This doesn't cover everything the function does, I couldn't
find any examples that would exercise some of the code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123500

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


Index: lldb/test/API/commands/help/TestHelp.py
===================================================================
--- lldb/test/API/commands/help/TestHelp.py
+++ lldb/test/API/commands/help/TestHelp.py
@@ -243,3 +243,30 @@
                 "-f <format> ( --format <format> )", "The format to use for 
each of the value to be written.",
                 "-s <byte-size> ( --size <byte-size> )", "The size in bytes to 
write from input file or each value."])
 
+    @no_debug_info_test
+    def test_help_shows_optional_short_options(self):
+        """Test that optional short options are printed and that they are in
+           alphabetical order with upper case options first."""
+        self.expect("help memory read",
+                    substrs=["memory read [-br]", "memory read [-AFLORTr]"])
+
+    @no_debug_info_test
+    def test_help_shows_command_options_usage(self):
+        """Test that we start the usage section with a specific line."""
+        self.expect("help memory read", substrs=["Command Options Usage:\n  
memory read"])
+
+    @no_debug_info_test
+    def test_help_detailed_information_spacing(self):
+        """Test that we put a break between the usage and the options help 
lines,
+           and between the options themselves."""
+        self.expect("help memory read", substrs=[
+                    "[<address-expression>]\n\n       --show-tags",
+                    # Starts with the end of the show-tags line
+                    "output).\n\n       -A"])
+
+    @no_debug_info_test
+    def test_help_detailed_information_ordering(self):
+        """Test that we order options alphabetically, upper case first."""
+        self.expect("help memory read", patterns=[
+            "(?s)\-L \( \-\-location \).*\-T \( \-\-show\-types \).*"
+                "\-b \( \-\-binary \).*\-r \( \-\-force \)"])
\ No newline at end of file


Index: lldb/test/API/commands/help/TestHelp.py
===================================================================
--- lldb/test/API/commands/help/TestHelp.py
+++ lldb/test/API/commands/help/TestHelp.py
@@ -243,3 +243,30 @@
                 "-f <format> ( --format <format> )", "The format to use for each of the value to be written.",
                 "-s <byte-size> ( --size <byte-size> )", "The size in bytes to write from input file or each value."])
 
+    @no_debug_info_test
+    def test_help_shows_optional_short_options(self):
+        """Test that optional short options are printed and that they are in
+           alphabetical order with upper case options first."""
+        self.expect("help memory read",
+                    substrs=["memory read [-br]", "memory read [-AFLORTr]"])
+
+    @no_debug_info_test
+    def test_help_shows_command_options_usage(self):
+        """Test that we start the usage section with a specific line."""
+        self.expect("help memory read", substrs=["Command Options Usage:\n  memory read"])
+
+    @no_debug_info_test
+    def test_help_detailed_information_spacing(self):
+        """Test that we put a break between the usage and the options help lines,
+           and between the options themselves."""
+        self.expect("help memory read", substrs=[
+                    "[<address-expression>]\n\n       --show-tags",
+                    # Starts with the end of the show-tags line
+                    "output).\n\n       -A"])
+
+    @no_debug_info_test
+    def test_help_detailed_information_ordering(self):
+        """Test that we order options alphabetically, upper case first."""
+        self.expect("help memory read", patterns=[
+            "(?s)\-L \( \-\-location \).*\-T \( \-\-show\-types \).*"
+                "\-b \( \-\-binary \).*\-r \( \-\-force \)"])
\ No newline at end of file
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to