097_glob_path_spec.lua (2307B)
1 -- vim: set foldmethod=marker foldmarker=[[,]] : 2 -- Test whether glob()/globpath() return correct results with certain escaped 3 -- characters. 4 5 local t = require('test.testutil') 6 local n = require('test.functional.testnvim')() 7 8 local clear = n.clear 9 local command, expect = n.command, n.expect 10 11 describe('glob() and globpath()', function() 12 setup(clear) 13 14 setup(function() 15 if t.is_os('win') then 16 os.execute('md sautest\\autoload') 17 os.execute('.>sautest\\autoload\\Test104.vim 2>nul') 18 os.execute('.>sautest\\autoload\\footest.vim 2>nul') 19 else 20 os.execute('mkdir -p sautest/autoload') 21 os.execute('touch sautest/autoload/Test104.vim') 22 os.execute('touch sautest/autoload/footest.vim') 23 end 24 end) 25 26 it('is working', function() 27 -- Make sure glob() doesn't use the shell 28 command('set shell=doesnotexist') 29 30 -- Consistent sorting of file names 31 command('set nofileignorecase') 32 33 if t.is_os('win') then 34 command([[$put =glob('Xxx{')]]) 35 command([[$put =glob('Xxx$')]]) 36 37 command('silent w! Xxx{') 38 command([[w! Xxx$]]) 39 command([[$put =glob('Xxx{')]]) 40 command([[$put =glob('Xxx$')]]) 41 42 command([[$put =string(globpath('sautest\autoload', '*.vim'))]]) 43 command([[$put =string(globpath('sautest\autoload', '*.vim', 0, 1))]]) 44 expect([=[ 45 46 47 48 Xxx{ 49 Xxx$ 50 'sautest\autoload\Test104.vim 51 sautest\autoload\footest.vim' 52 ['sautest\autoload\Test104.vim', 'sautest\autoload\footest.vim']]=]) 53 else 54 command([[$put =glob('Xxx\{')]]) 55 command([[$put =glob('Xxx\$')]]) 56 57 command('silent w! Xxx\\{') 58 command([[w! Xxx\$]]) 59 command([[$put =glob('Xxx\{')]]) 60 command([[$put =glob('Xxx\$')]]) 61 62 command("$put =string(globpath('sautest/autoload', '*.vim'))") 63 command("$put =string(globpath('sautest/autoload', '*.vim', 0, 1))") 64 expect([=[ 65 66 67 68 Xxx{ 69 Xxx$ 70 'sautest/autoload/Test104.vim 71 sautest/autoload/footest.vim' 72 ['sautest/autoload/Test104.vim', 'sautest/autoload/footest.vim']]=]) 73 end 74 end) 75 76 teardown(function() 77 if t.is_os('win') then 78 os.execute('del /q/f Xxx{ Xxx$') 79 os.execute('rd /q /s sautest') 80 else 81 os.execute('rm -rf sautest Xxx{ Xxx$') 82 end 83 end) 84 end)