1 Tests for find completion.
5 :" Do all test in a separate window to avoid E211 when we recursively
6 :" delete the Xfind directory during cleanup
8 :" This will cause a few errors, do it silently.
10 :set nocp viminfo+=nviminfo
12 :function! DeleteDirectory(dir)
13 : if has("win16") || has("win32") || has("win64") || has("dos16") || has("dos32")
14 : exec "silent !rmdir /Q /S " . a:dir
16 : exec "silent !rm -rf " . a:dir
19 :" On windows a stale "Xfind" directory may exist, remove it so that
20 :" we start from a clean state.
21 :call DeleteDirectory("Xfind")
24 :let test_out = cwd . '/test.out'
29 :exec "w! " . test_out
34 :exec "w >>" . test_out
39 :exec "w >>" . test_out
44 :exec "w >>" . test_out
47 :" We shouldn't find any file at this point, test.out must be empty.
57 SAnother Holy Grail
\e:w
58 :e Xfind/in/path/file.txt
62 :exec "w >>" . test_out
64 :exec "w >>" . test_out
66 :exec "w >>" . test_out
67 :" Rerun the previous three find completions, using fullpath in 'path'
68 :exec "set path=" . cwd . "/Xfind/**"
70 :exec "w >>" . test_out
72 :exec "w >>" . test_out
74 :exec "w >>" . test_out
75 :" Same steps again, using relative and fullpath items that point to the same
76 :" recursive location.
77 :" This is to test that there are no duplicates in the completion list.
78 :exec "set path+=Xfind/**"
80 :exec "w >>" . test_out
82 :exec "w >>" . test_out
84 :exec "w >>" . test_out
86 :" Test find completion for directory of current buffer, which at this point
87 :" is Xfind/in/file.txt.
90 :exec "w >>" . test_out
91 :" Test find completion for empty path item ",," which is the current directory
95 :exec "w >>" . test_out
98 :" foo/x/bar/voyager.txt
99 :" foo/y/bar/voyager.txt
101 :" When current directory is above foo/ they should be shortened to (in order
117 :" We should now be in the Xfind directory
118 :e foo/x/bar/voyager.txt
120 :e foo/y/bar/voyager.txt
122 :exec "set path=" . cwd . "/Xfind/**"
124 :exec "w >>" . test_out
126 :exec "w >>" . test_out
128 :" When current directory is .../foo/y/bar they should be shortened to (in
129 :" order of appearance):
137 :exec "w >> " . test_out
139 :exec "w >> " . test_out
140 :" Check the opposite too:
146 :exec "w >> " . test_out
148 :exec "w >> " . test_out
149 :" Check for correct handling of shorten_fname()'s behavior on windows
150 :exec "cd " . cwd . "/Xfind/in"
152 :exec "w >>" . test_out
153 :" Test for relative to current buffer 'path' item
154 :exec "cd " . cwd . "/Xfind/"
156 :" Open the file where Jimmy Hoffa is found
158 :" Find the file containing 'E.T.' in the Xfind/in/path directory
160 :exec "w >>" . test_out
163 :call DeleteDirectory("Xfind")