comparison src/testdir/test_cmdline.vim @ 29970:d891115c0aea v9.0.0323

patch 9.0.0323: using common name in tests leads to flaky tests Commit: https://github.com/vim/vim/commit/3b0d70f4ff436cb144683dafd956e8a3ee485a90 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 29 22:31:20 2022 +0100 patch 9.0.0323: using common name in tests leads to flaky tests Problem: Using common name in tests leads to flaky tests. Solution: Rename files and directories to be more specific.
author Bram Moolenaar <Bram@vim.org>
date Mon, 29 Aug 2022 23:45:04 +0200
parents 444dd4cc49d6
children 98f5a0618a77
comparison
equal deleted inserted replaced
29969:5f2d38cacd6c 29970:d891115c0aea
81 call delete('Xtest', 'rf') 81 call delete('Xtest', 'rf')
82 set wildmode& 82 set wildmode&
83 endfunc 83 endfunc
84 84
85 func Test_complete_wildmenu() 85 func Test_complete_wildmenu()
86 call mkdir('Xdir1/Xdir2', 'p') 86 call mkdir('Xwilddir1/Xdir2', 'p')
87 call writefile(['testfile1'], 'Xdir1/Xtestfile1') 87 call writefile(['testfile1'], 'Xwilddir1/Xtestfile1')
88 call writefile(['testfile2'], 'Xdir1/Xtestfile2') 88 call writefile(['testfile2'], 'Xwilddir1/Xtestfile2')
89 call writefile(['testfile3'], 'Xdir1/Xdir2/Xtestfile3') 89 call writefile(['testfile3'], 'Xwilddir1/Xdir2/Xtestfile3')
90 call writefile(['testfile3'], 'Xdir1/Xdir2/Xtestfile4') 90 call writefile(['testfile3'], 'Xwilddir1/Xdir2/Xtestfile4')
91 set wildmenu 91 set wildmenu
92 92
93 " Pressing <Tab> completes, and moves to next files when pressing again. 93 " Pressing <Tab> completes, and moves to next files when pressing again.
94 call feedkeys(":e Xdir1/\<Tab>\<Tab>\<CR>", 'tx') 94 call feedkeys(":e Xwilddir1/\<Tab>\<Tab>\<CR>", 'tx')
95 call assert_equal('testfile1', getline(1)) 95 call assert_equal('testfile1', getline(1))
96 call feedkeys(":e Xdir1/\<Tab>\<Tab>\<Tab>\<CR>", 'tx') 96 call feedkeys(":e Xwilddir1/\<Tab>\<Tab>\<Tab>\<CR>", 'tx')
97 call assert_equal('testfile2', getline(1)) 97 call assert_equal('testfile2', getline(1))
98 98
99 " <S-Tab> is like <Tab> but begin with the last match and then go to 99 " <S-Tab> is like <Tab> but begin with the last match and then go to
100 " previous. 100 " previous.
101 call feedkeys(":e Xdir1/Xtest\<S-Tab>\<CR>", 'tx') 101 call feedkeys(":e Xwilddir1/Xtest\<S-Tab>\<CR>", 'tx')
102 call assert_equal('testfile2', getline(1)) 102 call assert_equal('testfile2', getline(1))
103 call feedkeys(":e Xdir1/Xtest\<S-Tab>\<S-Tab>\<CR>", 'tx') 103 call feedkeys(":e Xwilddir1/Xtest\<S-Tab>\<S-Tab>\<CR>", 'tx')
104 call assert_equal('testfile1', getline(1)) 104 call assert_equal('testfile1', getline(1))
105 105
106 " <Left>/<Right> to move to previous/next file. 106 " <Left>/<Right> to move to previous/next file.
107 call feedkeys(":e Xdir1/\<Tab>\<Right>\<CR>", 'tx') 107 call feedkeys(":e Xwilddir1/\<Tab>\<Right>\<CR>", 'tx')
108 call assert_equal('testfile1', getline(1)) 108 call assert_equal('testfile1', getline(1))
109 call feedkeys(":e Xdir1/\<Tab>\<Right>\<Right>\<CR>", 'tx') 109 call feedkeys(":e Xwilddir1/\<Tab>\<Right>\<Right>\<CR>", 'tx')
110 call assert_equal('testfile2', getline(1)) 110 call assert_equal('testfile2', getline(1))
111 call feedkeys(":e Xdir1/\<Tab>\<Right>\<Right>\<Left>\<CR>", 'tx') 111 call feedkeys(":e Xwilddir1/\<Tab>\<Right>\<Right>\<Left>\<CR>", 'tx')
112 call assert_equal('testfile1', getline(1)) 112 call assert_equal('testfile1', getline(1))
113 113
114 " <Up>/<Down> to go up/down directories. 114 " <Up>/<Down> to go up/down directories.
115 call feedkeys(":e Xdir1/\<Tab>\<Down>\<CR>", 'tx') 115 call feedkeys(":e Xwilddir1/\<Tab>\<Down>\<CR>", 'tx')
116 call assert_equal('testfile3', getline(1)) 116 call assert_equal('testfile3', getline(1))
117 call feedkeys(":e Xdir1/\<Tab>\<Down>\<Up>\<Right>\<CR>", 'tx') 117 call feedkeys(":e Xwilddir1/\<Tab>\<Down>\<Up>\<Right>\<CR>", 'tx')
118 call assert_equal('testfile1', getline(1)) 118 call assert_equal('testfile1', getline(1))
119 119
120 " this fails in some Unix GUIs, not sure why 120 " this fails in some Unix GUIs, not sure why
121 if !has('unix') || !has('gui_running') 121 if !has('unix') || !has('gui_running')
122 " <C-J>/<C-K> mappings to go up/down directories when 'wildcharm' is 122 " <C-J>/<C-K> mappings to go up/down directories when 'wildcharm' is
123 " different than 'wildchar'. 123 " different than 'wildchar'.
124 set wildcharm=<C-Z> 124 set wildcharm=<C-Z>
125 cnoremap <C-J> <Down><C-Z> 125 cnoremap <C-J> <Down><C-Z>
126 cnoremap <C-K> <Up><C-Z> 126 cnoremap <C-K> <Up><C-Z>
127 call feedkeys(":e Xdir1/\<Tab>\<C-J>\<CR>", 'tx') 127 call feedkeys(":e Xwilddir1/\<Tab>\<C-J>\<CR>", 'tx')
128 call assert_equal('testfile3', getline(1)) 128 call assert_equal('testfile3', getline(1))
129 call feedkeys(":e Xdir1/\<Tab>\<C-J>\<C-K>\<CR>", 'tx') 129 call feedkeys(":e Xwilddir1/\<Tab>\<C-J>\<C-K>\<CR>", 'tx')
130 call assert_equal('testfile1', getline(1)) 130 call assert_equal('testfile1', getline(1))
131 set wildcharm=0 131 set wildcharm=0
132 cunmap <C-J> 132 cunmap <C-J>
133 cunmap <C-K> 133 cunmap <C-K>
134 endif 134 endif
135 135
136 " Test for canceling the wild menu by adding a character 136 " Test for canceling the wild menu by adding a character
137 redrawstatus 137 redrawstatus
138 call feedkeys(":e Xdir1/\<Tab>x\<C-B>\"\<CR>", 'xt') 138 call feedkeys(":e Xwilddir1/\<Tab>x\<C-B>\"\<CR>", 'xt')
139 call assert_equal('"e Xdir1/Xdir2/x', @:) 139 call assert_equal('"e Xwilddir1/Xdir2/x', @:)
140 140
141 " Completion using a relative path 141 " Completion using a relative path
142 cd Xdir1/Xdir2 142 cd Xwilddir1/Xdir2
143 call feedkeys(":e ../\<Tab>\<Right>\<Down>\<C-A>\<C-B>\"\<CR>", 'tx') 143 call feedkeys(":e ../\<Tab>\<Right>\<Down>\<C-A>\<C-B>\"\<CR>", 'tx')
144 call assert_equal('"e Xtestfile3 Xtestfile4', @:) 144 call assert_equal('"e Xtestfile3 Xtestfile4', @:)
145 cd - 145 cd -
146 146
147 " test for wildmenumode() 147 " test for wildmenumode()
148 cnoremap <expr> <F2> wildmenumode() 148 cnoremap <expr> <F2> wildmenumode()
149 call feedkeys(":cd Xdir\<Tab>\<F2>\<C-B>\"\<CR>", 'tx') 149 call feedkeys(":cd Xwilddir\<Tab>\<F2>\<C-B>\"\<CR>", 'tx')
150 call assert_equal('"cd Xdir1/0', @:) 150 call assert_equal('"cd Xwilddir1/0', @:)
151 call feedkeys(":e Xdir1/\<Tab>\<F2>\<C-B>\"\<CR>", 'tx') 151 call feedkeys(":e Xwilddir1/\<Tab>\<F2>\<C-B>\"\<CR>", 'tx')
152 call assert_equal('"e Xdir1/Xdir2/1', @:) 152 call assert_equal('"e Xwilddir1/Xdir2/1', @:)
153 cunmap <F2> 153 cunmap <F2>
154 154
155 " Test for canceling the wild menu by pressing <PageDown> or <PageUp>. 155 " Test for canceling the wild menu by pressing <PageDown> or <PageUp>.
156 " After this pressing <Left> or <Right> should not change the selection. 156 " After this pressing <Left> or <Right> should not change the selection.
157 call feedkeys(":sign \<Tab>\<PageDown>\<Left>\<Right>\<C-A>\<C-B>\"\<CR>", 'tx') 157 call feedkeys(":sign \<Tab>\<PageDown>\<Left>\<Right>\<C-A>\<C-B>\"\<CR>", 'tx')
160 call feedkeys(":sign \<Tab>\<PageUp>\<Left>\<Right>\<C-A>\<C-B>\"\<CR>", 'tx') 160 call feedkeys(":sign \<Tab>\<PageUp>\<Left>\<Right>\<C-A>\<C-B>\"\<CR>", 'tx')
161 call assert_equal('"TestWildMenu', @:) 161 call assert_equal('"TestWildMenu', @:)
162 162
163 " cleanup 163 " cleanup
164 %bwipe 164 %bwipe
165 call delete('Xdir1', 'rf') 165 call delete('Xwilddir1', 'rf')
166 set nowildmenu 166 set nowildmenu
167 endfunc 167 endfunc
168 168
169 func Test_wildmenu_screendump() 169 func Test_wildmenu_screendump()
170 CheckScreendump 170 CheckScreendump
1928 1928
1929 " Test for going up and down the directory tree using 'wildmenu' 1929 " Test for going up and down the directory tree using 'wildmenu'
1930 func Test_wildmenu_dirstack() 1930 func Test_wildmenu_dirstack()
1931 CheckUnix 1931 CheckUnix
1932 %bw! 1932 %bw!
1933 call mkdir('Xdir1/dir2/dir3/dir4', 'p') 1933 call mkdir('Xwildmenu/dir2/dir3/dir4', 'p')
1934 call writefile([], 'Xdir1/file1_1.txt') 1934 call writefile([], 'Xwildmenu/file1_1.txt')
1935 call writefile([], 'Xdir1/file1_2.txt') 1935 call writefile([], 'Xwildmenu/file1_2.txt')
1936 call writefile([], 'Xdir1/dir2/file2_1.txt') 1936 call writefile([], 'Xwildmenu/dir2/file2_1.txt')
1937 call writefile([], 'Xdir1/dir2/file2_2.txt') 1937 call writefile([], 'Xwildmenu/dir2/file2_2.txt')
1938 call writefile([], 'Xdir1/dir2/dir3/file3_1.txt') 1938 call writefile([], 'Xwildmenu/dir2/dir3/file3_1.txt')
1939 call writefile([], 'Xdir1/dir2/dir3/file3_2.txt') 1939 call writefile([], 'Xwildmenu/dir2/dir3/file3_2.txt')
1940 call writefile([], 'Xdir1/dir2/dir3/dir4/file4_1.txt') 1940 call writefile([], 'Xwildmenu/dir2/dir3/dir4/file4_1.txt')
1941 call writefile([], 'Xdir1/dir2/dir3/dir4/file4_2.txt') 1941 call writefile([], 'Xwildmenu/dir2/dir3/dir4/file4_2.txt')
1942 set wildmenu 1942 set wildmenu
1943 1943
1944 cd Xdir1/dir2/dir3/dir4 1944 cd Xwildmenu/dir2/dir3/dir4
1945 call feedkeys(":e \<Tab>\<C-B>\"\<CR>", 'xt') 1945 call feedkeys(":e \<Tab>\<C-B>\"\<CR>", 'xt')
1946 call assert_equal('"e file4_1.txt', @:) 1946 call assert_equal('"e file4_1.txt', @:)
1947 call feedkeys(":e \<Tab>\<Up>\<C-B>\"\<CR>", 'xt') 1947 call feedkeys(":e \<Tab>\<Up>\<C-B>\"\<CR>", 'xt')
1948 call assert_equal('"e ../dir4/', @:) 1948 call assert_equal('"e ../dir4/', @:)
1949 call feedkeys(":e \<Tab>\<Up>\<Up>\<C-B>\"\<CR>", 'xt') 1949 call feedkeys(":e \<Tab>\<Up>\<Up>\<C-B>\"\<CR>", 'xt')
1953 call feedkeys(":e \<Tab>\<Up>\<Up>\<Down>\<C-B>\"\<CR>", 'xt') 1953 call feedkeys(":e \<Tab>\<Up>\<Up>\<Down>\<C-B>\"\<CR>", 'xt')
1954 call assert_equal('"e ../../dir3/dir4/', @:) 1954 call assert_equal('"e ../../dir3/dir4/', @:)
1955 call feedkeys(":e \<Tab>\<Up>\<Up>\<Down>\<Down>\<C-B>\"\<CR>", 'xt') 1955 call feedkeys(":e \<Tab>\<Up>\<Up>\<Down>\<Down>\<C-B>\"\<CR>", 'xt')
1956 call assert_equal('"e ../../dir3/dir4/file4_1.txt', @:) 1956 call assert_equal('"e ../../dir3/dir4/file4_1.txt', @:)
1957 cd - 1957 cd -
1958 call feedkeys(":e Xdir1/\<Tab>\<Down>\<Down>\<Down>\<C-B>\"\<CR>", 'xt') 1958 call feedkeys(":e Xwildmenu/\<Tab>\<Down>\<Down>\<Down>\<C-B>\"\<CR>", 'xt')
1959 call assert_equal('"e Xdir1/dir2/dir3/dir4/file4_1.txt', @:) 1959 call assert_equal('"e Xwildmenu/dir2/dir3/dir4/file4_1.txt', @:)
1960 1960
1961 call delete('Xdir1', 'rf') 1961 call delete('Xwildmenu', 'rf')
1962 set wildmenu& 1962 set wildmenu&
1963 endfunc 1963 endfunc
1964 1964
1965 " Test for recalling newer or older cmdline from history with <Up>, <Down>, 1965 " Test for recalling newer or older cmdline from history with <Up>, <Down>,
1966 " <S-Up>, <S-Down>, <PageUp>, <PageDown>, <kPageUp>, <kPageDown>, <C-p>, or 1966 " <S-Up>, <S-Down>, <PageUp>, <PageDown>, <kPageUp>, <kPageDown>, <C-p>, or