mirror of
https://github.com/neovim/neovim.git
synced 2025-01-01 17:23:36 -07:00
tests: migrate legacy test 12. #4196
This commit is contained in:
parent
7b6786f6f9
commit
4a6b4bbf93
@ -9,7 +9,6 @@ SCRIPTSOURCE := ../../../runtime
|
|||||||
|
|
||||||
SCRIPTS := \
|
SCRIPTS := \
|
||||||
test8.out \
|
test8.out \
|
||||||
test12.out \
|
|
||||||
test13.out \
|
test13.out \
|
||||||
test14.out \
|
test14.out \
|
||||||
test17.out \
|
test17.out \
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
Tests for 'directory' option.
|
|
||||||
- ".", in same dir as file
|
|
||||||
- "./dir", in directory relative to file
|
|
||||||
- "dir", in directory relative to current dir
|
|
||||||
|
|
||||||
STARTTEST
|
|
||||||
:set dir=.,~
|
|
||||||
:/start of testfile/,/end of testfile/w! Xtest1
|
|
||||||
:" do an ls of the current dir to find the swap file (should not be there)
|
|
||||||
:if has("unix")
|
|
||||||
: !ls .X*.swp >test.out
|
|
||||||
:else
|
|
||||||
: r !ls X*.swp >test.out
|
|
||||||
:endif
|
|
||||||
:!echo first line >>test.out
|
|
||||||
:e Xtest1
|
|
||||||
:if has("unix")
|
|
||||||
:" Do an ls of the current dir to find the swap file, remove the leading dot
|
|
||||||
:" to make the result the same for all systems.
|
|
||||||
: r!ls .X*.swp
|
|
||||||
: s/\.*X/X/
|
|
||||||
: .w >>test.out
|
|
||||||
: undo
|
|
||||||
:else
|
|
||||||
: !ls X*.swp >>test.out
|
|
||||||
:endif
|
|
||||||
:!echo under Xtest1.swp >>test.out
|
|
||||||
:!mkdir Xtest2
|
|
||||||
:set dir=./Xtest2,.,~
|
|
||||||
:e Xtest1
|
|
||||||
:!ls X*.swp >>test.out
|
|
||||||
:!echo under under >>test.out
|
|
||||||
:!ls Xtest2 >>test.out
|
|
||||||
:!echo under Xtest1.swp >>test.out
|
|
||||||
:!mkdir Xtest.je
|
|
||||||
:/start of testfile/,/end of testfile/w! Xtest2/Xtest3
|
|
||||||
:set dir=Xtest.je,~
|
|
||||||
:e Xtest2/Xtest3
|
|
||||||
:swap
|
|
||||||
:!ls Xtest2 >>test.out
|
|
||||||
:!echo under Xtest3 >>test.out
|
|
||||||
:!ls Xtest.je >>test.out
|
|
||||||
:!echo under Xtest3.swp >>test.out
|
|
||||||
:qa!
|
|
||||||
ENDTEST
|
|
||||||
|
|
||||||
start of testfile
|
|
||||||
line 2 Abcdefghij
|
|
||||||
line 3 Abcdefghij
|
|
||||||
end of testfile
|
|
@ -1,10 +0,0 @@
|
|||||||
first line
|
|
||||||
Xtest1.swp
|
|
||||||
under Xtest1.swp
|
|
||||||
under under
|
|
||||||
Xtest1.swp
|
|
||||||
under Xtest1.swp
|
|
||||||
Xtest3
|
|
||||||
under Xtest3
|
|
||||||
Xtest3.swp
|
|
||||||
under Xtest3.swp
|
|
88
test/functional/legacy/012_directory_spec.lua
Normal file
88
test/functional/legacy/012_directory_spec.lua
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
-- Tests for 'directory' option.
|
||||||
|
-- - ".", in same dir as file
|
||||||
|
-- - "./dir", in directory relative to file
|
||||||
|
-- - "dir", in directory relative to current dir
|
||||||
|
|
||||||
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
|
local lfs = require('lfs')
|
||||||
|
local insert, eq = helpers.insert, helpers.eq
|
||||||
|
local neq, eval = helpers.neq, helpers.eval
|
||||||
|
local clear, execute = helpers.clear, helpers.execute
|
||||||
|
local wait, write_file = helpers.wait, helpers.write_file
|
||||||
|
|
||||||
|
local function ls_dir_sorted(dirname)
|
||||||
|
local files = {}
|
||||||
|
for f in lfs.dir(dirname) do
|
||||||
|
if f ~= "." and f~= ".." then
|
||||||
|
table.insert(files, f)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.sort(files)
|
||||||
|
return files
|
||||||
|
end
|
||||||
|
|
||||||
|
describe("'directory' option", function()
|
||||||
|
setup(function()
|
||||||
|
local text = [[
|
||||||
|
start of testfile
|
||||||
|
line 2 Abcdefghij
|
||||||
|
line 3 Abcdefghij
|
||||||
|
end of testfile
|
||||||
|
]]
|
||||||
|
write_file('Xtest1', text)
|
||||||
|
lfs.mkdir('Xtest.je')
|
||||||
|
lfs.mkdir('Xtest2')
|
||||||
|
write_file('Xtest2/Xtest3', text)
|
||||||
|
clear()
|
||||||
|
end)
|
||||||
|
teardown(function()
|
||||||
|
helpers.rmdir('Xtest.je')
|
||||||
|
helpers.rmdir('Xtest2')
|
||||||
|
os.remove('Xtest1')
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('is working', function()
|
||||||
|
insert([[
|
||||||
|
start of testfile
|
||||||
|
line 2 Abcdefghij
|
||||||
|
line 3 Abcdefghij
|
||||||
|
end of testfile]])
|
||||||
|
|
||||||
|
execute('set swapfile')
|
||||||
|
execute('set dir=.,~')
|
||||||
|
|
||||||
|
-- sanity check: files should not exist yet.
|
||||||
|
eq(nil, lfs.attributes('.Xtest1.swp')) -- unix
|
||||||
|
eq(nil, lfs.attributes('Xtest1.swp')) -- non-unix
|
||||||
|
|
||||||
|
execute('e! Xtest1')
|
||||||
|
wait()
|
||||||
|
eq('Xtest1', eval('buffer_name("%")'))
|
||||||
|
-- Verify that the swapfile exists. In the legacy test this was done by
|
||||||
|
-- reading the output from :!ls.
|
||||||
|
if eval('has("unix")') == 1 then
|
||||||
|
neq(nil, lfs.attributes('.Xtest1.swp'))
|
||||||
|
else
|
||||||
|
neq(nil, lfs.attributes('Xtest1.swp'))
|
||||||
|
end
|
||||||
|
|
||||||
|
execute('set dir=./Xtest2,.,~')
|
||||||
|
execute('e Xtest1')
|
||||||
|
wait()
|
||||||
|
|
||||||
|
-- swapfile should no longer exist in CWD.
|
||||||
|
eq(nil, lfs.attributes('.Xtest1.swp')) -- for unix
|
||||||
|
eq(nil, lfs.attributes('Xtest1.swp')) -- for other systems
|
||||||
|
|
||||||
|
eq({ "Xtest1.swp", "Xtest3" }, ls_dir_sorted("Xtest2"))
|
||||||
|
|
||||||
|
execute('set dir=Xtest.je,~')
|
||||||
|
execute('e Xtest2/Xtest3')
|
||||||
|
eq(1, eval('&swapfile'))
|
||||||
|
execute('swap')
|
||||||
|
wait()
|
||||||
|
|
||||||
|
eq({ "Xtest3" }, ls_dir_sorted("Xtest2"))
|
||||||
|
eq({ "Xtest3.swp" }, ls_dir_sorted("Xtest.je"))
|
||||||
|
end)
|
||||||
|
end)
|
Loading…
Reference in New Issue
Block a user