Update tests following changes to "help" and "apropos"
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 3 Jun 2019 19:50:22 +0000 (21:50 +0200)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 3 Jun 2019 19:59:35 +0000 (21:59 +0200)
Factorizes the testing of the help output, by having a single place
that defines the common help trailer and/or prefix messages.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/help.exp
gdb/testsuite/gdb.base/style.exp
gdb/testsuite/gdb.guile/scm-cmd.exp
gdb/testsuite/gdb.python/py-cmd.exp
gdb/testsuite/gdb.trace/tracecmd.exp
gdb/testsuite/lib/gdb-utils.exp
gdb/testsuite/lib/gdb.exp

index 8d5f6bc63714efe8c05ef0b4f91ecabc00045e40..75f87f51b9b434bf99fb5ad0f537a44420f68305 100644 (file)
@@ -1,3 +1,18 @@
+2019-06-03  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
+
+       * lib/gdb.exp (help_list_trailer): New regexp variable
+       factorizing the help trailer message.
+       (test_class_help): Use help_list_trailer.  Add LIST_OF_COMMANDS
+       arg to allow to better factorize various tests.
+       (test_user_defined_class_help): Factorizes testing 'help user-defined'.
+       (test_prefix_command_help): Use help_list_trailer.
+       * gdb.python/py-cmd.exp: Use test_user_defined_class_help.
+       * gdb.guile/scm-cmd.exp: Likewise.
+       * gdb.trace/tracecmd.exp: Update caller of test_class_help.
+       * gdb.base/help.exp: Use test_user_defined_class_help.
+       * gdb.base/style.exp: Add tests for styling of help and apropos.
+       * lib/gdb-utils.exp (style): Add title and highlight styles.
+
 2019-05-31  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
        * gdb.base/shell.exp: Test pipe command, $_shell_exitcode,
index 511e7d6238574641d7c0f280cb65fce2d2a02009..e65f7c875f6908bf2b65469cdf007d5974690da1 100644 (file)
@@ -51,11 +51,8 @@ test_class_help "support" {"Support facilities\.\[\r\n\]+"}
 test_class_help "tracepoints" {
     "Tracing of program execution without stopping the program\.\[\r\n\]+"
 }
-test_class_help "user-defined" {
-    "User-defined commands\.\[\r\n\]+"
-    "The commands in this class are those defined by the user\.\[\r\n\]+"
-    "Use the \"define\" command to define a command\.\[\r\n\]+"
-}
+
+test_user_defined_class_help
 
 # Test help of an abbreviated command.  "break" is picked at random.
 set help_breakpoint_text "Set breakpoint at specified location\..*"
