annotate src/testdir/test_recover.vim @ 12616:4767939d10cc v8.0.1186

patch 8.0.1186: still quite a few old style tests commit https://github.com/vim/vim/commit/4a6fcf8047de13c7949ab2f27f7774acaec4ae4d Author: Bram Moolenaar <Bram@vim.org> Date: Thu Oct 12 21:29:22 2017 +0200 patch 8.0.1186: still quite a few old style tests Problem: Still quite a few old style tests. Solution: Convert old to new style tests. (Yegappan Lakshmanan) Avoid ringing the bell while running tests.
author Christian Brabandt <cb@256bit.org>
date Thu, 12 Oct 2017 21:30:07 +0200
parents 0cafb01af1b6
children 1fad9675d8fd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10896
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test :recover
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 func Test_recover_root_dir()
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 " This used to access invalid memory.
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 split Xtest
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 set dir=/
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 call assert_fails('recover', 'E305:')
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 close!
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
11432
0cafb01af1b6 patch 8.0.0600: test_recover fails on some systems
Christian Brabandt <cb@256bit.org>
parents: 10898
diff changeset
10 if has('win32') || filewritable('/') == 2
10898
cc3f6ad092c2 patch 8.0.0338: :recover test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10896
diff changeset
11 " can write in / directory on MS-Windows
cc3f6ad092c2 patch 8.0.0338: :recover test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10896
diff changeset
12 set dir=/notexist/
cc3f6ad092c2 patch 8.0.0338: :recover test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10896
diff changeset
13 endif
10896
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 call assert_fails('split Xtest', 'E303:')
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 set dir&
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 endfunc
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
18 " Inserts 10000 lines with text to fill the swap file with two levels of pointer
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
19 " blocks. Then recovers from the swap file and checks all text is restored.
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
20 "
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
21 " We need about 10000 lines of 100 characters to get two levels of pointer
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
22 " blocks.
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
23 func Test_swap_file()
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
24 set fileformat=unix undolevels=-1 belloff=all
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
25 edit! Xtest
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
26 let text = "\tabcdefghijklmnoparstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnoparstuvwxyz0123456789"
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
27 let i = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
28 let linecount = 10000
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
29 while i <= linecount
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
30 call append(i - 1, i . text)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
31 let i += 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
32 endwhile
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
33 $delete
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
34 preserve
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
35 " get the name of the swap file
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
36 let swname = split(execute("swapname"))[0]
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
37 let swname = substitute(swname, '[[:blank:][:cntrl:]]*\(.\{-}\)[[:blank:][:cntrl:]]*$', '\1', '')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
38 " make a copy of the swap file in Xswap
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
39 set binary
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
40 exe 'sp ' . swname
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
41 w! Xswap
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
42 set nobinary
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
43 new
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
44 only!
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
45 bwipe! Xtest
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
46 call rename('Xswap', swname)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
47 recover Xtest
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
48 call delete(swname)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
49 let linedollar = line('$')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
50 call assert_equal(linecount, linedollar)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
51 if linedollar < linecount
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
52 let linecount = linedollar
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
53 endif
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
54 let i = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
55 while i <= linecount
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
56 call assert_equal(i . text, getline(i))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
57 let i += 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
58 endwhile
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
59
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
60 set undolevels&
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
61 enew! | only
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
62 endfunc