comparison src/testdir/test_cd.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 1c22fcc7415c
children f7a2de8a4ddc
comparison
equal deleted inserted replaced
29969:5f2d38cacd6c 29970:d891115c0aea
67 endfunc 67 endfunc
68 68
69 " Test for chdir() 69 " Test for chdir()
70 func Test_chdir_func() 70 func Test_chdir_func()
71 let topdir = getcwd() 71 let topdir = getcwd()
72 call mkdir('Xdir/y/z', 'p') 72 call mkdir('Xchdir/y/z', 'p')
73 73
74 " Create a few tabpages and windows with different directories 74 " Create a few tabpages and windows with different directories
75 new 75 new
76 cd Xdir 76 cd Xchdir
77 tabnew 77 tabnew
78 tcd y 78 tcd y
79 below new 79 below new
80 below new 80 below new
81 lcd z 81 lcd z
82 82
83 tabfirst 83 tabfirst
84 call assert_match('^\[global\] .*/Xdir$', trim(execute('verbose pwd'))) 84 call assert_match('^\[global\] .*/Xchdir$', trim(execute('verbose pwd')))
85 call chdir('..') 85 call chdir('..')
86 call assert_equal('y', fnamemodify(getcwd(1, 2), ':t')) 86 call assert_equal('y', fnamemodify(getcwd(1, 2), ':t'))
87 call assert_equal('z', fnamemodify(3->getcwd(2), ':t')) 87 call assert_equal('z', fnamemodify(3->getcwd(2), ':t'))
88 tabnext | wincmd t 88 tabnext | wincmd t
89 call assert_match('^\[tabpage\] .*/y$', trim(execute('verbose pwd'))) 89 call assert_match('^\[tabpage\] .*/y$', trim(execute('verbose pwd')))
90 eval '..'->chdir() 90 eval '..'->chdir()
91 call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t')) 91 call assert_equal('Xchdir', fnamemodify(getcwd(1, 2), ':t'))
92 call assert_equal('Xdir', fnamemodify(getcwd(2, 2), ':t')) 92 call assert_equal('Xchdir', fnamemodify(getcwd(2, 2), ':t'))
93 call assert_equal('z', fnamemodify(getcwd(3, 2), ':t')) 93 call assert_equal('z', fnamemodify(getcwd(3, 2), ':t'))
94 call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t')) 94 call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t'))
95 3wincmd w 95 3wincmd w
96 call assert_match('^\[window\] .*/z$', trim(execute('verbose pwd'))) 96 call assert_match('^\[window\] .*/z$', trim(execute('verbose pwd')))
97 call chdir('..') 97 call chdir('..')
98 call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t')) 98 call assert_equal('Xchdir', fnamemodify(getcwd(1, 2), ':t'))
99 call assert_equal('Xdir', fnamemodify(getcwd(2, 2), ':t')) 99 call assert_equal('Xchdir', fnamemodify(getcwd(2, 2), ':t'))
100 call assert_equal('y', fnamemodify(getcwd(3, 2), ':t')) 100 call assert_equal('y', fnamemodify(getcwd(3, 2), ':t'))
101 call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t')) 101 call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t'))
102 102
103 " Error case 103 " Error case
104 call assert_fails("call chdir('dir-abcd')", 'E344:') 104 call assert_fails("call chdir('dir-abcd')", 'E344:')
108 call chdir(d) 108 call chdir(d)
109 call assert_equal('', chdir([])) 109 call assert_equal('', chdir([]))
110 110
111 only | tabonly 111 only | tabonly
112 call chdir(topdir) 112 call chdir(topdir)
113 call delete('Xdir', 'rf') 113 call delete('Xchdir', 'rf')
114 endfunc 114 endfunc
115 115
116 " Test for changing to the previous directory '-' 116 " Test for changing to the previous directory '-'
117 func Test_prev_dir() 117 func Test_prev_dir()
118 let topdir = getcwd() 118 let topdir = getcwd()
119 call mkdir('Xdir/a/b/c', 'p') 119 call mkdir('Xprevdir/a/b/c', 'p')
120 120
121 " Create a few tabpages and windows with different directories 121 " Create a few tabpages and windows with different directories
122 new | only 122 new | only
123 tabnew | new 123 tabnew | new
124 tabnew 124 tabnew
125 tabfirst 125 tabfirst
126 cd Xdir 126 cd Xprevdir
127 tabnext | wincmd t 127 tabnext | wincmd t
128 tcd a 128 tcd a
129 wincmd w 129 wincmd w
130 lcd b 130 lcd b
131 tabnext 131 tabnext
141 tabnext 141 tabnext
142 tcd - | tcd - 142 tcd - | tcd -
143 143
144 " Check the directory of all the windows 144 " Check the directory of all the windows
145 tabfirst 145 tabfirst
146 call assert_equal('Xdir', fnamemodify(getcwd(), ':t')) 146 call assert_equal('Xprevdir', fnamemodify(getcwd(), ':t'))
147 tabnext | wincmd t 147 tabnext | wincmd t
148 call assert_equal('a', fnamemodify(getcwd(), ':t')) 148 call assert_equal('a', fnamemodify(getcwd(), ':t'))
149 wincmd w 149 wincmd w
150 call assert_equal('b', fnamemodify(getcwd(), ':t')) 150 call assert_equal('b', fnamemodify(getcwd(), ':t'))
151 tabnext 151 tabnext
161 tabnext 161 tabnext
162 call chdir("-") | call chdir("-") 162 call chdir("-") | call chdir("-")
163 163
164 " Check the directory of all the windows 164 " Check the directory of all the windows
165 tabfirst 165 tabfirst
166 call assert_equal('Xdir', fnamemodify(getcwd(), ':t')) 166 call assert_equal('Xprevdir', fnamemodify(getcwd(), ':t'))
167 tabnext | wincmd t 167 tabnext | wincmd t
168 call assert_equal('a', fnamemodify(getcwd(), ':t')) 168 call assert_equal('a', fnamemodify(getcwd(), ':t'))
169 wincmd w 169 wincmd w
170 call assert_equal('b', fnamemodify(getcwd(), ':t')) 170 call assert_equal('b', fnamemodify(getcwd(), ':t'))
171 tabnext 171 tabnext
172 call assert_equal('c', fnamemodify(getcwd(), ':t')) 172 call assert_equal('c', fnamemodify(getcwd(), ':t'))
173 173
174 only | tabonly 174 only | tabonly
175 call chdir(topdir) 175 call chdir(topdir)
176 call delete('Xdir', 'rf') 176 call delete('Xprevdir', 'rf')
177 endfunc 177 endfunc
178 178
179 func Test_lcd_split() 179 func Test_lcd_split()
180 let curdir = getcwd() 180 let curdir = getcwd()
181 lcd .. 181 lcd ..