Fix latent bug in test_gdb_complete_cmd_multiple
authorPedro Alves <palves@redhat.com>
Wed, 3 Jul 2019 15:57:50 +0000 (16:57 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 3 Jul 2019 16:09:16 +0000 (17:09 +0100)
A following patch will add the following to a testcase:

  test_gdb_completion_offers_commands "| "

And that tripped on a latent testsuite bug:

 (gdb) | PASS: gdb.base/shell.exp: tab complete "| "
 ^CQuit
 (gdb) complete |
 | !
 | +
 PASS: gdb.base/shell.exp: cmd complete "| "
 |  *** List may be truncated, max-completions reached. ***
 (gdb) FAIL: gdb.base/shell.exp: set max-completions 200
 set max-completions 200

The issue is that "|" ends up as part of a regexp, and "|" in regexps
has a special meaning...

Fix this with string_to_regexp.

gdb/testsuite/ChangeLog:
2019-07-03  Pedro Alves  <palves@redhat.com>

* lib/completion-support.exp (test_gdb_complete_cmd_multiple): Use
string_to_regexp.

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

index 8a426ffc87714956d3e9c0130c6d2fce2431bed2..601348f1305c67ab5c8b289e0683a10dac60756f 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-03  Pedro Alves  <palves@redhat.com>
+
+       * lib/completion-support.exp (test_gdb_complete_cmd_multiple): Use
+       string_to_regexp.
+
 2019-07-03  Pedro Alves  <palves@redhat.com>
 
        * gdb.base/options.exp (expect_none, expect_flag, expect_bool)
index 3199e85fd4d3e8c74595bb09f454a87af22f5870..abe48b4a7f7786206cec55b28f12386c21d65879 100644 (file)
@@ -200,8 +200,9 @@ proc test_gdb_complete_cmd_multiple { cmd_prefix completion_word completion_list
     set expected_re [make_cmd_completion_list_re $cmd_prefix $completion_list $start_quote_char $end_quote_char]
 
     if {$max_completions} {
+       set cmd_prefix_re [string_to_regexp $cmd_prefix]
        append expected_re \
-           "$cmd_prefix \\*\\*\\* List may be truncated, max-completions reached\\. \\*\\*\\*.*\r\n"
+           "$cmd_prefix_re \\*\\*\\* List may be truncated, max-completions reached\\. \\*\\*\\*.*\r\n"
     }
 
     set cmd_re [string_to_regexp "complete $cmd_prefix$completion_word"]