From patchwork Fri May 31 13:19:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Waroquiers X-Patchwork-Id: 32960 Received: (qmail 91098 invoked by alias); 31 May 2019 13:19:24 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 91009 invoked by uid 89); 31 May 2019 13:19:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=inquiries, 1597, UD:gdb.exp, gdb.exp X-HELO: mailsec108.isp.belgacom.be Received: from mailsec108.isp.belgacom.be (HELO mailsec108.isp.belgacom.be) (195.238.20.104) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 31 May 2019 13:19:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1559308760; x=1590844760; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PMP1gvHt3E9Vo/m2G2B325+m6kbdkFSu8+Oxt3BuThA=; b=aPUZPgdnoG9p13hL4P9K5qNA7GfBipQbhOZbkXQUpPg0Wzz7E73yXoOv YfyH/JOMWGP1FWqQLGs4XlGq3TszIw==; Received: from 161.32-242-81.adsl-dyn.isp.belgacom.be (HELO md.home) ([81.242.32.161]) by relay.skynet.be with ESMTP/TLS/DHE-RSA-AES128-GCM-SHA256; 31 May 2019 15:19:10 +0200 From: Philippe Waroquiers To: gdb-patches@sourceware.org Cc: Philippe Waroquiers Subject: [RFA 3/4] Update tests following changes to "help" and "apropos" Date: Fri, 31 May 2019 15:19:02 +0200 Message-Id: <20190531131903.21203-4-philippe.waroquiers@skynet.be> In-Reply-To: <20190531131903.21203-1-philippe.waroquiers@skynet.be> References: <20190531131903.21203-1-philippe.waroquiers@skynet.be> MIME-Version: 1.0 X-IsSubscribed: yes 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 | 13 +++++++ gdb/testsuite/gdb.base/help.exp | 30 ++++++++-------- gdb/testsuite/gdb.guile/scm-cmd.exp | 4 +-- gdb/testsuite/gdb.python/py-cmd.exp | 2 +- gdb/testsuite/gdb.trace/tracecmd.exp | 2 +- gdb/testsuite/lib/gdb.exp | 51 +++++++++++++++++++++------- 6 files changed, 69 insertions(+), 33 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 661c93860c..7b485a8f6b 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -16111,3 +16111,16 @@ For older changes see ChangeLog-1993-2013. Copyright 2014-2019 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted provided the copyright notice and this notice are preserved. + +2019-05-31 Philippe Waroquiers + + * gdb.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: Likewise. Use test_user_defined_class_help. diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp index 511e7d6238..0a8ad8e54d 100644 --- a/gdb/testsuite/gdb.base/help.exp +++ b/gdb/testsuite/gdb.base/help.exp @@ -25,37 +25,35 @@ gdb_start gdb_test_no_output "set height 0" "disable pagination" # Test all the help classes. -test_class_help "aliases" {"Aliases of other commands\.\[\r\n\]+"} +test_class_help "aliases" {"Aliases of other commands\.\[\r\n\]+"} {} test_class_help "breakpoints" { "Making program stop at certain points\.\[\r\n\]+" -} -test_class_help "data" {"Examining data\.\[\r\n\]+"} -test_class_help "files" {"Specifying and examining files\.\[\r\n\]+"} +} {} +test_class_help "data" {"Examining data\.\[\r\n\]+"} {} +test_class_help "files" {"Specifying and examining files\.\[\r\n\]+"} {} test_class_help "internals" { "Maintenance commands\.\[\r\n\]+" "Some gdb commands are provided just for use by gdb maintainers\.\[\r\n\]+" "These commands are subject to frequent change, and may not be as\[\r\n\]+" "well documented as user commands\.\[\r\n\]+" -} -test_class_help "obscure" {"Obscure features\.\[\r\n\]+"} -test_class_help "running" {"Running the program\.\[\r\n\]+"} +} {} +test_class_help "obscure" {"Obscure features\.\[\r\n\]+"} {} +test_class_help "running" {"Running the program\.\[\r\n\]+"} {} test_class_help "stack" { "Examining the stack\..*\[\r\n\]+" "When the program being debugged stops, gdb selects the innermost frame\.\[\r\n\]+" "The commands below can be used to select other frames by number or address\.\[\r\n\]+" -} +} {} test_class_help "status" { "Status inquiries\.\[\r\n\]+" -} -test_class_help "support" {"Support facilities\.\[\r\n\]+"} +} {} +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 "help user-defined", not checking user-defined command list. +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\..*" diff --git a/gdb/testsuite/gdb.guile/scm-cmd.exp b/gdb/testsuite/gdb.guile/scm-cmd.exp index 3f24df3c9e..518da660c2 100644 --- a/gdb/testsuite/gdb.guile/scm-cmd.exp +++ b/gdb/testsuite/gdb.guile/scm-cmd.exp @@ -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\." \ diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp index 9abdb0f39e..c7c7b8c899 100644 --- a/gdb/testsuite/gdb.python/py-cmd.exp +++ b/gdb/testsuite/gdb.python/py-cmd.exp @@ -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\." \ diff --git a/gdb/testsuite/gdb.trace/tracecmd.exp b/gdb/testsuite/gdb.trace/tracecmd.exp index 6aa3eb18a4..05350665db 100644 --- a/gdb/testsuite/gdb.trace/tracecmd.exp +++ b/gdb/testsuite/gdb.trace/tracecmd.exp @@ -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: diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index c703a7e633..d11a95c442 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -5561,24 +5561,52 @@ proc help_test_raw { gdb_command expected_lines args } { 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. # 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 args } { + 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 } +# Like test_class_help but specialised to test "help user-defined". +proc test_user_defined_class_help { list_of_commands args } { + 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 [list $args] + # Unclear why, but if [list $args] is rather $args, the above is tested + # but gives no PASS message (but gives a FAIL message if it fails) ??? +} + + # 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 +5615,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 +5626,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 {