annotate src/testdir/test_recover.vim @ 24091:12a773f4f62f v8.2.2587

patch 8.2.2587: recover test fails on FreeBSD Commit: https://github.com/vim/vim/commit/6635ae1437e6e343c0514524a8dfb19d9525b908 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 10 21:46:39 2021 +0100 patch 8.2.2587: recover test fails on FreeBSD Problem: Recover test fails on FreeBSD. Solution: Check for Linux.
author Bram Moolenaar <Bram@vim.org>
date Wed, 10 Mar 2021 22:00:03 +0100
parents cdeec1389c8c
children 467c3022fba6
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
24089
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
3 source check.vim
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
4
10896
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 func Test_recover_root_dir()
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 " 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
7 split Xtest
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 set dir=/
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 call assert_fails('recover', 'E305:')
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 close!
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11
11432
0cafb01af1b6 patch 8.0.0600: test_recover fails on some systems
Christian Brabandt <cb@256bit.org>
parents: 10898
diff changeset
12 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
13 " 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
14 set dir=/notexist/
cc3f6ad092c2 patch 8.0.0338: :recover test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10896
diff changeset
15 endif
10896
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 call assert_fails('split Xtest', 'E303:')
18372
11394af51615 patch 8.1.2180: Error E303 is not useful when 'directory' is empty
Bram Moolenaar <Bram@vim.org>
parents: 12644
diff changeset
17
11394af51615 patch 8.1.2180: Error E303 is not useful when 'directory' is empty
Bram Moolenaar <Bram@vim.org>
parents: 12644
diff changeset
18 " No error with empty 'directory' setting.
11394af51615 patch 8.1.2180: Error E303 is not useful when 'directory' is empty
Bram Moolenaar <Bram@vim.org>
parents: 12644
diff changeset
19 set directory=
11394af51615 patch 8.1.2180: Error E303 is not useful when 'directory' is empty
Bram Moolenaar <Bram@vim.org>
parents: 12644
diff changeset
20 split XtestOK
11394af51615 patch 8.1.2180: Error E303 is not useful when 'directory' is empty
Bram Moolenaar <Bram@vim.org>
parents: 12644
diff changeset
21 close!
11394af51615 patch 8.1.2180: Error E303 is not useful when 'directory' is empty
Bram Moolenaar <Bram@vim.org>
parents: 12644
diff changeset
22
10896
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 set dir&
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 endfunc
d513b653f5d0 patch 8.0.0337: invalid memory access in :recover command
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25
24089
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
26 " Make a copy of the current swap file to "Xswap".
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
27 " Return the name of the swap file.
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
28 func CopySwapfile()
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
29 preserve
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
30 " get the name of the swap file
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
31 let swname = split(execute("swapname"))[0]
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
32 let swname = substitute(swname, '[[:blank:][:cntrl:]]*\(.\{-}\)[[:blank:][:cntrl:]]*$', '\1', '')
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
33 " make a copy of the swap file in Xswap
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
34 set binary
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
35 exe 'sp ' . swname
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
36 w! Xswap
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
37 set nobinary
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
38 return swname
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
39 endfunc
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
40
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
41 " 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
42 " 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
43 "
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
44 " 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
45 " blocks.
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
46 func Test_swap_file()
12644
1fad9675d8fd patch 8.0.1200: tests switch the bell off twice
Christian Brabandt <cb@256bit.org>
parents: 12616
diff changeset
47 set fileformat=unix undolevels=-1
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
48 edit! Xtest
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
49 let text = "\tabcdefghijklmnoparstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnoparstuvwxyz0123456789"
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
50 let i = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
51 let linecount = 10000
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
52 while i <= linecount
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
53 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
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 endwhile
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
56 $delete
24089
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
57
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
58 let swname = CopySwapfile()
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
59
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
60 new
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
61 only!
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
62 bwipe! Xtest
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
63 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
64 recover Xtest
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
65 call delete(swname)
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
66 let linedollar = line('$')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
67 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
68 if linedollar < linecount
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
69 let linecount = linedollar
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
70 endif
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
71 let i = 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
72 while i <= linecount
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
73 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
74 let i += 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
75 endwhile
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
76
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
77 set undolevels&
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
78 enew! | only
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 11432
diff changeset
79 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 18372
diff changeset
80
24089
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
81 func Test_nocatch_process_still_running()
24091
12a773f4f62f patch 8.2.2587: recover test fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 24089
diff changeset
82 " sysinfo.uptime probably only works on Linux
12a773f4f62f patch 8.2.2587: recover test fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 24089
diff changeset
83 CheckLinux
12a773f4f62f patch 8.2.2587: recover test fails on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 24089
diff changeset
84 " the GUI dialog can't be handled
24089
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
85 CheckNotGui
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
86
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
87 " don't intercept existing swap file here
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
88 au! SwapExists
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
89
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
90 " Edit a file and grab its swapfile.
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
91 edit Xswaptest
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
92 call setline(1, ['a', 'b', 'c'])
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
93 let swname = CopySwapfile()
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
94
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
95 " Forget we edited this file
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
96 new
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
97 only!
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
98 bwipe! Xswaptest
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
99
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
100 call rename('Xswap', swname)
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
101 call feedkeys('e', 'tL')
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
102 redir => editOutput
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
103 edit Xswaptest
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
104 redir END
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
105 call assert_match('E325: ATTENTION', editOutput)
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
106 call assert_match('file name: .*Xswaptest', editOutput)
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
107 call assert_match('process ID: \d* (STILL RUNNING)', editOutput)
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
108
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
109 " Forget we edited this file
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
110 new
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
111 only!
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
112 bwipe! Xswaptest
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
113
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
114 " pretend we rebooted
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
115 call test_override("uptime", 0)
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
116 sleep 1
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
117
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
118 call rename('Xswap', swname)
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
119 call feedkeys('e', 'tL')
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
120 redir => editOutput
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
121 edit Xswaptest
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
122 redir END
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
123 call assert_match('E325: ATTENTION', editOutput)
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
124 call assert_notmatch('(STILL RUNNING)', editOutput)
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
125
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
126 call test_override("ALL", 0)
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
127 call delete(swname)
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
128 endfunc
cdeec1389c8c patch 8.2.2586: process id may be invalid
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
129
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 18372
diff changeset
130 " vim: shiftwidth=2 sts=2 expandtab