Bram Moolenaar | 80a7dcf | 2010-08-04 17:07:20 +0200 | [diff] [blame] | 1 | Tests for find completion. |
| 2 | |
| 3 | STARTTEST |
Bram Moolenaar | 84f888a | 2010-08-05 21:40:16 +0200 | [diff] [blame^] | 4 | :" 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 Moolenaar | 3ea5fa7 | 2010-08-04 18:27:57 +0200 | [diff] [blame] | 23 | :!mkdir Xfind |
Bram Moolenaar | 84f888a | 2010-08-05 21:40:16 +0200 | [diff] [blame^] | 24 | :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 Moolenaar | 80a7dcf | 2010-08-04 17:07:20 +0200 | [diff] [blame] | 50 | :e Xfind/file.txt |
Bram Moolenaar | 3ea5fa7 | 2010-08-04 18:27:57 +0200 | [diff] [blame] | 51 | SHoly Grail:w |
Bram Moolenaar | 80a7dcf | 2010-08-04 17:07:20 +0200 | [diff] [blame] | 52 | :e Xfind/in/file.txt |
Bram Moolenaar | 3ea5fa7 | 2010-08-04 18:27:57 +0200 | [diff] [blame] | 53 | SJimmy Hoffa:w |
Bram Moolenaar | 84f888a | 2010-08-05 21:40:16 +0200 | [diff] [blame^] | 54 | :e Xfind/in/stuff.txt |
| 55 | SAnother Holy Grail:w |
Bram Moolenaar | 80a7dcf | 2010-08-04 17:07:20 +0200 | [diff] [blame] | 56 | :e Xfind/in/path/file.txt |
Bram Moolenaar | 3ea5fa7 | 2010-08-04 18:27:57 +0200 | [diff] [blame] | 57 | SE.T.:w |
Bram Moolenaar | 80a7dcf | 2010-08-04 17:07:20 +0200 | [diff] [blame] | 58 | :set path=Xfind/** |
Bram Moolenaar | 80a7dcf | 2010-08-04 17:07:20 +0200 | [diff] [blame] | 59 | :find file |
Bram Moolenaar | 84f888a | 2010-08-05 21:40:16 +0200 | [diff] [blame^] | 60 | :w >> test.out |
Bram Moolenaar | 80a7dcf | 2010-08-04 17:07:20 +0200 | [diff] [blame] | 61 | :find file |
| 62 | :w >>test.out |
| 63 | :find file |
| 64 | :w >>test.out |
Bram Moolenaar | 84f888a | 2010-08-05 21:40:16 +0200 | [diff] [blame^] | 65 | :" 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 Moolenaar | 80a7dcf | 2010-08-04 17:07:20 +0200 | [diff] [blame] | 97 | :qa! |
| 98 | ENDTEST |
| 99 | |