1 # Copyright (C) 2014-2015 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 set testfile "py-completion"
18 load_lib gdb-python.exp
23 # Skip all tests if Python scripting is not enabled.
24 if { [skip_python_tests] } { continue }
26 gdb_test_no_output "source ${srcdir}/${subdir}/${testfile}.py"
28 # Create a temporary directory
29 set testdir "[standard_output_file "py-completion-testdir"]/"
30 set testdir_regex [string_to_regexp $testdir]
31 set testdir_complete [standard_output_file "py-completion-test"]
34 # This one should always pass.
35 send_gdb "completefileinit ${testdir_complete}\t"
36 gdb_test_multiple "" "completefileinit completion" {
37 -re "^completefileinit ${testdir_regex}$" {
38 pass "completefileinit completion"
42 # Just discarding whatever we typed.
44 gdb_test " " ".*" "discard #[incr discard]"
46 # This is the problematic one.
47 send_gdb "completefilemethod ${testdir_complete}\t"
48 gdb_test_multiple "" "completefilemethod completion" {
49 -re "^completefilemethod ${testdir_regex} $" {
50 fail "completefilemethod completion (completed filename as wrong command arg)"
52 -re "^completefilemethod ${testdir_regex}$" {
53 pass "completefilemethod completion"
58 gdb_test " " ".*" "discard #[incr discard]"
61 set completion_regex "[string_to_regexp [standard_output_file "py-completion-t"]]"
62 send_gdb "completefilecommandcond [standard_output_file "py-completion-t\t"]"
63 gdb_test_multiple "" "completefilecommandcond completion" {
64 -re "^completefilecommandcond ${testdir}$" {
65 fail "completefilecommandcond completion (completed filename instead of command)"
67 -re "^completefilecommandcond ${completion_regex}\007$" {
68 pass "completefilecommandcond completion"
72 # Start gdb over again to clear out current state. This can interfere
73 # with the expected output of the below tests in a buggy gdb.
76 gdb_test_no_output "source ${srcdir}/${subdir}/${testfile}.py"
78 gdb_test_sequence "complete completel" \
79 "list all completions of 'complete completel'" {
90 gdb_test " " ".*" "discard #[incr discard]"
92 gdb_test_sequence "complete completelimit1 c" \
93 "list all completions of 'complete completelimit1 c'" {
100 gdb_test " " ".*" "discard #[incr discard]"
102 # If using readline, we can TAB-complete. This used to trigger a bug
103 # because the cached result from the completer was being reused for
104 # a different python command.
105 if {[readline_is_used]} {
106 set testname "tab-complete 'completelimit1 c'"
107 send_gdb "completelimit1 c\t"
108 gdb_test_multiple "" $testname {
109 -re "^completelimit1 c\\\x07l1$" {
112 # Discard the command line
113 gdb_test " " ".*" "discard #[incr discard]"
117 gdb_test_sequence "complete completelimit2 c" \
118 "list all completions of 'complete completelimit2 c'" {
119 "completelimit2 cl21"
120 "completelimit2 cl210"
121 "completelimit2 cl22"
122 "completelimit2 cl23"
123 "completelimit2 cl24"
124 "completelimit2 cl25"
125 "completelimit2 cl26"
126 "completelimit2 cl27"
127 "completelimit2 cl28"
128 "completelimit2 cl29"