From patchwork Tue Jun 4 22:34:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 32998 Received: (qmail 47371 invoked by alias); 4 Jun 2019 22:35:22 -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 47318 invoked by uid 89); 4 Jun 2019 22:35:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=13112, completes X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Jun 2019 22:35:20 +0000 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 34C7F3D95D for ; Tue, 4 Jun 2019 22:35:19 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id C198919C69 for ; Tue, 4 Jun 2019 22:35:18 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v3 18/24] lib/completion-support.exp: Add test_gdb_completion_offers_commands Date: Tue, 4 Jun 2019 23:34:38 +0100 Message-Id: <20190604223444.26472-19-palves@redhat.com> In-Reply-To: <20190604223444.26472-1-palves@redhat.com> References: <20190604223444.26472-1-palves@redhat.com> This adds a procedure to the collection of completion-testing routines, that allows checking whether completion offers all commands as completion candidates. This will be used for testing completing "frame apply all [TAB]", "thread apply all [TAB]", etc. gdb/testsuite/ChangeLog: yyyy-mm-dd Pedro Alves * lib/completion-support.exp (test_gdb_complete_tab_multiple) (test_gdb_complete_cmd_multiple, test_gdb_complete_multiple): Add 'max_completions' parameter and handle it. (test_gdb_completion_offers_commands): New. --- gdb/testsuite/lib/completion-support.exp | 66 +++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/gdb/testsuite/lib/completion-support.exp b/gdb/testsuite/lib/completion-support.exp index 3e498d3c631..97fed18b055 100644 --- a/gdb/testsuite/lib/completion-support.exp +++ b/gdb/testsuite/lib/completion-support.exp @@ -119,10 +119,11 @@ proc test_gdb_complete_tab_unique { input_line complete_line_re append_char_re } # Test that completing INPUT_LINE with TAB completes to "INPUT_LINE + # ADD_COMPLETED_LINE" and that it displays the completion matches in -# COMPLETION_LIST. +# COMPLETION_LIST. If MAX_COMPLETIONS then we expect the completion +# to hit the max-completions limit. proc test_gdb_complete_tab_multiple { input_line add_completed_line \ - completion_list } { + completion_list {max_completions 0}} { global gdb_prompt set input_line_re [string_to_regexp $input_line] @@ -130,6 +131,12 @@ proc test_gdb_complete_tab_multiple { input_line add_completed_line \ set expected_re [make_tab_completion_list_re $completion_list] + if {$max_completions} { + append expected_re "\r\n" + append expected_re \ + "\\*\\*\\* List may be truncated, max-completions reached\\. \\*\\*\\*" + } + set test "tab complete \"$input_line\"" send_gdb "$input_line\t" gdb_test_multiple "" "$test (first tab)" { @@ -179,12 +186,20 @@ proc test_gdb_complete_cmd_unique { input_line complete_line_re } { # Test that completing "CMD_PREFIX + COMPLETION_WORD" with the # complete command displays the COMPLETION_LIST completion list. Each -# entry in the list should be prefixed by CMD_PREFIX. +# entry in the list should be prefixed by CMD_PREFIX. If +# MAX_COMPLETIONS then we expect the completion to hit the +# max-completions limit. -proc test_gdb_complete_cmd_multiple { cmd_prefix completion_word completion_list {start_quote_char ""} {end_quote_char ""} } { +proc test_gdb_complete_cmd_multiple { cmd_prefix completion_word completion_list {start_quote_char ""} {end_quote_char ""} {max_completions 0}} { global gdb_prompt set expected_re [make_cmd_completion_list_re $cmd_prefix $completion_list $start_quote_char $end_quote_char] + + if {$max_completions} { + append expected_re \ + "$cmd_prefix \\*\\*\\* List may be truncated, max-completions reached\\. \\*\\*\\*.*\r\n" + } + set cmd_re [string_to_regexp "complete $cmd_prefix$completion_word"] set test "cmd complete \"$cmd_prefix$completion_word\"" gdb_test_multiple "complete $cmd_prefix$completion_word" $test { @@ -255,11 +270,15 @@ proc test_gdb_complete_unique { input_line complete_line {append_char " "} {max_ # Test that completing "CMD_PREFIX + COMPLETION_WORD" adds # ADD_COMPLETED_LINE to the input line, and that it displays # COMPLETION_LIST as completion match list. COMPLETION_WORD is the -# completion word. - -proc test_gdb_complete_multiple { cmd_prefix completion_word add_completed_line completion_list {start_quote_char ""} {end_quote_char ""}} { - test_gdb_complete_tab_multiple "$cmd_prefix$completion_word" $add_completed_line $completion_list - test_gdb_complete_cmd_multiple $cmd_prefix $completion_word $completion_list $start_quote_char $end_quote_char +# completion word. If MAX_COMPLETIONS then we expect the completion +# to hit the max-completions limit. + +proc test_gdb_complete_multiple { + cmd_prefix completion_word add_completed_line completion_list + {start_quote_char ""} {end_quote_char ""} {max_completions 0} +} { + test_gdb_complete_tab_multiple "$cmd_prefix$completion_word" $add_completed_line $completion_list $max_completions + test_gdb_complete_cmd_multiple $cmd_prefix $completion_word $completion_list $start_quote_char $end_quote_char $max_completions } # Test that all the substring prefixes of INPUT from [0..START) to @@ -481,3 +500,32 @@ proc foreach_location_labels { sources functions labels body_linespec body_expli } } } + +# Check that completion of INPUT_LINE results in GDB completing on all +# command names. +proc test_gdb_completion_offers_commands {input_line} { + global gdb_prompt + + # There are two many commands to usefully check here. So we force + # max-completions to 2, and check if those 2 come out. + + # Save current max-completions. + set max_completions 0 + set test "show max-completions" + gdb_test_multiple $test $test { + -re "Maximum number of completion candidates is (.*)\\.\r\n$gdb_prompt $" { + set max_completions $expect_out(1,string) + } + } + + # Force showing two commands. + gdb_test_no_output "set max-completions 2" "" + + test_gdb_complete_multiple $input_line "" "" { + "!" + "+" + } "" "" 1 + + # Restore. + gdb_test_no_output "set max-completions $max_completions" "" +}