Tighten regexp of lib/completion-support.exp:test_gdb_complete_tab_multiple
authorPedro Alves <palves@redhat.com>
Wed, 13 Dec 2017 16:38:50 +0000 (16:38 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 13 Dec 2017 16:40:00 +0000 (16:40 +0000)
While writing the tests included in the previous commit, I noticed
that test_gdb_complete_tab_multiple would not FAIL if GDB happens to
show more completions than expected before the expected list.

E.g., with something like this, expecting "p foo" to complete to
"foo2" and "foo3":

 test_gdb_complete_tab_multiple "p foo" "" {
"foo2"
"foo3"
 }

and then if foo actually completes to:

 (gdb) p foo[TAB]
 foo1   foo2  foo3
 ^^^^

we'd still PASS.  (Note the spurious "foo1" above.)

This tightens the regexp with a beginning anchor thus making the
completions above cause a FAIL.  Other similar functions in
completion-support.exp already do something like this; I had just
missed this one originally.  Thankfully, this did not expose any
problems in the gdb.linespec/ tests.  Phew.

gdb/testsuite/ChangeLog:
2017-12-13  Pedro Alves  <palves@redhat.com>

* lib/completion-support.exp (test_gdb_complete_tab_multiple):
Tighten regexp by matching with an anchor.

gdb/testsuite/ChangeLog
gdb/testsuite/lib/completion-support.exp

index 450ca3574fb3ef0b234e7384893d15d70450af01..1a33fc265222f414ff88db0f2a1fd3282f6263ff 100644 (file)
@@ -1,3 +1,8 @@
+2017-12-13  Pedro Alves  <palves@redhat.com>
+
+       * lib/completion-support.exp (test_gdb_complete_tab_multiple):
+       Tighten regexp by matching with an anchor.
+
 2017-12-13  Pedro Alves  <palves@redhat.com>
 
        * gdb.cp/cpcompletion.exp: Load completion-support.exp.
index fe5b16a85b858b8b550be933e6694e9190f240ff..bebf90e117ba55c17c98f87ddf466ec85b0720ef 100644 (file)
@@ -139,9 +139,12 @@ proc test_gdb_complete_tab_multiple { input_line add_completed_line \
            # extra tab to show the matches list.
            if {$add_completed_line != ""} {
                send_gdb "\t"
+               set maybe_bell ${completion::bell_re}
+           } else {
+               set maybe_bell ""
            }
            gdb_test_multiple "" "$test (second tab)" {
-               -re "$expected_re\r\n$gdb_prompt $input_line_re$add_completed_line_re$" {
+               -re "^${maybe_bell}\r\n$expected_re\r\n$gdb_prompt $input_line_re$add_completed_line_re$" {
                    pass "$test"
                }
            }
This page took 0.031793 seconds and 4 git commands to generate.