index 15de05cdafb68b5cccb27c69f6a7963a1e797bd0..a17f201486548e7883dd3f34150696b89077893d 100644 (file)
@@ -90,6 +90,39 @@ save_vars { env(TERM) } {
     gdb_test "" "${vers}.*" \
        "version is styled"
 
+    set address_style_expr [style "\"address\" style" address]
+    gdb_test "show style address foreground" \
+       "The ${address_style_expr} foreground color is: blue" \
+       "style name and style word styled using its own style in show style"
+
+    set aliases_expr [style "aliases" title]
+    set breakpoints_expr [style "breakpoints" title]
+    gdb_test "help" \
+       [multi_line \
+            "List of classes of commands:" \
+            "" \
+            "${aliases_expr} -- Aliases of other commands" \
+            "${breakpoints_expr} -- Making program stop at certain points" \
+            ".*" \
+           ] \
+       "help classes of commands styled with title"
+
+    set taas_expr  [style "taas" title]
+    set tfaas_expr  [style "tfaas" title]
+    set cut_for_thre_expr [style "cut for 'thre" highlight]
+    gdb_test "apropos -v cut for 'thre" \
+       [multi_line \
+            "" \
+            "${taas_expr} --.*" \
+            "Usage:.*" \
+            "short${cut_for_thre_expr}ad apply.*" \
+            "" \
+            "${tfaas_expr} --.*" \
+            "Usage:.*" \
+            "short${cut_for_thre_expr}ad apply.*" \
+           ] \
+       "apropos -v cut for 'thre"
+
     set quoted [string_to_regexp $binfile]
     gdb_test "file $binfile" \
        "Reading symbols from [style $quoted file]..." \
index 3f24df3c9e12a2f9cc983660925d84f85c98e0fa..518da660c2d56c89da64f795a75f89b3a002be7b 100644 (file)
@@ -130,9 +130,7 @@ gdb_test "test-help ugh" "test-cmd output, arg = ugh" \
     "call simple user-defined command"
 
 # Make sure the command shows up in `help user-defined`.
-gdb_test "help user-defined" \
-    "User-defined commands.\[\r\n\]+The commands in this class are those defined by the user.\[\r\n\]+Use the \"define\" command to define a command.\[\r\n\]+List of commands:\[\r\n\]+test-help -- Docstring\[\r\n\]+Type \"help\" followed by command name for full documentation.\[\r\n\]+Type \"apropos word\" to search for commands related to \"word\".\[\r\n\]+Command name abbreviations are allowed if unambiguous.\[\r\n\]+" \
-    "see user-defined command in `help user-defined`"
+test_user_defined_class_help {"test-help -- Docstring[\r\n]"}
 
 # Make sure the command does not show up in `show user`.
 gdb_test "show user test-help" "Not a user command\." \
index 9abdb0f39e9a40819017e3fb4caa15a39e7db5bd..c7c7b8c8998047c70ae8ea1e72fc938a123b368f 100644 (file)
@@ -159,7 +159,7 @@ gdb_py_test_multiple "input simple user-defined command" \
 gdb_test "test_help ugh" "test_cmd output, arg = ugh" "call simple user-defined command"
 
 # Make sure the command shows up in `help user-defined`.
-gdb_test "help user-defined" "User-defined commands.\[\r\n\]+The commands in this class are those defined by the user.\[\r\n\]+Use the \"define\" command to define a command.\[\r\n\]+\[\r\n\]+List of commands:\[\r\n\]+\[\r\n\]+test_help -- Docstring\[\r\n\]+\[\r\n\]+Type \"help\" followed by command name for full documentation.\[\r\n\]+Type \"apropos word\" to search for commands related to \"word\".\[\r\n\]+Command name abbreviations are allowed if unambiguous.\[\r\n\]+" "see user-defined command in `help user-defined`"
+test_user_defined_class_help {"test_help -- Docstring[\r\n]"}
 
 # Make sure the command does not show up in `show user`.
 gdb_test "show user test_help" "Not a user command\." \
index 6aa3eb18a4b3f38ff32f050802af2363029bd3c9..05350665db629c365e56624619059ddeb244516f 100644 (file)
@@ -55,7 +55,7 @@ set testline2 [expr $baseline + 3]
 set helpcnt 0
 test_class_help "tracepoints" {
     "Tracing of program execution without stopping the program\.[\r\n\]+" 
-} "1.0: help tracepoints"
+} {} "1.0: help tracepoints"
 
 #
 # test trace command:
