neovim/test/functional/legacy/097_glob_path_spec.lua

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
2.2 KiB
Lua
Raw Normal View History

2014-10-27 09:45:52 -07:00
-- vim: set foldmethod=marker foldmarker=[[,]] :
-- Test whether glob()/globpath() return correct results with certain escaped
-- characters.
local t = require('test.functional.testutil')()
local clear = t.clear
local command, expect = t.command, t.expect
2014-10-27 09:45:52 -07:00
describe('glob() and globpath()', function()
setup(clear)
setup(function()
if t.is_os('win') then
2017-10-11 19:56:11 -07:00
os.execute('md sautest\\autoload')
os.execute('.>sautest\\autoload\\Test104.vim 2>nul')
os.execute('.>sautest\\autoload\\footest.vim 2>nul')
else
os.execute('mkdir -p sautest/autoload')
os.execute('touch sautest/autoload/Test104.vim')
os.execute('touch sautest/autoload/footest.vim')
end
2014-10-27 09:45:52 -07:00
end)
it('is working', function()
-- Make sure glob() doesn't use the shell
command('set shell=doesnotexist')
2014-10-27 09:45:52 -07:00
-- Consistent sorting of file names
command('set nofileignorecase')
2014-10-27 09:45:52 -07:00
if t.is_os('win') then
2017-10-11 19:56:11 -07:00
command([[$put =glob('Xxx{')]])
command([[$put =glob('Xxx$')]])
command('silent w! Xxx{')
command([[w! Xxx$]])
command([[$put =glob('Xxx{')]])
command([[$put =glob('Xxx$')]])
command([[$put =string(globpath('sautest\autoload', '*.vim'))]])
command([[$put =string(globpath('sautest\autoload', '*.vim', 0, 1))]])
expect([=[
2014-10-27 09:45:52 -07:00
2017-10-11 19:56:11 -07:00
Xxx{
Xxx$
'sautest\autoload\Test104.vim
sautest\autoload\footest.vim'
['sautest\autoload\Test104.vim', 'sautest\autoload\footest.vim']]=])
else
command([[$put =glob('Xxx\{')]])
command([[$put =glob('Xxx\$')]])
2014-10-27 09:45:52 -07:00
command('silent w! Xxx\\{')
2017-10-11 19:56:11 -07:00
command([[w! Xxx\$]])
command([[$put =glob('Xxx\{')]])
command([[$put =glob('Xxx\$')]])
2014-10-27 09:45:52 -07:00
2017-10-11 19:56:11 -07:00
command("$put =string(globpath('sautest/autoload', '*.vim'))")
command("$put =string(globpath('sautest/autoload', '*.vim', 0, 1))")
expect([=[
2017-10-11 19:56:11 -07:00
Xxx{
Xxx$
'sautest/autoload/Test104.vim
sautest/autoload/footest.vim'
['sautest/autoload/Test104.vim', 'sautest/autoload/footest.vim']]=])
end
2014-10-27 09:45:52 -07:00
end)
teardown(function()
if t.is_os('win') then
2017-10-11 19:56:11 -07:00
os.execute('del /q/f Xxx{ Xxx$')
2018-05-20 12:08:55 -07:00
os.execute('rd /q /s sautest')
2017-10-11 19:56:11 -07:00
else
os.execute('rm -rf sautest Xxx{ Xxx$')
end
2014-10-27 09:45:52 -07:00
end)
end)