# 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]
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)" {
# 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 {
# 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
}
}
}
+
+# 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" ""
+}