index a6567884426ac358e535a8130518f0fc845e70de..89767dc51c4ed350c6cce947b075db5c56aa3d16 100644 (file)
@@ -48,8 +48,10 @@ proc string_to_regexp {str} {
 
 proc style {str style} {
     switch -exact -- $style {
+       title { set style 1 }
        file { set style 32 }
        function { set style 33 }
+       highlight { set style 31 }
        variable { set style 36 }
        address { set style 34 }
     }
index c703a7e63385f2247e84febdcd11cba92a7443f2..da36ec0d4aa8587758c5d9516b40d09d02abdbd9 100644 (file)
@@ -5550,35 +5550,64 @@ proc gdb_gnu_strip_debug { dest args } {
 # Test the output of GDB_COMMAND matches the pattern obtained
 # by concatenating all elements of EXPECTED_LINES.  This makes
 # it possible to split otherwise very long string into pieces.
-# If third argument is not empty, it's used as the name of the
+# If third argument TESTNAME is not empty, it's used as the name of the
 # test to be printed on pass/fail.
-proc help_test_raw { gdb_command expected_lines args } {
-    set message $gdb_command
-    if [llength $args]>0 then {
-       set message [lindex $args 0]
-    } 
+proc help_test_raw { gdb_command expected_lines {testname {}} } {
+    if {$testname == {}} {
+       set message $gdb_command
+    } else {
+       set message $testname
+    }
     set expected_output [join $expected_lines ""]
     gdb_test "${gdb_command}" "${expected_output}" $message
 }
 
-# Test the output of "help COMMAND_CLASS". EXPECTED_INITIAL_LINES
+# A regexp that matches the end of help CLASS|PREFIX_COMMAND
+set help_list_trailer {
+    "Type \"apropos word\" to search for commands related to \"word\"\.[\r\n]+"
+    "Type \"apropos -v word\" for full documentation of commands related to \"word\"\.[\r\n]+"
+    "Command name abbreviations are allowed if unambiguous\."
+}
+
+# Test the output of "help COMMAND_CLASS".  EXPECTED_INITIAL_LINES
 # are regular expressions that should match the beginning of output,
-# before the list of commands in that class.  The presence of 
-# command list and standard epilogue will be tested automatically.
+# before the list of commands in that class.
+# LIST_OF_COMMANDS are regular expressions that should match the
+# list of commands in that class.  If empty, the command list will be
+# matched automatically.  The presence of standard epilogue will be tested
+# automatically.
+# If last argument TESTNAME is not empty, it's used as the name of the
+# test to be printed on pass/fail.
 # Notice that the '[' and ']' characters don't need to be escaped for strings
 # wrapped in {} braces.
-proc test_class_help { command_class expected_initial_lines args } {
+proc test_class_help { command_class expected_initial_lines {list_of_commands {}} {testname {}} } {
+    global help_list_trailer
+    if {[llength $list_of_commands]>0} {
+       set l_list_of_commands {"List of commands:[\r\n]+[\r\n]+"}
+        set l_list_of_commands [concat $l_list_of_commands $list_of_commands]
+       set l_list_of_commands [concat $l_list_of_commands {"[\r\n]+[\r\n]+"}]
+    } else {
+        set l_list_of_commands {"List of commands\:.*[\r\n]+"}
+    }
     set l_stock_body {
-        "List of commands\:.*[\r\n]+"
         "Type \"help\" followed by command name for full documentation\.[\r\n]+"
-        "Type \"apropos word\" to search for commands related to \"word\"\.[\r\n]+"
-        "Command name abbreviations are allowed if unambiguous\." 
     }
-    set l_entire_body [concat $expected_initial_lines $l_stock_body]
+    set l_entire_body [concat $expected_initial_lines $l_list_of_commands \
+                      $l_stock_body $help_list_trailer]
 
-    eval [list help_test_raw "help ${command_class}" $l_entire_body] $args
+    help_test_raw "help ${command_class}" $l_entire_body $testname
 }
 
+# Like test_class_help but specialised to test "help user-defined".
+proc test_user_defined_class_help { {list_of_commands {}} {testname {}} } {
+    test_class_help "user-defined" {
+       "User-defined commands\.[\r\n]+"
+       "The commands in this class are those defined by the user\.[\r\n]+"
+       "Use the \"define\" command to define a command\.[\r\n]+"
+    } $list_of_commands $testname
+}
+
+
 # COMMAND_LIST should have either one element -- command to test, or
 # two elements -- abbreviated command to test, and full command the first
 # element is abbreviation of.
@@ -5587,6 +5616,7 @@ proc test_class_help { command_class expected_initial_lines args } {
 # before the list of subcommands.  The presence of 
 # subcommand list and standard epilogue will be tested automatically.
 proc test_prefix_command_help { command_list expected_initial_lines args } {
+    global help_list_trailer
     set command [lindex $command_list 0]   
     if {[llength $command_list]>1} {        
         set full_command [lindex $command_list 1]
@@ -5597,10 +5627,8 @@ proc test_prefix_command_help { command_list expected_initial_lines args } {
     # be expanded in this list.
     set l_stock_body [list\
          "List of $full_command subcommands\:.*\[\r\n\]+"\
-         "Type \"help $full_command\" followed by $full_command subcommand name for full documentation\.\[\r\n\]+"\
-         "Type \"apropos word\" to search for commands related to \"word\"\.\[\r\n\]+"\
-         "Command name abbreviations are allowed if unambiguous\."]
-    set l_entire_body [concat $expected_initial_lines $l_stock_body]
+         "Type \"help $full_command\" followed by $full_command subcommand name for full documentation\.\[\r\n\]+"]
+    set l_entire_body [concat $expected_initial_lines $l_stock_body $help_list_trailer]
     if {[llength $args]>0} {
         help_test_raw "help ${command}" $l_entire_body [lindex $args 0]
     } else {
This page took 0.037272 seconds and 4 git commands to generate.