public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb/testsuite: Improve testing of GDB's completion functions
@ 2023-02-27  9:53 Bruno Larsen
  0 siblings, 0 replies; only message in thread
From: Bruno Larsen @ 2023-02-27  9:53 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a3da2e7e550c4fe79128b5e532dbb90df4d4f418

commit a3da2e7e550c4fe79128b5e532dbb90df4d4f418
Author: Bruno Larsen <blarsen@redhat.com>
Date:   Tue Feb 21 17:10:31 2023 +0100

    gdb/testsuite: Improve testing of GDB's completion functions
    
    When looking at some failures of gdb.linespec/cp-completion-aliases.exp,
    I noticed that when a completion test will fail, it always fails with a
    timeout.  This is because most completion tests use gdb_test_multiple
    and only add a check for the correct output.  This commit adds new
    options for both, tab and command completion.
    
    For command completion, the new option will check if the prompt was
    printed, and fail in this case. This is enough to know that the test has
    failed because the check comes after the PASS path. For tab completion,
    we have to check if GDB outputted more than just the input line, because
    sometimes GDB would have printed a partial line before finishing with
    the correct completion.
    
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 gdb/testsuite/lib/completion-support.exp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gdb/testsuite/lib/completion-support.exp b/gdb/testsuite/lib/completion-support.exp
index bf9c5ad352c..275f8874f15 100644
--- a/gdb/testsuite/lib/completion-support.exp
+++ b/gdb/testsuite/lib/completion-support.exp
@@ -94,6 +94,9 @@ proc test_gdb_complete_tab_none { line } {
 	-re "^$line_re$completion::bell_re$" {
 	    pass "$test"
 	}
+	-re "$line_re\[^ \]+ $" {
+	    fail "$test"
+	}
     }
 
     clear_input_line $test
@@ -108,11 +111,15 @@ proc test_gdb_complete_tab_unique { input_line complete_line_re append_char_re }
 
     set test "tab complete \"$input_line\""
     send_gdb "$input_line\t"
+    set partial_complete [string_to_regexp $input_line]
     set res 1
     gdb_test_multiple "" "$test" {
 	-re "^$complete_line_re$append_char_re$" {
 	    pass "$test"
 	}
+	-re "$partial_complete\[^ \]+ $" {
+	    fail "$test"
+	}
 	timeout {
 	    fail "$test (timeout)"
 	    set res -1
@@ -164,6 +171,9 @@ proc test_gdb_complete_tab_multiple { input_line add_completed_line \
 			}
 		    }
 		}
+		-re "${maybe_bell}\r\n.+\r\n$gdb_prompt $" {
+		    fail "$test"
+		}
 	    }
 	}
     }
@@ -191,6 +201,9 @@ proc test_gdb_complete_cmd_unique { input_line complete_line_re } {
 	-re "^$cmd_re\r\n$complete_line_re\r\n$gdb_prompt $" {
 	    pass $test
 	}
+	-re "$gdb_prompt $" {
+	    fail "$test"
+	}
     }
 }
 
@@ -217,6 +230,9 @@ proc test_gdb_complete_cmd_multiple { cmd_prefix completion_word completion_list
 	-re "^$cmd_re\r\n$expected_re$gdb_prompt $" {
 	    pass $test
 	}
+	-re "$gdb_prompt $" {
+	    fail "$test"
+	}
     }
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-27  9:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-27  9:53 [binutils-gdb] gdb/testsuite: Improve testing of GDB's completion functions Bruno Larsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).