aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/testdir/Makefile2
-rw-r--r--src/nvim/testdir/test78.in46
-rw-r--r--src/nvim/testdir/test78.ok3
-rw-r--r--test/functional/legacy/078_swapfile_recover_spec.lua80
4 files changed, 81 insertions, 50 deletions
diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile
index a530e3cf23..0a7c16e2cb 100644
--- a/src/nvim/testdir/Makefile
+++ b/src/nvim/testdir/Makefile
@@ -24,7 +24,7 @@ SCRIPTS := test_autoformat_join.out \
test61.out test62.out test63.out test64.out test65.out \
test68.out test69.out \
test71.out test73.out test74.out \
- test76.out test78.out test79.out test80.out \
+ test76.out test79.out test80.out \
test82.out test83.out \
test86.out test87.out test88.out \
test96.out \
diff --git a/src/nvim/testdir/test78.in b/src/nvim/testdir/test78.in
deleted file mode 100644
index cb0e51edd5..0000000000
--- a/src/nvim/testdir/test78.in
+++ /dev/null
@@ -1,46 +0,0 @@
-Inserts 10000 lines with text to fill the swap file with two levels of pointer
-blocks. Then recovers from the swap file and checks all text is restored.
-
-We need about 10000 lines of 100 characters to get two levels of pointer
-blocks.
-
-STARTTEST
-:so small.vim
-:set fileformat=unix undolevels=-1
-:e! Xtest
-ggdG
-:let text = "\tabcdefghijklmnoparstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnoparstuvwxyz0123456789"
-:let i = 1
-:let linecount = 10000
-:while i <= linecount | call append(i - 1, i . text) | let i += 1 | endwhile
-:preserve
-:" get the name of the swap file
-:redir => swapname
-:swapname
-:redir END
-:let swapname = substitute(swapname, '[[:blank:][:cntrl:]]*\(.\{-}\)[[:blank:][:cntrl:]]*$', '\1', '')
-:" make a copy of the swap file in Xswap
-:set bin
-:exe 'sp ' . swapname
-:w! Xswap
-:echo swapname
-:set nobin
-:new
-:only!
-:bwipe! Xtest
-:call rename('Xswap', swapname)
-:recover Xtest
-:call delete(swapname)
-:new
-:call append(0, 'recovery start')
-:wincmd w
-:let linedollar = line('$')
-:if linedollar < linecount | exe 'wincmd w' | call append(line('$'), "expected " . linecount . " lines but found only " . linedollar) | exe 'wincmd w' | let linecount = linedollar | endif
-:let i = 1
-:while i <= linecount | if getline(i) != i . text | exe 'wincmd w' | call append(line('$'), i . ' differs') | exe 'wincmd w' | endif | let i += 1 | endwhile
-:q!
-:call append(line('$'), 'recovery end')
-:w! test.out
-:qa!
-ENDTEST
-
diff --git a/src/nvim/testdir/test78.ok b/src/nvim/testdir/test78.ok
deleted file mode 100644
index 6c3ecefe3c..0000000000
--- a/src/nvim/testdir/test78.ok
+++ /dev/null
@@ -1,3 +0,0 @@
-recovery start
-
-recovery end
diff --git a/test/functional/legacy/078_swapfile_recover_spec.lua b/test/functional/legacy/078_swapfile_recover_spec.lua
new file mode 100644
index 0000000000..e250c91441
--- /dev/null
+++ b/test/functional/legacy/078_swapfile_recover_spec.lua
@@ -0,0 +1,80 @@
+-- Inserts 10000 lines with text to fill the swap file with two levels of
+-- pointer blocks. Then recovers from the swap file and checks all text is
+-- restored. We need about 10000 lines of 100 characters to get two levels of
+-- pointer blocks.
+
+local helpers = require('test.functional.helpers')
+local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local clear, execute, expect, source = helpers.clear, helpers.execute, helpers.expect, helpers.source
+local eval = helpers.eval
+
+describe('78', function()
+ setup(clear)
+ teardown(function()
+ os.remove(".Xtest.swp")
+ os.remove(".Xtest.swo")
+ end)
+
+ it('is working', function()
+ source([=[
+ set swapfile fileformat=unix undolevels=-1
+ e! Xtest
+ let text = "\tabcdefghijklmnoparstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnoparstuvwxyz0123456789"
+ let i = 1
+ let linecount = 10000
+ while i <= linecount | call append(i - 1, i . text) | let i += 1 | endwhile
+ preserve
+
+ " Get the name of the swap file, and clean up the :redir capture.
+ redir => g:swapname | swapname | redir END
+ let g:swapname = substitute(g:swapname, '[[:blank:][:cntrl:]]*\(.\{-}\)[[:blank:][:cntrl:]]*$', '\1', 'g')
+ let g:swapname = fnameescape(g:swapname)
+
+ " Make a copy of the swap file in Xswap
+ set bin
+ exe 'sp ' . g:swapname
+ w! Xswap
+
+ set nobin
+ new
+ only!
+ bwipe! Xtest
+ call rename('Xswap', g:swapname)
+
+ "TODO(jkeyes): without 'silent', this hangs the test " at message:
+ " 'Recovery completed. You should check if everything is OK.'
+ silent recover Xtest
+
+ call delete(g:swapname)
+ new
+ call append(0, 'recovery start')
+ wincmd w
+
+ let g:linedollar = line('$')
+ if g:linedollar < linecount
+ wincmd w
+ call append(line('$'), "expected " . linecount
+ \ . " lines but found only " . g:linedollar)
+ wincmd w
+ let linecount = g:linedollar
+ endif
+
+ let i = 1
+ while i <= linecount
+ if getline(i) != i . text
+ exe 'wincmd w'
+ call append(line('$'), i . ' differs')
+ exe 'wincmd w'
+ endif
+ let i += 1
+ endwhile
+ q!
+ call append(line('$'), 'recovery end')
+ ]=])
+
+ expect([[
+ recovery start
+
+ recovery end]])
+ end)
+end)