blob: 706c379e7ce780d58a886797a590b4618690a324 [file] [log] [blame]
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +02001Tests for find completion.
2
3STARTTEST
Bram Moolenaar84f888a2010-08-05 21:40:16 +02004:" Do all test in a separate window to avoid E211 when we recursively
5:" delete the Xfind directory during cleanup
6:"
7:" This will cause a few errors, do it silently.
8:set visualbell
9:"
10:function! DeleteDirectory(dir)
11: if has("win16") || has("win32") || has("win64")
12: exec "silent !rmdir /Q /S " . a:dir
13: else
14: exec "silent !rm -rf " . a:dir
15: endif
16:endfun
17:" On windows a stale "Xfind" directory may exist, remove it so that
18:" we start from a clean state.
19:call DeleteDirectory("Xfind")
20:set nocp
21:new
22:let cwd=getcwd()
Bram Moolenaar3ea5fa72010-08-04 18:27:57 +020023:!mkdir Xfind
Bram Moolenaar84f888a2010-08-05 21:40:16 +020024:cd Xfind
25:set path=
26:find
27:w! ../test.out
28:close
29:new
30:set path=.
31:find
32:w >>../test.out
33:close
34:new
35:set path=.,,
36:find
37:w >>../test.out
38:close
39:new
40:set path=./**
41:find
42:w >>../test.out
43:close
44:new
45:" We shouldn't find any file at this point, ../test.out must be empty.
46:!mkdir in
47:cd in
48:!mkdir path
49:exec "cd " . cwd
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +020050:e Xfind/file.txt
Bram Moolenaar3ea5fa72010-08-04 18:27:57 +020051SHoly Grail:w
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +020052:e Xfind/in/file.txt
Bram Moolenaar3ea5fa72010-08-04 18:27:57 +020053SJimmy Hoffa:w
Bram Moolenaar84f888a2010-08-05 21:40:16 +020054:e Xfind/in/stuff.txt
55SAnother Holy Grail:w
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +020056:e Xfind/in/path/file.txt
Bram Moolenaar3ea5fa72010-08-04 18:27:57 +020057SE.T.:w
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +020058:set path=Xfind/**
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +020059:find file
Bram Moolenaar84f888a2010-08-05 21:40:16 +020060:w >> test.out
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +020061:find file
62:w >>test.out
63:find file
64:w >>test.out
Bram Moolenaar84f888a2010-08-05 21:40:16 +020065:" Rerun the previous three find completions, using fullpath in 'path'
66:exec "set path=" . cwd . "/Xfind/**"
67:find file
68:w >> test.out
69:find file
70:w >>test.out
71:find file
72:w >>test.out
73:" Same steps again, using relative and fullpath items that point to the same
74:" recursive location.
75:" This is to test that there are no duplicates in the completion list.
76:exec "set path+=Xfind/**"
77:find file
78:w >> test.out
79:find file
80:w >>test.out
81:find file
82:w >>test.out
83:find file
84:" Test find completion for directory of current buffer, which at this point
85:" is Xfind/in/file.txt.
86:set path=.
87:find st
88:w >> test.out
89:" Test find completion for empty path item ",," which is the current directory
90:cd Xfind
91:set path=,,
92:find f
93:w >> ../test.out
94:cd ..
95:q
96:call DeleteDirectory("Xfind")
Bram Moolenaar80a7dcf2010-08-04 17:07:20 +020097:qa!
98ENDTEST
99