Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 18/24] lib/completion-support.exp: Add test_gdb_completion_offers_commands
Date: Wed, 22 May 2019 20:53:00 -0000	[thread overview]
Message-ID: <20190522205327.2568-19-palves@redhat.com> (raw)
In-Reply-To: <20190522205327.2568-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  <palves@redhat.com>

        * 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" ""
+}
-- 
2.14.5


  parent reply	other threads:[~2019-05-22 20:53 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 20:53 [PATCH 00/24] gdb::option framework, "print -OPT", other cmd options Pedro Alves
2019-05-22 20:53 ` [PATCH 08/24] gdb.base/settings.exp: Fix comment typo Pedro Alves
2019-05-24 11:40   ` Pedro Alves
2019-05-22 20:53 ` [PATCH 07/24] Remove "show" command completers Pedro Alves
2019-05-23 19:28   ` Sergio Durigan Junior
2019-05-24 11:25     ` Pedro Alves
2019-05-24 14:21       ` Sergio Durigan Junior
2019-05-22 20:53 ` [PATCH 03/24] Fix TID parser bug Pedro Alves
2019-05-22 20:53 ` [PATCH 11/24] number_or_range_parser::get_number, don't treat "1 -" as a range Pedro Alves
2019-05-22 20:53 ` [PATCH 04/24] Make check_for_argument skip whitespace after arg itself Pedro Alves
2019-05-22 20:53 ` Pedro Alves [this message]
2019-05-22 20:53 ` [PATCH 19/24] Introduce complete_command Pedro Alves
2019-05-22 20:53 ` [PATCH 15/24] Introduce rename_cmd Pedro Alves
2019-05-25 19:58   ` Philippe Waroquiers
2019-05-29 16:03     ` Pedro Alves
2019-05-29 18:30       ` Pedro Alves
2019-05-30 10:22         ` Philippe Waroquiers
2019-05-30 20:01           ` Pedro Alves
2019-05-22 20:54 ` [PATCH 01/24] Fix latent bug in custom word point completion handling Pedro Alves
2019-05-22 20:54 ` [PATCH 14/24] Migrate rest of compile commands to new options framework Pedro Alves
2019-05-22 20:54 ` [PATCH 20/24] Make "frame apply" support -OPT options Pedro Alves
2019-05-25 20:12   ` Philippe Waroquiers
2019-05-29 15:13     ` Pedro Alves
2019-05-29 15:25       ` Pedro Alves
2019-05-22 20:54 ` [PATCH 10/24] boolean/auto-boolean commands, make "o" ambiguous Pedro Alves
2019-05-22 20:54 ` [PATCH 22/24] Make "thread apply" use the gdb::option framework Pedro Alves
2019-05-25 20:24   ` Philippe Waroquiers
2019-05-29 15:38     ` Pedro Alves
2019-05-22 20:54 ` [PATCH 02/24] Fix latent bug with custom word point completers Pedro Alves
2019-05-22 20:54 ` [PATCH 09/24] New set/show testing framework (gdb.base/settings.exp) Pedro Alves
2019-05-23  4:15   ` Eli Zaretskii
2019-05-22 20:54 ` [PATCH 21/24] "thread apply 1 -- -" vs "frame apply level 0 -- -" Pedro Alves
2019-05-22 20:54 ` [PATCH 12/24] Introduce generic command options framework Pedro Alves
2019-05-25  7:43   ` Philippe Waroquiers
2019-05-25 10:31     ` Pedro Alves
2019-05-22 20:54 ` [PATCH 06/24] Fix "set enum-command value garbage" Pedro Alves
2019-05-23 19:13   ` Sergio Durigan Junior
2019-05-24 11:39     ` Pedro Alves
2019-05-22 20:54 ` [PATCH 05/24] Allow "unlimited" abbreviations Pedro Alves
2019-05-22 20:58 ` [PATCH 13/24] Make "print" and "compile print" support -OPT options Pedro Alves
2019-05-24 19:49   ` Sergio Durigan Junior
2019-05-25 10:10     ` Pedro Alves
2019-05-25 10:37       ` Andreas Schwab
2019-05-22 20:58 ` [PATCH 16/24] Make "backtrace" " Pedro Alves
2019-05-22 21:00 ` [PATCH 17/24] "backtrace full/no-filters/hide" completer Pedro Alves
2019-05-22 21:00 ` [PATCH 24/24] NEWS and manual changes for command options changes Pedro Alves
2019-05-23  4:31   ` Eli Zaretskii
2019-05-23 15:01     ` Pedro Alves
2019-05-23 15:07       ` Eli Zaretskii
2019-05-23 15:31         ` Pedro Alves
2019-05-25 20:40   ` Philippe Waroquiers
2019-05-29 16:03     ` Pedro Alves
2019-05-22 21:03 ` [PATCH 23/24] Delete parse_flags/parse_flags_qcs Pedro Alves
2019-05-22 21:46 ` [PATCH 00/24] gdb::option framework, "print -OPT", other cmd options Pedro Alves
2019-05-24 19:58 ` Sergio Durigan Junior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190522205327.2568-19-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox