Bram Moolenaar | 66459b7 | 2016-08-06 19:01:55 +0200 | [diff] [blame] | 1 | " Tests for startup. |
Bram Moolenaar | b9a46fe | 2016-07-29 18:13:42 +0200 | [diff] [blame] | 2 | |
Bram Moolenaar | 66459b7 | 2016-08-06 19:01:55 +0200 | [diff] [blame] | 3 | source shared.vim |
Bram Moolenaar | c75e812 | 2019-04-21 15:55:10 +0200 | [diff] [blame] | 4 | source screendump.vim |
Bram Moolenaar | cde0ff3 | 2020-04-04 14:00:39 +0200 | [diff] [blame] | 5 | source term_util.vim |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 6 | source check.vim |
Bram Moolenaar | 66459b7 | 2016-08-06 19:01:55 +0200 | [diff] [blame] | 7 | |
| 8 | " Check that loading startup.vim works. |
Bram Moolenaar | b9a46fe | 2016-07-29 18:13:42 +0200 | [diff] [blame] | 9 | func Test_startup_script() |
| 10 | set compatible |
| 11 | source $VIMRUNTIME/defaults.vim |
| 12 | |
| 13 | call assert_equal(0, &compatible) |
Bram Moolenaar | cde0ff3 | 2020-04-04 14:00:39 +0200 | [diff] [blame] | 14 | " Restore some options, so that the following tests doesn't break |
| 15 | set nomore |
| 16 | set noshowmode |
Bram Moolenaar | b9a46fe | 2016-07-29 18:13:42 +0200 | [diff] [blame] | 17 | endfunc |
Bram Moolenaar | 66459b7 | 2016-08-06 19:01:55 +0200 | [diff] [blame] | 18 | |
| 19 | " Verify the order in which plugins are loaded: |
| 20 | " 1. plugins in non-after directories |
| 21 | " 2. packages |
| 22 | " 3. plugins in after directories |
| 23 | func Test_after_comes_later() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 24 | CheckFeature packages |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 25 | let before =<< trim [CODE] |
| 26 | set nocp viminfo+=nviminfo |
| 27 | set guioptions+=M |
| 28 | let $HOME = "/does/not/exist" |
| 29 | set loadplugins |
| 30 | set rtp=Xhere,Xafter,Xanother |
| 31 | set packpath=Xhere,Xafter |
| 32 | set nomore |
| 33 | let g:sequence = "" |
| 34 | [CODE] |
| 35 | |
| 36 | let after =<< trim [CODE] |
| 37 | redir! > Xtestout |
| 38 | scriptnames |
| 39 | redir END |
| 40 | redir! > Xsequence |
| 41 | echo g:sequence |
| 42 | redir END |
| 43 | quit |
| 44 | [CODE] |
| 45 | |
Bram Moolenaar | 66459b7 | 2016-08-06 19:01:55 +0200 | [diff] [blame] | 46 | call mkdir('Xhere/plugin', 'p') |
Bram Moolenaar | 07ecfa6 | 2017-06-27 14:43:55 +0200 | [diff] [blame] | 47 | call writefile(['let g:sequence .= "here "'], 'Xhere/plugin/here.vim') |
| 48 | call mkdir('Xanother/plugin', 'p') |
| 49 | call writefile(['let g:sequence .= "another "'], 'Xanother/plugin/another.vim') |
Bram Moolenaar | 66459b7 | 2016-08-06 19:01:55 +0200 | [diff] [blame] | 50 | call mkdir('Xhere/pack/foo/start/foobar/plugin', 'p') |
Bram Moolenaar | 07ecfa6 | 2017-06-27 14:43:55 +0200 | [diff] [blame] | 51 | call writefile(['let g:sequence .= "pack "'], 'Xhere/pack/foo/start/foobar/plugin/foo.vim') |
Bram Moolenaar | 66459b7 | 2016-08-06 19:01:55 +0200 | [diff] [blame] | 52 | |
| 53 | call mkdir('Xafter/plugin', 'p') |
Bram Moolenaar | 07ecfa6 | 2017-06-27 14:43:55 +0200 | [diff] [blame] | 54 | call writefile(['let g:sequence .= "after "'], 'Xafter/plugin/later.vim') |
Bram Moolenaar | 66459b7 | 2016-08-06 19:01:55 +0200 | [diff] [blame] | 55 | |
Bram Moolenaar | 472a0a8 | 2016-08-06 22:31:42 +0200 | [diff] [blame] | 56 | if RunVim(before, after, '') |
Bram Moolenaar | 66459b7 | 2016-08-06 19:01:55 +0200 | [diff] [blame] | 57 | |
Bram Moolenaar | 83b3c3d | 2016-08-06 19:16:43 +0200 | [diff] [blame] | 58 | let lines = readfile('Xtestout') |
Bram Moolenaar | 07ecfa6 | 2017-06-27 14:43:55 +0200 | [diff] [blame] | 59 | let expected = ['Xbefore.vim', 'here.vim', 'another.vim', 'foo.vim', 'later.vim', 'Xafter.vim'] |
Bram Moolenaar | 83b3c3d | 2016-08-06 19:16:43 +0200 | [diff] [blame] | 60 | let found = [] |
| 61 | for line in lines |
| 62 | for one in expected |
| 63 | if line =~ one |
| 64 | call add(found, one) |
| 65 | endif |
| 66 | endfor |
Bram Moolenaar | 66459b7 | 2016-08-06 19:01:55 +0200 | [diff] [blame] | 67 | endfor |
Bram Moolenaar | 83b3c3d | 2016-08-06 19:16:43 +0200 | [diff] [blame] | 68 | call assert_equal(expected, found) |
| 69 | endif |
Bram Moolenaar | 66459b7 | 2016-08-06 19:01:55 +0200 | [diff] [blame] | 70 | |
Bram Moolenaar | 07ecfa6 | 2017-06-27 14:43:55 +0200 | [diff] [blame] | 71 | call assert_equal('here another pack after', substitute(join(readfile('Xsequence', 1), ''), '\s\+$', '', '')) |
| 72 | |
Bram Moolenaar | 66459b7 | 2016-08-06 19:01:55 +0200 | [diff] [blame] | 73 | call delete('Xtestout') |
Bram Moolenaar | 07ecfa6 | 2017-06-27 14:43:55 +0200 | [diff] [blame] | 74 | call delete('Xsequence') |
Bram Moolenaar | 66459b7 | 2016-08-06 19:01:55 +0200 | [diff] [blame] | 75 | call delete('Xhere', 'rf') |
Bram Moolenaar | 07ecfa6 | 2017-06-27 14:43:55 +0200 | [diff] [blame] | 76 | call delete('Xanother', 'rf') |
Bram Moolenaar | 66459b7 | 2016-08-06 19:01:55 +0200 | [diff] [blame] | 77 | call delete('Xafter', 'rf') |
| 78 | endfunc |
Bram Moolenaar | 472a0a8 | 2016-08-06 22:31:42 +0200 | [diff] [blame] | 79 | |
Bram Moolenaar | ce876aa | 2017-06-04 17:47:42 +0200 | [diff] [blame] | 80 | func Test_pack_in_rtp_when_plugins_run() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 81 | CheckFeature packages |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 82 | let before =<< trim [CODE] |
| 83 | set nocp viminfo+=nviminfo |
| 84 | set guioptions+=M |
| 85 | let $HOME = "/does/not/exist" |
| 86 | set loadplugins |
| 87 | set rtp=Xhere |
| 88 | set packpath=Xhere |
| 89 | set nomore |
| 90 | [CODE] |
| 91 | |
Bram Moolenaar | ce876aa | 2017-06-04 17:47:42 +0200 | [diff] [blame] | 92 | let after = [ |
| 93 | \ 'quit', |
| 94 | \ ] |
| 95 | call mkdir('Xhere/plugin', 'p') |
| 96 | call writefile(['redir! > Xtestout', 'silent set runtimepath?', 'silent! call foo#Trigger()', 'redir END'], 'Xhere/plugin/here.vim') |
| 97 | call mkdir('Xhere/pack/foo/start/foobar/autoload', 'p') |
| 98 | call writefile(['function! foo#Trigger()', 'echo "autoloaded foo"', 'endfunction'], 'Xhere/pack/foo/start/foobar/autoload/foo.vim') |
| 99 | |
| 100 | if RunVim(before, after, '') |
| 101 | |
| 102 | let lines = filter(readfile('Xtestout'), '!empty(v:val)') |
| 103 | call assert_match('Xhere[/\\]pack[/\\]foo[/\\]start[/\\]foobar', get(lines, 0)) |
| 104 | call assert_match('autoloaded foo', get(lines, 1)) |
| 105 | endif |
| 106 | |
| 107 | call delete('Xtestout') |
| 108 | call delete('Xhere', 'rf') |
| 109 | endfunc |
| 110 | |
Bram Moolenaar | 472a0a8 | 2016-08-06 22:31:42 +0200 | [diff] [blame] | 111 | func Test_help_arg() |
Bram Moolenaar | 3214812 | 2021-03-16 13:23:30 +0100 | [diff] [blame] | 112 | if !has('unix') && has('gui_running') |
| 113 | throw 'Skipped: does not work with gvim on MS-Windows' |
| 114 | endif |
Bram Moolenaar | 240309c | 2021-03-14 16:20:37 +0100 | [diff] [blame] | 115 | |
Bram Moolenaar | 472a0a8 | 2016-08-06 22:31:42 +0200 | [diff] [blame] | 116 | if RunVim([], [], '--help >Xtestout') |
| 117 | let lines = readfile('Xtestout') |
| 118 | call assert_true(len(lines) > 20) |
Bram Moolenaar | ba98bef | 2016-08-07 15:51:39 +0200 | [diff] [blame] | 119 | call assert_match('Vi IMproved', lines[0]) |
Bram Moolenaar | 472a0a8 | 2016-08-06 22:31:42 +0200 | [diff] [blame] | 120 | |
| 121 | " check if couple of lines are there |
Bram Moolenaar | 50fa8dd | 2016-08-09 22:58:21 +0200 | [diff] [blame] | 122 | let found = [] |
Bram Moolenaar | 472a0a8 | 2016-08-06 22:31:42 +0200 | [diff] [blame] | 123 | for line in lines |
| 124 | if line =~ '-R.*Readonly mode' |
Bram Moolenaar | 50fa8dd | 2016-08-09 22:58:21 +0200 | [diff] [blame] | 125 | call add(found, 'Readonly mode') |
Bram Moolenaar | 472a0a8 | 2016-08-06 22:31:42 +0200 | [diff] [blame] | 126 | endif |
Bram Moolenaar | 50fa8dd | 2016-08-09 22:58:21 +0200 | [diff] [blame] | 127 | " Watch out for a second --version line in the Gnome version. |
| 128 | if line =~ '--version.*Print version information and exit' |
| 129 | call add(found, "--version") |
Bram Moolenaar | 472a0a8 | 2016-08-06 22:31:42 +0200 | [diff] [blame] | 130 | endif |
| 131 | endfor |
Bram Moolenaar | 50fa8dd | 2016-08-09 22:58:21 +0200 | [diff] [blame] | 132 | call assert_equal(['Readonly mode', '--version'], found) |
Bram Moolenaar | 472a0a8 | 2016-08-06 22:31:42 +0200 | [diff] [blame] | 133 | endif |
| 134 | call delete('Xtestout') |
| 135 | endfunc |
Bram Moolenaar | ba98bef | 2016-08-07 15:51:39 +0200 | [diff] [blame] | 136 | |
| 137 | func Test_compatible_args() |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 138 | let after =<< trim [CODE] |
| 139 | call writefile([string(&compatible)], "Xtestout") |
| 140 | set viminfo+=nviminfo |
| 141 | quit |
| 142 | [CODE] |
| 143 | |
Bram Moolenaar | ba98bef | 2016-08-07 15:51:39 +0200 | [diff] [blame] | 144 | if RunVim([], after, '-C') |
| 145 | let lines = readfile('Xtestout') |
| 146 | call assert_equal('1', lines[0]) |
| 147 | endif |
| 148 | |
| 149 | if RunVim([], after, '-N') |
| 150 | let lines = readfile('Xtestout') |
| 151 | call assert_equal('0', lines[0]) |
| 152 | endif |
| 153 | |
| 154 | call delete('Xtestout') |
| 155 | endfunc |
| 156 | |
Bram Moolenaar | 8f4499b | 2018-09-16 16:28:11 +0200 | [diff] [blame] | 157 | " Test the -o[N] and -O[N] arguments to open N windows split |
| 158 | " horizontally or vertically. |
| 159 | func Test_o_arg() |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 160 | let after =<< trim [CODE] |
Bram Moolenaar | e96a249 | 2019-06-25 04:12:16 +0200 | [diff] [blame] | 161 | set cpo&vim |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 162 | call writefile([winnr("$"), |
| 163 | \ winheight(1), winheight(2), &lines, |
| 164 | \ winwidth(1), winwidth(2), &columns, |
| 165 | \ bufname(winbufnr(1)), bufname(winbufnr(2))], |
| 166 | \ "Xtestout") |
| 167 | qall |
| 168 | [CODE] |
| 169 | |
Bram Moolenaar | 8f4499b | 2018-09-16 16:28:11 +0200 | [diff] [blame] | 170 | if RunVim([], after, '-o2') |
| 171 | " Open 2 windows split horizontally. Expect: |
| 172 | " - 2 windows |
| 173 | " - both windows should have the same or almost the same height |
| 174 | " - sum of both windows height (+ 3 for both statusline and Ex command) |
| 175 | " should be equal to the number of lines |
| 176 | " - both windows should have the same width which should be equal to the |
| 177 | " number of columns |
| 178 | " - buffer of both windows should have no name |
| 179 | let [wn, wh1, wh2, ln, ww1, ww2, cn, bn1, bn2] = readfile('Xtestout') |
| 180 | call assert_equal('2', wn) |
| 181 | call assert_inrange(0, 1, wh1 - wh2) |
| 182 | call assert_equal(string(wh1 + wh2 + 3), ln) |
| 183 | call assert_equal(ww1, ww2) |
| 184 | call assert_equal(ww1, cn) |
| 185 | call assert_equal('', bn1) |
| 186 | call assert_equal('', bn2) |
| 187 | endif |
| 188 | |
| 189 | if RunVim([], after, '-o foo bar') |
| 190 | " Same expectations as for -o2 but buffer names should be foo and bar |
| 191 | let [wn, wh1, wh2, ln, ww1, ww2, cn, bn1, bn2] = readfile('Xtestout') |
| 192 | call assert_equal('2', wn) |
| 193 | call assert_inrange(0, 1, wh1 - wh2) |
| 194 | call assert_equal(string(wh1 + wh2 + 3), ln) |
| 195 | call assert_equal(ww1, ww2) |
| 196 | call assert_equal(ww1, cn) |
| 197 | call assert_equal('foo', bn1) |
| 198 | call assert_equal('bar', bn2) |
| 199 | endif |
| 200 | |
| 201 | if RunVim([], after, '-O2') |
| 202 | " Open 2 windows split vertically. Expect: |
| 203 | " - 2 windows |
| 204 | " - both windows should have the same or almost the same width |
Bram Moolenaar | 036b09c | 2018-09-21 12:54:06 +0200 | [diff] [blame] | 205 | " - sum of both windows width (+ 1 for the separator) should be equal to |
| 206 | " the number of columns |
Bram Moolenaar | 8f4499b | 2018-09-16 16:28:11 +0200 | [diff] [blame] | 207 | " - both windows should have the same height |
| 208 | " - window height (+ 2 for the statusline and Ex command) should be equal |
| 209 | " to the number of lines |
Bram Moolenaar | 9e81db9 | 2018-09-18 22:37:31 +0200 | [diff] [blame] | 210 | " - buffer of both windows should have no name |
Bram Moolenaar | 8f4499b | 2018-09-16 16:28:11 +0200 | [diff] [blame] | 211 | let [wn, wh1, wh2, ln, ww1, ww2, cn, bn1, bn2] = readfile('Xtestout') |
| 212 | call assert_equal('2', wn) |
| 213 | call assert_inrange(0, 1, ww1 - ww2) |
| 214 | call assert_equal(string(ww1 + ww2 + 1), cn) |
| 215 | call assert_equal(wh1, wh2) |
| 216 | call assert_equal(string(wh1 + 2), ln) |
| 217 | call assert_equal('', bn1) |
| 218 | call assert_equal('', bn2) |
| 219 | endif |
| 220 | |
| 221 | if RunVim([], after, '-O foo bar') |
| 222 | " Same expectations as for -O2 but buffer names should be foo and bar |
| 223 | let [wn, wh1, wh2, ln, ww1, ww2, cn, bn1, bn2] = readfile('Xtestout') |
| 224 | call assert_equal('2', wn) |
| 225 | call assert_inrange(0, 1, ww1 - ww2) |
| 226 | call assert_equal(string(ww1 + ww2 + 1), cn) |
| 227 | call assert_equal(wh1, wh2) |
| 228 | call assert_equal(string(wh1 + 2), ln) |
| 229 | call assert_equal('foo', bn1) |
| 230 | call assert_equal('bar', bn2) |
| 231 | endif |
| 232 | |
| 233 | call delete('Xtestout') |
| 234 | endfunc |
| 235 | |
Bram Moolenaar | 9e81db9 | 2018-09-18 22:37:31 +0200 | [diff] [blame] | 236 | " Test the -p[N] argument to open N tabpages. |
| 237 | func Test_p_arg() |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 238 | let after =<< trim [CODE] |
| 239 | call writefile(split(execute("tabs"), "\n"), "Xtestout") |
| 240 | qall |
| 241 | [CODE] |
| 242 | |
Bram Moolenaar | 9e81db9 | 2018-09-18 22:37:31 +0200 | [diff] [blame] | 243 | if RunVim([], after, '-p2') |
| 244 | let lines = readfile('Xtestout') |
| 245 | call assert_equal(4, len(lines)) |
| 246 | call assert_equal('Tab page 1', lines[0]) |
| 247 | call assert_equal('> [No Name]', lines[1]) |
| 248 | call assert_equal('Tab page 2', lines[2]) |
| 249 | call assert_equal(' [No Name]', lines[3]) |
| 250 | endif |
| 251 | |
| 252 | if RunVim([], after, '-p foo bar') |
| 253 | let lines = readfile('Xtestout') |
| 254 | call assert_equal(4, len(lines)) |
| 255 | call assert_equal('Tab page 1', lines[0]) |
| 256 | call assert_equal('> foo', lines[1]) |
| 257 | call assert_equal('Tab page 2', lines[2]) |
| 258 | call assert_equal(' bar', lines[3]) |
| 259 | endif |
| 260 | |
| 261 | call delete('Xtestout') |
| 262 | endfunc |
| 263 | |
Bram Moolenaar | 4b1c9a9 | 2018-09-19 21:06:31 +0200 | [diff] [blame] | 264 | " Test the -V[N] argument to set the 'verbose' option to [N] |
Bram Moolenaar | 9e81db9 | 2018-09-18 22:37:31 +0200 | [diff] [blame] | 265 | func Test_V_arg() |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 266 | " Can't catch the output of gvim. |
| 267 | CheckNotGui |
| 268 | |
Bram Moolenaar | 9e81db9 | 2018-09-18 22:37:31 +0200 | [diff] [blame] | 269 | let out = system(GetVimCommand() . ' --clean -es -X -V0 -c "set verbose?" -cq') |
| 270 | call assert_equal(" verbose=0\n", out) |
| 271 | |
| 272 | let out = system(GetVimCommand() . ' --clean -es -X -V2 -c "set verbose?" -cq') |
Bram Moolenaar | 4515bcd | 2020-05-03 18:21:04 +0200 | [diff] [blame] | 273 | call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nline \\d\\+: sourcing \"[^\"]*runtime[\\/]filetype\.vim\".*\n", out) |
Bram Moolenaar | 4b1c9a9 | 2018-09-19 21:06:31 +0200 | [diff] [blame] | 274 | call assert_match(" verbose=2\n", out) |
Bram Moolenaar | 9e81db9 | 2018-09-18 22:37:31 +0200 | [diff] [blame] | 275 | |
| 276 | let out = system(GetVimCommand() . ' --clean -es -X -V15 -c "set verbose?" -cq') |
Bram Moolenaar | 4b1c9a9 | 2018-09-19 21:06:31 +0200 | [diff] [blame] | 277 | call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nline 1: \" The default vimrc file\..* verbose=15\n", out) |
Bram Moolenaar | 9e81db9 | 2018-09-18 22:37:31 +0200 | [diff] [blame] | 278 | endfunc |
| 279 | |
Bram Moolenaar | 5494818 | 2018-12-28 18:32:56 +0100 | [diff] [blame] | 280 | " Test the '-q [errorfile]' argument. |
| 281 | func Test_q_arg() |
Bram Moolenaar | 5a4c308 | 2019-12-01 15:23:11 +0100 | [diff] [blame] | 282 | CheckFeature quickfix |
| 283 | |
Bram Moolenaar | 1e1f612 | 2020-07-15 11:19:11 +0200 | [diff] [blame] | 284 | let lines =<< trim END |
| 285 | /* some file with an error */ |
| 286 | main() { |
| 287 | functionCall(arg; arg, arg); |
| 288 | return 666 |
| 289 | } |
| 290 | END |
| 291 | call writefile(lines, 'Xbadfile.c') |
| 292 | |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 293 | let after =<< trim [CODE] |
| 294 | call writefile([&errorfile, string(getpos("."))], "Xtestout") |
| 295 | copen |
| 296 | w >> Xtestout |
| 297 | qall |
| 298 | [CODE] |
Bram Moolenaar | 5494818 | 2018-12-28 18:32:56 +0100 | [diff] [blame] | 299 | |
| 300 | " Test with default argument '-q'. |
| 301 | call assert_equal('errors.err', &errorfile) |
Bram Moolenaar | 1e1f612 | 2020-07-15 11:19:11 +0200 | [diff] [blame] | 302 | call writefile(["Xbadfile.c:4:12: error: expected ';' before '}' token"], 'errors.err') |
Bram Moolenaar | 5494818 | 2018-12-28 18:32:56 +0100 | [diff] [blame] | 303 | if RunVim([], after, '-q') |
| 304 | let lines = readfile('Xtestout') |
| 305 | call assert_equal(['errors.err', |
Bram Moolenaar | 1e1f612 | 2020-07-15 11:19:11 +0200 | [diff] [blame] | 306 | \ '[0, 4, 12, 0]', |
| 307 | \ "Xbadfile.c|4 col 12| error: expected ';' before '}' token"], |
Bram Moolenaar | 5494818 | 2018-12-28 18:32:56 +0100 | [diff] [blame] | 308 | \ lines) |
| 309 | endif |
| 310 | call delete('Xtestout') |
| 311 | call delete('errors.err') |
| 312 | |
| 313 | " Test with explicit argument '-q Xerrors' (with space). |
Bram Moolenaar | 1e1f612 | 2020-07-15 11:19:11 +0200 | [diff] [blame] | 314 | call writefile(["Xbadfile.c:4:12: error: expected ';' before '}' token"], 'Xerrors') |
Bram Moolenaar | 5494818 | 2018-12-28 18:32:56 +0100 | [diff] [blame] | 315 | if RunVim([], after, '-q Xerrors') |
| 316 | let lines = readfile('Xtestout') |
| 317 | call assert_equal(['Xerrors', |
Bram Moolenaar | 1e1f612 | 2020-07-15 11:19:11 +0200 | [diff] [blame] | 318 | \ '[0, 4, 12, 0]', |
| 319 | \ "Xbadfile.c|4 col 12| error: expected ';' before '}' token"], |
Bram Moolenaar | 5494818 | 2018-12-28 18:32:56 +0100 | [diff] [blame] | 320 | \ lines) |
| 321 | endif |
| 322 | call delete('Xtestout') |
| 323 | |
| 324 | " Test with explicit argument '-qXerrors' (without space). |
| 325 | if RunVim([], after, '-qXerrors') |
| 326 | let lines = readfile('Xtestout') |
| 327 | call assert_equal(['Xerrors', |
Bram Moolenaar | 1e1f612 | 2020-07-15 11:19:11 +0200 | [diff] [blame] | 328 | \ '[0, 4, 12, 0]', |
| 329 | \ "Xbadfile.c|4 col 12| error: expected ';' before '}' token"], |
Bram Moolenaar | 5494818 | 2018-12-28 18:32:56 +0100 | [diff] [blame] | 330 | \ lines) |
| 331 | endif |
| 332 | |
Bram Moolenaar | cde0ff3 | 2020-04-04 14:00:39 +0200 | [diff] [blame] | 333 | " Test with a non-existing error file (exits with value 3) |
| 334 | let out = system(GetVimCommand() .. ' -q xyz.err') |
| 335 | call assert_equal(3, v:shell_error) |
| 336 | |
Bram Moolenaar | 1e1f612 | 2020-07-15 11:19:11 +0200 | [diff] [blame] | 337 | call delete('Xbadfile.c') |
Bram Moolenaar | 5494818 | 2018-12-28 18:32:56 +0100 | [diff] [blame] | 338 | call delete('Xtestout') |
| 339 | call delete('Xerrors') |
| 340 | endfunc |
| 341 | |
Bram Moolenaar | 036b09c | 2018-09-21 12:54:06 +0200 | [diff] [blame] | 342 | " Test the -V[N]{filename} argument to set the 'verbose' option to N |
| 343 | " and set 'verbosefile' to filename. |
| 344 | func Test_V_file_arg() |
Bram Moolenaar | 4841a7c | 2018-09-22 14:08:49 +0200 | [diff] [blame] | 345 | if RunVim([], [], ' --clean -V2Xverbosefile -c "set verbose? verbosefile?" -cq') |
Bram Moolenaar | 036b09c | 2018-09-21 12:54:06 +0200 | [diff] [blame] | 346 | let out = join(readfile('Xverbosefile'), "\n") |
| 347 | call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\n", out) |
| 348 | call assert_match("\n verbose=2\n", out) |
| 349 | call assert_match("\n verbosefile=Xverbosefile", out) |
| 350 | endif |
| 351 | |
| 352 | call delete('Xverbosefile') |
| 353 | endfunc |
| 354 | |
| 355 | " Test the -m, -M and -R arguments: |
| 356 | " -m resets 'write' |
| 357 | " -M resets 'modifiable' and 'write' |
| 358 | " -R sets 'readonly' |
| 359 | func Test_m_M_R() |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 360 | let after =<< trim [CODE] |
| 361 | call writefile([&write, &modifiable, &readonly, &updatecount], "Xtestout") |
| 362 | qall |
| 363 | [CODE] |
| 364 | |
Bram Moolenaar | 036b09c | 2018-09-21 12:54:06 +0200 | [diff] [blame] | 365 | if RunVim([], after, '') |
| 366 | let lines = readfile('Xtestout') |
| 367 | call assert_equal(['1', '1', '0', '200'], lines) |
| 368 | endif |
| 369 | if RunVim([], after, '-m') |
| 370 | let lines = readfile('Xtestout') |
| 371 | call assert_equal(['0', '1', '0', '200'], lines) |
| 372 | endif |
| 373 | if RunVim([], after, '-M') |
| 374 | let lines = readfile('Xtestout') |
| 375 | call assert_equal(['0', '0', '0', '200'], lines) |
| 376 | endif |
| 377 | if RunVim([], after, '-R') |
| 378 | let lines = readfile('Xtestout') |
| 379 | call assert_equal(['1', '1', '1', '10000'], lines) |
| 380 | endif |
| 381 | |
| 382 | call delete('Xtestout') |
| 383 | endfunc |
| 384 | |
Bram Moolenaar | 9e81db9 | 2018-09-18 22:37:31 +0200 | [diff] [blame] | 385 | " Test the -A, -F and -H arguments (Arabic, Farsi and Hebrew modes). |
| 386 | func Test_A_F_H_arg() |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 387 | let after =<< trim [CODE] |
| 388 | call writefile([&rightleft, &arabic, &fkmap, &hkmap], "Xtestout") |
| 389 | qall |
| 390 | [CODE] |
| 391 | |
Bram Moolenaar | 4b1c9a9 | 2018-09-19 21:06:31 +0200 | [diff] [blame] | 392 | " Use silent Ex mode to avoid the hit-Enter prompt for the warning that |
| 393 | " 'encoding' is not utf-8. |
| 394 | if has('arabic') && &encoding == 'utf-8' && RunVim([], after, '-e -s -A') |
Bram Moolenaar | 9e81db9 | 2018-09-18 22:37:31 +0200 | [diff] [blame] | 395 | let lines = readfile('Xtestout') |
| 396 | call assert_equal(['1', '1', '0', '0'], lines) |
| 397 | endif |
| 398 | |
| 399 | if has('farsi') && RunVim([], after, '-F') |
| 400 | let lines = readfile('Xtestout') |
| 401 | call assert_equal(['1', '0', '1', '0'], lines) |
| 402 | endif |
| 403 | |
| 404 | if has('rightleft') && RunVim([], after, '-H') |
| 405 | let lines = readfile('Xtestout') |
| 406 | call assert_equal(['1', '0', '0', '1'], lines) |
| 407 | endif |
| 408 | |
| 409 | call delete('Xtestout') |
| 410 | endfunc |
| 411 | |
Bram Moolenaar | 240309c | 2021-03-14 16:20:37 +0100 | [diff] [blame] | 412 | " Test the --echo-wid argument (for GTK GUI only). |
| 413 | func Test_echo_wid() |
| 414 | CheckCanRunGui |
| 415 | CheckFeature gui_gtk |
| 416 | |
| 417 | if RunVim([], [], '-g --echo-wid -cq >Xtest_echo_wid') |
| 418 | let lines = readfile('Xtest_echo_wid') |
| 419 | call assert_equal(1, len(lines)) |
| 420 | call assert_match('^WID: \d\+$', lines[0]) |
| 421 | endif |
| 422 | |
| 423 | call delete('Xtest_echo_wid') |
| 424 | endfunction |
| 425 | |
| 426 | " Test the -reverse and +reverse arguments (for GUI only). |
| 427 | func Test_reverse() |
| 428 | CheckCanRunGui |
| 429 | CheckNotMSWindows |
| 430 | |
| 431 | let after =<< trim [CODE] |
| 432 | call writefile([&background], "Xtest_reverse") |
| 433 | qall |
| 434 | [CODE] |
| 435 | if RunVim([], after, '-f -g -reverse') |
| 436 | let lines = readfile('Xtest_reverse') |
| 437 | call assert_equal(['dark'], lines) |
| 438 | endif |
| 439 | if RunVim([], after, '-f -g +reverse') |
| 440 | let lines = readfile('Xtest_reverse') |
| 441 | call assert_equal(['light'], lines) |
| 442 | endif |
| 443 | |
| 444 | call delete('Xtest_reverse') |
| 445 | endfunc |
| 446 | |
| 447 | " Test the -background and -foreground arguments (for GUI only). |
| 448 | func Test_background_foreground() |
| 449 | CheckCanRunGui |
| 450 | CheckNotMSWindows |
| 451 | |
| 452 | " Is there a better way to check the effect of -background & -foreground |
| 453 | " other than merely looking at &background (dark or light)? |
| 454 | let after =<< trim [CODE] |
| 455 | call writefile([&background], "Xtest_fg_bg") |
| 456 | qall |
| 457 | [CODE] |
| 458 | if RunVim([], after, '-f -g -background darkred -foreground yellow') |
| 459 | let lines = readfile('Xtest_fg_bg') |
| 460 | call assert_equal(['dark'], lines) |
| 461 | endif |
| 462 | if RunVim([], after, '-f -g -background ivory -foreground darkgreen') |
| 463 | let lines = readfile('Xtest_fg_bg') |
| 464 | call assert_equal(['light'], lines) |
| 465 | endif |
| 466 | |
| 467 | call delete('Xtest_fg_bg') |
| 468 | endfunc |
| 469 | |
| 470 | " Test the -font argument (for GUI only). |
| 471 | func Test_font() |
| 472 | CheckCanRunGui |
| 473 | CheckNotMSWindows |
| 474 | |
| 475 | if has('gui_gtk') |
| 476 | let font = 'Courier 14' |
| 477 | elseif has('gui_motif') || has('gui_athena') |
| 478 | let font = '-misc-fixed-bold-*' |
| 479 | else |
| 480 | throw 'Skipped: test does not set a valid font for this GUI' |
| 481 | endif |
| 482 | |
| 483 | let after =<< trim [CODE] |
| 484 | call writefile([&guifont], "Xtest_font") |
| 485 | qall |
| 486 | [CODE] |
| 487 | |
| 488 | if RunVim([], after, '--nofork -g -font "' .. font .. '"') |
| 489 | let lines = readfile('Xtest_font') |
| 490 | call assert_equal([font], lines) |
| 491 | endif |
| 492 | |
| 493 | call delete('Xtest_font') |
| 494 | endfunc |
| 495 | |
| 496 | " Test the -geometry argument (for GUI only). |
| 497 | func Test_geometry() |
| 498 | CheckCanRunGui |
| 499 | CheckNotMSWindows |
| 500 | |
| 501 | if has('gui_motif') || has('gui_athena') |
| 502 | " FIXME: With GUI Athena or Motif, the value of getwinposx(), |
| 503 | " getwinposy() and getwinpos() do not match exactly the |
| 504 | " value given in -geometry. Why? |
| 505 | " So only check &columns and &lines for those GUIs. |
| 506 | let after =<< trim [CODE] |
| 507 | call writefile([&columns, &lines], "Xtest_geometry") |
| 508 | qall |
| 509 | [CODE] |
| 510 | if RunVim([], after, '-f -g -geometry 31x13+41+43') |
| 511 | let lines = readfile('Xtest_geometry') |
| 512 | call assert_equal(['31', '13'], lines) |
| 513 | endif |
| 514 | else |
| 515 | let after =<< trim [CODE] |
| 516 | call writefile([&columns, &lines, getwinposx(), getwinposy(), string(getwinpos())], "Xtest_geometry") |
| 517 | qall |
| 518 | [CODE] |
| 519 | if RunVim([], after, '-f -g -geometry 31x13+41+43') |
| 520 | let lines = readfile('Xtest_geometry') |
| 521 | call assert_equal(['31', '13', '41', '43', '[41, 43]'], lines) |
| 522 | endif |
| 523 | endif |
| 524 | |
| 525 | call delete('Xtest_geometry') |
| 526 | endfunc |
| 527 | |
| 528 | " Test the -iconic argument (for GUI only). |
| 529 | func Test_iconic() |
| 530 | CheckCanRunGui |
| 531 | CheckNotMSWindows |
| 532 | |
| 533 | call RunVim([], [], '-f -g -iconic -cq') |
| 534 | |
| 535 | " TODO: currently only start vim iconified, but does not |
| 536 | " check that vim is iconified. How could this be checked? |
| 537 | endfunc |
| 538 | |
| 539 | |
Bram Moolenaar | ba9ea91 | 2019-05-07 22:10:50 +0200 | [diff] [blame] | 540 | func Test_invalid_args() |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 541 | " must be able to get the output of Vim. |
| 542 | CheckUnix |
| 543 | CheckNotGui |
Bram Moolenaar | ba9ea91 | 2019-05-07 22:10:50 +0200 | [diff] [blame] | 544 | |
| 545 | for opt in ['-Y', '--does-not-exist'] |
| 546 | let out = split(system(GetVimCommand() .. ' ' .. opt), "\n") |
| 547 | call assert_equal(1, v:shell_error) |
| 548 | call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) |
| 549 | call assert_equal('Unknown option argument: "' .. opt .. '"', out[1]) |
| 550 | call assert_equal('More info with: "vim -h"', out[2]) |
| 551 | endfor |
| 552 | |
| 553 | for opt in ['-c', '-i', '-s', '-t', '-T', '-u', '-U', '-w', '-W', '--cmd', '--startuptime'] |
| 554 | let out = split(system(GetVimCommand() .. ' ' .. opt), "\n") |
| 555 | call assert_equal(1, v:shell_error) |
| 556 | call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) |
| 557 | call assert_equal('Argument missing after: "' .. opt .. '"', out[1]) |
| 558 | call assert_equal('More info with: "vim -h"', out[2]) |
| 559 | endfor |
| 560 | |
| 561 | if has('clientserver') |
Bram Moolenaar | ba9ea91 | 2019-05-07 22:10:50 +0200 | [diff] [blame] | 562 | for opt in ['--remote', '--remote-send', '--remote-silent', '--remote-expr', |
| 563 | \ '--remote-tab', '--remote-tab-wait', |
| 564 | \ '--remote-tab-wait-silent', '--remote-tab-silent', |
| 565 | \ '--remote-wait', '--remote-wait-silent', |
Bram Moolenaar | 2782126 | 2019-05-08 16:41:09 +0200 | [diff] [blame] | 566 | \ '--servername', |
Bram Moolenaar | ba9ea91 | 2019-05-07 22:10:50 +0200 | [diff] [blame] | 567 | \ ] |
| 568 | let out = split(system(GetVimCommand() .. ' ' .. opt), "\n") |
| 569 | call assert_equal(1, v:shell_error) |
| 570 | call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) |
| 571 | call assert_equal('Argument missing after: "' .. opt .. '"', out[1]) |
| 572 | call assert_equal('More info with: "vim -h"', out[2]) |
| 573 | endfor |
| 574 | endif |
| 575 | |
Bram Moolenaar | 240f7ab | 2019-05-08 17:58:15 +0200 | [diff] [blame] | 576 | if has('gui_gtk') |
Bram Moolenaar | 2782126 | 2019-05-08 16:41:09 +0200 | [diff] [blame] | 577 | let out = split(system(GetVimCommand() .. ' --display'), "\n") |
| 578 | call assert_equal(1, v:shell_error) |
| 579 | call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) |
| 580 | call assert_equal('Argument missing after: "--display"', out[1]) |
| 581 | call assert_equal('More info with: "vim -h"', out[2]) |
| 582 | endif |
Bram Moolenaar | ba9ea91 | 2019-05-07 22:10:50 +0200 | [diff] [blame] | 583 | |
Bram Moolenaar | 5416b75 | 2019-05-08 18:36:43 +0200 | [diff] [blame] | 584 | if has('xterm_clipboard') |
Bram Moolenaar | 240f7ab | 2019-05-08 17:58:15 +0200 | [diff] [blame] | 585 | let out = split(system(GetVimCommand() .. ' -display'), "\n") |
| 586 | call assert_equal(1, v:shell_error) |
| 587 | call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) |
| 588 | call assert_equal('Argument missing after: "-display"', out[1]) |
| 589 | call assert_equal('More info with: "vim -h"', out[2]) |
| 590 | endif |
| 591 | |
Bram Moolenaar | ba9ea91 | 2019-05-07 22:10:50 +0200 | [diff] [blame] | 592 | let out = split(system(GetVimCommand() .. ' -ix'), "\n") |
| 593 | call assert_equal(1, v:shell_error) |
| 594 | call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) |
| 595 | call assert_equal('Garbage after option argument: "-ix"', out[1]) |
| 596 | call assert_equal('More info with: "vim -h"', out[2]) |
| 597 | |
| 598 | let out = split(system(GetVimCommand() .. ' - xxx'), "\n") |
| 599 | call assert_equal(1, v:shell_error) |
| 600 | call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) |
| 601 | call assert_equal('Too many edit arguments: "xxx"', out[1]) |
| 602 | call assert_equal('More info with: "vim -h"', out[2]) |
| 603 | |
Bram Moolenaar | 5a4c308 | 2019-12-01 15:23:11 +0100 | [diff] [blame] | 604 | if has('quickfix') |
| 605 | " Detect invalid repeated arguments '-t foo -t foo", '-q foo -q foo'. |
| 606 | for opt in ['-t', '-q'] |
| 607 | let out = split(system(GetVimCommand() .. repeat(' ' .. opt .. ' foo', 2)), "\n") |
| 608 | call assert_equal(1, v:shell_error) |
| 609 | call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) |
| 610 | call assert_equal('Too many edit arguments: "' .. opt .. '"', out[1]) |
| 611 | call assert_equal('More info with: "vim -h"', out[2]) |
| 612 | endfor |
| 613 | endif |
Bram Moolenaar | ba9ea91 | 2019-05-07 22:10:50 +0200 | [diff] [blame] | 614 | |
| 615 | for opt in [' -cq', ' --cmd q', ' +', ' -S foo'] |
| 616 | let out = split(system(GetVimCommand() .. repeat(opt, 11)), "\n") |
| 617 | call assert_equal(1, v:shell_error) |
| 618 | " FIXME: The error message given by Vim is not ideal in case of repeated |
| 619 | " -S foo since it does not mention -S. |
| 620 | call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) |
| 621 | call assert_equal('Too many "+command", "-c command" or "--cmd command" arguments', out[1]) |
| 622 | call assert_equal('More info with: "vim -h"', out[2]) |
| 623 | endfor |
| 624 | |
Bram Moolenaar | 2782126 | 2019-05-08 16:41:09 +0200 | [diff] [blame] | 625 | if has('gui_gtk') |
| 626 | for opt in ['--socketid x', '--socketid 0xg'] |
| 627 | let out = split(system(GetVimCommand() .. ' ' .. opt), "\n") |
| 628 | call assert_equal(1, v:shell_error) |
| 629 | call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) |
| 630 | call assert_equal('Invalid argument for: "--socketid"', out[1]) |
| 631 | call assert_equal('More info with: "vim -h"', out[2]) |
| 632 | endfor |
| 633 | endif |
Bram Moolenaar | ba9ea91 | 2019-05-07 22:10:50 +0200 | [diff] [blame] | 634 | endfunc |
| 635 | |
Bram Moolenaar | ba98bef | 2016-08-07 15:51:39 +0200 | [diff] [blame] | 636 | func Test_file_args() |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 637 | let after =<< trim [CODE] |
| 638 | call writefile(argv(), "Xtestout") |
| 639 | qall |
| 640 | [CODE] |
| 641 | |
Bram Moolenaar | ba98bef | 2016-08-07 15:51:39 +0200 | [diff] [blame] | 642 | if RunVim([], after, '') |
| 643 | let lines = readfile('Xtestout') |
| 644 | call assert_equal(0, len(lines)) |
| 645 | endif |
| 646 | |
| 647 | if RunVim([], after, 'one') |
| 648 | let lines = readfile('Xtestout') |
| 649 | call assert_equal(1, len(lines)) |
| 650 | call assert_equal('one', lines[0]) |
| 651 | endif |
| 652 | |
| 653 | if RunVim([], after, 'one two three') |
| 654 | let lines = readfile('Xtestout') |
| 655 | call assert_equal(3, len(lines)) |
| 656 | call assert_equal('one', lines[0]) |
| 657 | call assert_equal('two', lines[1]) |
| 658 | call assert_equal('three', lines[2]) |
| 659 | endif |
| 660 | |
| 661 | if RunVim([], after, 'one -c echo two') |
| 662 | let lines = readfile('Xtestout') |
| 663 | call assert_equal(2, len(lines)) |
| 664 | call assert_equal('one', lines[0]) |
| 665 | call assert_equal('two', lines[1]) |
| 666 | endif |
| 667 | |
| 668 | if RunVim([], after, 'one -- -c echo two') |
| 669 | let lines = readfile('Xtestout') |
| 670 | call assert_equal(4, len(lines)) |
| 671 | call assert_equal('one', lines[0]) |
| 672 | call assert_equal('-c', lines[1]) |
| 673 | call assert_equal('echo', lines[2]) |
| 674 | call assert_equal('two', lines[3]) |
| 675 | endif |
| 676 | |
| 677 | call delete('Xtestout') |
| 678 | endfunc |
| 679 | |
| 680 | func Test_startuptime() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 681 | CheckFeature startuptime |
Bram Moolenaar | ba98bef | 2016-08-07 15:51:39 +0200 | [diff] [blame] | 682 | let after = ['qall'] |
| 683 | if RunVim([], after, '--startuptime Xtestout one') |
| 684 | let lines = readfile('Xtestout') |
| 685 | let expected = ['--- VIM STARTING ---', 'parsing arguments', |
| 686 | \ 'shell init', 'inits 3', 'start termcap', 'opening buffers'] |
| 687 | let found = [] |
| 688 | for line in lines |
| 689 | for exp in expected |
| 690 | if line =~ exp |
| 691 | call add(found, exp) |
| 692 | endif |
| 693 | endfor |
| 694 | endfor |
| 695 | call assert_equal(expected, found) |
| 696 | endif |
| 697 | call delete('Xtestout') |
| 698 | endfunc |
Bram Moolenaar | 3a93838 | 2016-08-07 16:36:40 +0200 | [diff] [blame] | 699 | |
| 700 | func Test_read_stdin() |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 701 | let after =<< trim [CODE] |
| 702 | write Xtestout |
| 703 | quit! |
| 704 | [CODE] |
| 705 | |
Bram Moolenaar | 3a93838 | 2016-08-07 16:36:40 +0200 | [diff] [blame] | 706 | if RunVimPiped([], after, '-', 'echo something | ') |
| 707 | let lines = readfile('Xtestout') |
Bram Moolenaar | e4a76ad | 2016-08-07 16:50:10 +0200 | [diff] [blame] | 708 | " MS-Windows adds a space after the word |
| 709 | call assert_equal(['something'], split(lines[0])) |
Bram Moolenaar | 3a93838 | 2016-08-07 16:36:40 +0200 | [diff] [blame] | 710 | endif |
| 711 | call delete('Xtestout') |
| 712 | endfunc |
Bram Moolenaar | 08cab96 | 2017-03-04 14:37:18 +0100 | [diff] [blame] | 713 | |
Bram Moolenaar | 4bfa8af | 2018-02-03 15:14:46 +0100 | [diff] [blame] | 714 | func Test_set_shell() |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 715 | let after =<< trim [CODE] |
| 716 | call writefile([&shell], "Xtestout") |
| 717 | quit! |
| 718 | [CODE] |
| 719 | |
Bram Moolenaar | 2efc44b | 2019-10-05 12:09:32 +0200 | [diff] [blame] | 720 | if has('win32') |
| 721 | let $SHELL = 'C:\with space\cmd.exe' |
| 722 | let expected = '"C:\with space\cmd.exe"' |
| 723 | else |
| 724 | let $SHELL = '/bin/with space/sh' |
| 725 | let expected = '/bin/with\ space/sh' |
| 726 | endif |
| 727 | |
Bram Moolenaar | 4bfa8af | 2018-02-03 15:14:46 +0100 | [diff] [blame] | 728 | if RunVimPiped([], after, '', '') |
| 729 | let lines = readfile('Xtestout') |
Bram Moolenaar | 2efc44b | 2019-10-05 12:09:32 +0200 | [diff] [blame] | 730 | call assert_equal(expected, lines[0]) |
Bram Moolenaar | 4bfa8af | 2018-02-03 15:14:46 +0100 | [diff] [blame] | 731 | endif |
| 732 | call delete('Xtestout') |
| 733 | endfunc |
| 734 | |
Bram Moolenaar | 08cab96 | 2017-03-04 14:37:18 +0100 | [diff] [blame] | 735 | func Test_progpath() |
| 736 | " Tests normally run with "./vim" or "../vim", these must have been expanded |
| 737 | " to a full path. |
| 738 | if has('unix') |
| 739 | call assert_equal('/', v:progpath[0]) |
| 740 | elseif has('win32') |
| 741 | call assert_equal(':', v:progpath[1]) |
| 742 | call assert_match('[/\\]', v:progpath[2]) |
| 743 | endif |
| 744 | |
| 745 | " Only expect "vim" to appear in v:progname. |
| 746 | call assert_match('vim\c', v:progname) |
| 747 | endfunc |
Bram Moolenaar | d5d3753 | 2017-03-27 23:02:07 +0200 | [diff] [blame] | 748 | |
| 749 | func Test_silent_ex_mode() |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 750 | " must be able to get the output of Vim. |
| 751 | CheckUnix |
| 752 | CheckNotGui |
Bram Moolenaar | d5d3753 | 2017-03-27 23:02:07 +0200 | [diff] [blame] | 753 | |
| 754 | " This caused an ml_get error. |
| 755 | let out = system(GetVimCommand() . '-u NONE -es -c''set verbose=1|h|exe "%norm\<c-y>\<c-d>"'' -c cq') |
| 756 | call assert_notmatch('E315:', out) |
| 757 | endfunc |
Bram Moolenaar | 85045a7 | 2017-04-02 16:54:09 +0200 | [diff] [blame] | 758 | |
| 759 | func Test_default_term() |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 760 | " must be able to get the output of Vim. |
| 761 | CheckUnix |
| 762 | CheckNotGui |
Bram Moolenaar | 85045a7 | 2017-04-02 16:54:09 +0200 | [diff] [blame] | 763 | |
| 764 | let save_term = $TERM |
Bram Moolenaar | 08f88b1 | 2017-04-02 17:21:16 +0200 | [diff] [blame] | 765 | let $TERM = 'unknownxxx' |
Bram Moolenaar | 85045a7 | 2017-04-02 16:54:09 +0200 | [diff] [blame] | 766 | let out = system(GetVimCommand() . ' -c''set term'' -c cq') |
| 767 | call assert_match("defaulting to 'ansi'", out) |
| 768 | let $TERM = save_term |
| 769 | endfunc |
Bram Moolenaar | 09ca932 | 2017-09-26 17:40:45 +0200 | [diff] [blame] | 770 | |
| 771 | func Test_zzz_startinsert() |
| 772 | " Test :startinsert |
| 773 | call writefile(['123456'], 'Xtestout') |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 774 | let after =<< trim [CODE] |
| 775 | :startinsert |
| 776 | call feedkeys("foobar\<c-o>:wq\<cr>","t") |
| 777 | [CODE] |
| 778 | |
Bram Moolenaar | 09ca932 | 2017-09-26 17:40:45 +0200 | [diff] [blame] | 779 | if RunVim([], after, 'Xtestout') |
| 780 | let lines = readfile('Xtestout') |
| 781 | call assert_equal(['foobar123456'], lines) |
| 782 | endif |
| 783 | " Test :startinsert! |
| 784 | call writefile(['123456'], 'Xtestout') |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 785 | let after =<< trim [CODE] |
| 786 | :startinsert! |
| 787 | call feedkeys("foobar\<c-o>:wq\<cr>","t") |
| 788 | [CODE] |
| 789 | |
Bram Moolenaar | 09ca932 | 2017-09-26 17:40:45 +0200 | [diff] [blame] | 790 | if RunVim([], after, 'Xtestout') |
| 791 | let lines = readfile('Xtestout') |
| 792 | call assert_equal(['123456foobar'], lines) |
| 793 | endif |
| 794 | call delete('Xtestout') |
| 795 | endfunc |
Bram Moolenaar | 97c2c05 | 2019-02-22 13:42:07 +0100 | [diff] [blame] | 796 | |
| 797 | func Test_issue_3969() |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 798 | " Can't catch the output of gvim. |
| 799 | CheckNotGui |
| 800 | |
Bram Moolenaar | 97c2c05 | 2019-02-22 13:42:07 +0100 | [diff] [blame] | 801 | " Check that message is not truncated. |
| 802 | let out = system(GetVimCommand() . ' -es -X -V1 -c "echon ''hello''" -cq') |
| 803 | call assert_equal('hello', out) |
| 804 | endfunc |
Bram Moolenaar | c75e812 | 2019-04-21 15:55:10 +0200 | [diff] [blame] | 805 | |
| 806 | func Test_start_with_tabs() |
Bram Moolenaar | 494e906 | 2020-05-31 21:28:02 +0200 | [diff] [blame] | 807 | CheckRunVimInTerminal |
Bram Moolenaar | c75e812 | 2019-04-21 15:55:10 +0200 | [diff] [blame] | 808 | |
| 809 | let buf = RunVimInTerminal('-p a b c', {}) |
| 810 | call VerifyScreenDump(buf, 'Test_start_with_tabs', {}) |
| 811 | |
| 812 | " clean up |
| 813 | call StopVimInTerminal(buf) |
| 814 | endfunc |
Bram Moolenaar | 69bf634 | 2019-10-29 04:16:57 +0100 | [diff] [blame] | 815 | |
| 816 | func Test_v_argv() |
| 817 | " Can't catch the output of gvim. |
| 818 | CheckNotGui |
| 819 | |
| 820 | let out = system(GetVimCommand() . ' -es -V1 -X arg1 --cmd "echo v:argv" --cmd q') |
| 821 | let list = out->split("', '") |
| 822 | call assert_match('vim', list[0]) |
| 823 | let idx = index(list, 'arg1') |
| 824 | call assert_true(idx > 2) |
| 825 | call assert_equal(['arg1', '--cmd', 'echo v:argv', '--cmd', 'q'']'], list[idx:]) |
| 826 | endfunc |
Bram Moolenaar | cde0ff3 | 2020-04-04 14:00:39 +0200 | [diff] [blame] | 827 | |
| 828 | " Test for the "-r" recovery mode option |
| 829 | func Test_r_arg() |
| 830 | " Can't catch the output of gvim. |
| 831 | CheckNotGui |
| 832 | CheckUnix |
| 833 | CheckEnglish |
| 834 | let cmd = GetVimCommand() |
| 835 | " There can be swap files anywhere, only check for the headers. |
| 836 | let expected =<< trim END |
| 837 | Swap files found:.* |
| 838 | In current directory:.* |
| 839 | In directory \~/tmp:.* |
| 840 | In directory /var/tmp:.* |
| 841 | In directory /tmp:.* |
| 842 | END |
| 843 | call assert_match(join(expected, ""), system(cmd .. " -r")->substitute("[\r\n]\\+", '', '')) |
| 844 | endfunc |
| 845 | |
| 846 | " Test for the '-t' option to jump to a tag |
| 847 | func Test_t_arg() |
| 848 | let before =<< trim [CODE] |
| 849 | set tags=Xtags |
| 850 | [CODE] |
| 851 | let after =<< trim [CODE] |
| 852 | let s = bufname('') .. ':L' .. line('.') .. 'C' .. col('.') |
| 853 | call writefile([s], "Xtestout") |
| 854 | qall |
| 855 | [CODE] |
| 856 | |
| 857 | call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", |
| 858 | \ "first\tXfile1\t/^ \\zsfirst$/", |
| 859 | \ "second\tXfile1\t/^ \\zssecond$/", |
| 860 | \ "third\tXfile1\t/^ \\zsthird$/"], |
| 861 | \ 'Xtags') |
| 862 | call writefile([' first', ' second', ' third'], 'Xfile1') |
| 863 | |
| 864 | if RunVim(before, after, '-t second') |
| 865 | call assert_equal(['Xfile1:L2C5'], readfile('Xtestout')) |
| 866 | call delete('Xtestout') |
| 867 | endif |
| 868 | |
| 869 | call delete('Xtags') |
| 870 | call delete('Xfile1') |
| 871 | endfunc |
| 872 | |
Bram Moolenaar | 1f33e0a | 2020-12-19 13:32:07 +0100 | [diff] [blame] | 873 | " Test the '-T' argument which sets the 'term' option. |
| 874 | func Test_T_arg() |
| 875 | CheckNotGui |
| 876 | let after =<< trim [CODE] |
| 877 | call writefile([&term], "Xtest_T_arg") |
| 878 | qall |
| 879 | [CODE] |
| 880 | |
| 881 | for t in ['builtin_dumb', 'builtin_ansi'] |
| 882 | if RunVim([], after, '-T ' .. t) |
| 883 | let lines = readfile('Xtest_T_arg') |
| 884 | call assert_equal([t], lines) |
| 885 | endif |
| 886 | endfor |
| 887 | |
| 888 | call delete('Xtest_T_arg') |
| 889 | endfunc |
| 890 | |
| 891 | " Test the '-x' argument to read/write encrypted files. |
| 892 | func Test_x_arg() |
| 893 | CheckRunVimInTerminal |
| 894 | CheckFeature cryptv |
| 895 | |
| 896 | " Create an encrypted file Xtest_x_arg. |
| 897 | let buf = RunVimInTerminal('-n -x Xtest_x_arg', #{rows: 10, wait_for_ruler: 0}) |
| 898 | call WaitForAssert({-> assert_match('^Enter encryption key: ', term_getline(buf, 10))}) |
| 899 | call term_sendkeys(buf, "foo\n") |
| 900 | call WaitForAssert({-> assert_match('^Enter same key again: ', term_getline(buf, 10))}) |
| 901 | call term_sendkeys(buf, "foo\n") |
| 902 | call WaitForAssert({-> assert_match(' All$', term_getline(buf, 10))}) |
| 903 | call term_sendkeys(buf, "itest\<Esc>:w\<Enter>") |
| 904 | call WaitForAssert({-> assert_match('"Xtest_x_arg" \[New\]\[blowfish2\] 1L, 5B written', |
| 905 | \ term_getline(buf, 10))}) |
| 906 | call StopVimInTerminal(buf) |
| 907 | |
| 908 | " Read the encrypted file and check that it contains the expected content "test" |
| 909 | let buf = RunVimInTerminal('-n -x Xtest_x_arg', #{rows: 10, wait_for_ruler: 0}) |
| 910 | call WaitForAssert({-> assert_match('^Enter encryption key: ', term_getline(buf, 10))}) |
| 911 | call term_sendkeys(buf, "foo\n") |
| 912 | call WaitForAssert({-> assert_match('^Enter same key again: ', term_getline(buf, 10))}) |
| 913 | call term_sendkeys(buf, "foo\n") |
| 914 | call WaitForAssert({-> assert_match('^test', term_getline(buf, 1))}) |
| 915 | call StopVimInTerminal(buf) |
| 916 | |
| 917 | call delete('Xtest_x_arg') |
| 918 | endfunc |
| 919 | |
Bram Moolenaar | cde0ff3 | 2020-04-04 14:00:39 +0200 | [diff] [blame] | 920 | " Test for entering the insert mode on startup |
| 921 | func Test_start_insertmode() |
| 922 | let before =<< trim [CODE] |
| 923 | set insertmode |
| 924 | [CODE] |
| 925 | let after =<< trim [CODE] |
| 926 | call writefile(['insertmode=' .. &insertmode], 'Xtestout') |
| 927 | qall |
| 928 | [CODE] |
| 929 | if RunVim(before, after, '') |
| 930 | call assert_equal(['insertmode=1'], readfile('Xtestout')) |
| 931 | call delete('Xtestout') |
| 932 | endif |
| 933 | endfunc |
| 934 | |
| 935 | " Test for enabling the binary mode on startup |
| 936 | func Test_b_arg() |
| 937 | let after =<< trim [CODE] |
| 938 | call writefile(['binary=' .. &binary], 'Xtestout') |
| 939 | qall |
| 940 | [CODE] |
| 941 | if RunVim([], after, '-b') |
| 942 | call assert_equal(['binary=1'], readfile('Xtestout')) |
| 943 | call delete('Xtestout') |
| 944 | endif |
| 945 | endfunc |
| 946 | |
| 947 | " Test for enabling the lisp mode on startup |
| 948 | func Test_l_arg() |
| 949 | let after =<< trim [CODE] |
| 950 | let s = 'lisp=' .. &lisp .. ', showmatch=' .. &showmatch |
| 951 | call writefile([s], 'Xtestout') |
| 952 | qall |
| 953 | [CODE] |
| 954 | if RunVim([], after, '-l') |
| 955 | call assert_equal(['lisp=1, showmatch=1'], readfile('Xtestout')) |
| 956 | call delete('Xtestout') |
| 957 | endif |
| 958 | endfunc |
| 959 | |
| 960 | " Test for specifying a non-existing vimrc file using "-u" |
| 961 | func Test_missing_vimrc() |
Bram Moolenaar | 494e906 | 2020-05-31 21:28:02 +0200 | [diff] [blame] | 962 | CheckRunVimInTerminal |
Bram Moolenaar | cde0ff3 | 2020-04-04 14:00:39 +0200 | [diff] [blame] | 963 | let after =<< trim [CODE] |
| 964 | call assert_match('^E282:', v:errmsg) |
| 965 | call writefile(v:errors, 'Xtestout') |
| 966 | [CODE] |
| 967 | call writefile(after, 'Xafter') |
| 968 | |
| 969 | let cmd = GetVimCommandCleanTerm() . ' -u Xvimrc_missing -S Xafter' |
| 970 | let buf = term_start(cmd, {'term_rows' : 10}) |
| 971 | call WaitForAssert({-> assert_equal("running", term_getstatus(buf))}) |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame] | 972 | call TermWait(buf) |
Bram Moolenaar | cde0ff3 | 2020-04-04 14:00:39 +0200 | [diff] [blame] | 973 | call term_sendkeys(buf, "\n:") |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame] | 974 | call TermWait(buf) |
Bram Moolenaar | cde0ff3 | 2020-04-04 14:00:39 +0200 | [diff] [blame] | 975 | call WaitForAssert({-> assert_match(':', term_getline(buf, 10))}) |
| 976 | call StopVimInTerminal(buf) |
| 977 | call assert_equal([], readfile('Xtestout')) |
| 978 | call delete('Xafter') |
| 979 | call delete('Xtestout') |
| 980 | endfunc |
| 981 | |
| 982 | " Test for using the $VIMINIT environment variable |
| 983 | func Test_VIMINIT() |
| 984 | let after =<< trim [CODE] |
| 985 | call assert_equal(1, exists('viminit_found')) |
| 986 | call assert_equal('yes', viminit_found) |
| 987 | call writefile(v:errors, 'Xtestout') |
| 988 | qall |
| 989 | [CODE] |
| 990 | call writefile(after, 'Xafter') |
| 991 | let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "set enc=utf8"' |
| 992 | call setenv('VIMINIT', 'let viminit_found="yes"') |
| 993 | exe "silent !" . cmd |
| 994 | call assert_equal([], readfile('Xtestout')) |
| 995 | call delete('Xtestout') |
| 996 | call delete('Xafter') |
| 997 | endfunc |
| 998 | |
| 999 | " Test for using the $EXINIT environment variable |
| 1000 | func Test_EXINIT() |
| 1001 | let after =<< trim [CODE] |
| 1002 | call assert_equal(1, exists('exinit_found')) |
| 1003 | call assert_equal('yes', exinit_found) |
| 1004 | call writefile(v:errors, 'Xtestout') |
| 1005 | qall |
| 1006 | [CODE] |
| 1007 | call writefile(after, 'Xafter') |
| 1008 | let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "set enc=utf8"' |
| 1009 | call setenv('EXINIT', 'let exinit_found="yes"') |
| 1010 | exe "silent !" . cmd |
| 1011 | call assert_equal([], readfile('Xtestout')) |
| 1012 | call delete('Xtestout') |
| 1013 | call delete('Xafter') |
| 1014 | endfunc |
| 1015 | |
| 1016 | " Test for using the 'exrc' option |
| 1017 | func Test_exrc() |
| 1018 | let after =<< trim [CODE] |
| 1019 | call assert_equal(1, &exrc) |
| 1020 | call assert_equal(1, &secure) |
| 1021 | call assert_equal(37, exrc_found) |
| 1022 | call writefile(v:errors, 'Xtestout') |
| 1023 | qall |
| 1024 | [CODE] |
| 1025 | call mkdir('Xdir') |
| 1026 | call writefile(['let exrc_found=37'], 'Xdir/.exrc') |
| 1027 | call writefile(after, 'Xdir/Xafter') |
| 1028 | let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "cd Xdir" --cmd "set enc=utf8 exrc secure"' |
| 1029 | exe "silent !" . cmd |
| 1030 | call assert_equal([], readfile('Xdir/Xtestout')) |
| 1031 | call delete('Xdir', 'rf') |
| 1032 | endfunc |
| 1033 | |
| 1034 | " Test for starting Vim with a non-terminal as input/output |
| 1035 | func Test_io_not_a_terminal() |
| 1036 | " Can't catch the output of gvim. |
| 1037 | CheckNotGui |
| 1038 | CheckUnix |
| 1039 | CheckEnglish |
| 1040 | let l = systemlist(GetVimProg() .. ' --ttyfail') |
| 1041 | call assert_equal(['Vim: Warning: Output is not to a terminal', |
| 1042 | \ 'Vim: Warning: Input is not from a terminal'], l) |
| 1043 | endfunc |
| 1044 | |
| 1045 | " Test for the "-w scriptout" argument |
| 1046 | func Test_w_arg() |
| 1047 | " Can't catch the output of gvim. |
| 1048 | CheckNotGui |
| 1049 | call writefile(["iVim Editor\<Esc>:q!\<CR>"], 'Xscriptin', 'b') |
| 1050 | if RunVim([], [], '-s Xscriptin -w Xscriptout') |
| 1051 | call assert_equal(["iVim Editor\e:q!\r"], readfile('Xscriptout')) |
| 1052 | call delete('Xscriptout') |
| 1053 | endif |
| 1054 | call delete('Xscriptin') |
| 1055 | |
| 1056 | " Test for failing to open the script output file. This test works only when |
| 1057 | " the language is English. |
| 1058 | if v:lang == "C" || v:lang =~ '^[Ee]n' |
| 1059 | call mkdir("Xdir") |
| 1060 | let m = system(GetVimCommand() .. " -w Xdir") |
| 1061 | call assert_equal("Cannot open for script output: \"Xdir\"\n", m) |
| 1062 | call delete("Xdir", 'rf') |
| 1063 | endif |
| 1064 | endfunc |
| 1065 | |
| 1066 | " Test for the "-s scriptin" argument |
| 1067 | func Test_s_arg() |
| 1068 | " Can't catch the output of gvim. |
| 1069 | CheckNotGui |
| 1070 | CheckEnglish |
| 1071 | " Test for failing to open the script input file. |
| 1072 | let m = system(GetVimCommand() .. " -s abcxyz") |
| 1073 | call assert_equal("Cannot open for reading: \"abcxyz\"\n", m) |
| 1074 | |
| 1075 | call writefile([], 'Xinput') |
| 1076 | let m = system(GetVimCommand() .. " -s Xinput -s Xinput") |
| 1077 | call assert_equal("Attempt to open script file again: \"-s Xinput\"\n", m) |
| 1078 | call delete('Xinput') |
| 1079 | endfunc |
| 1080 | |
| 1081 | " Test for the "-n" (no swap file) argument |
| 1082 | func Test_n_arg() |
| 1083 | let after =<< trim [CODE] |
| 1084 | call assert_equal(0, &updatecount) |
| 1085 | call writefile(v:errors, 'Xtestout') |
| 1086 | qall |
| 1087 | [CODE] |
| 1088 | if RunVim([], after, '-n') |
| 1089 | call assert_equal([], readfile('Xtestout')) |
| 1090 | call delete('Xtestout') |
| 1091 | endif |
Bram Moolenaar | cde0ff3 | 2020-04-04 14:00:39 +0200 | [diff] [blame] | 1092 | endfunc |
| 1093 | |
| 1094 | " Test for the "-h" (help) argument |
| 1095 | func Test_h_arg() |
| 1096 | " Can't catch the output of gvim. |
| 1097 | CheckNotGui |
| 1098 | let l = systemlist(GetVimProg() .. ' -h') |
| 1099 | call assert_match('^VIM - Vi IMproved', l[0]) |
| 1100 | let l = systemlist(GetVimProg() .. ' -?') |
| 1101 | call assert_match('^VIM - Vi IMproved', l[0]) |
| 1102 | endfunc |
| 1103 | |
| 1104 | " Test for the "-F" (farsi) argument |
| 1105 | func Test_F_arg() |
| 1106 | " Can't catch the output of gvim. |
| 1107 | CheckNotGui |
| 1108 | let l = systemlist(GetVimProg() .. ' -F') |
| 1109 | call assert_match('^E27:', l[0]) |
| 1110 | endfunc |
| 1111 | |
| 1112 | " Test for the "-E" (improved Ex mode) argument |
| 1113 | func Test_E_arg() |
| 1114 | let after =<< trim [CODE] |
| 1115 | call assert_equal('cv', mode(1)) |
| 1116 | call writefile(v:errors, 'Xtestout') |
| 1117 | qall |
| 1118 | [CODE] |
| 1119 | if RunVim([], after, '-E') |
| 1120 | call assert_equal([], readfile('Xtestout')) |
| 1121 | call delete('Xtestout') |
| 1122 | endif |
Bram Moolenaar | cde0ff3 | 2020-04-04 14:00:39 +0200 | [diff] [blame] | 1123 | endfunc |
| 1124 | |
| 1125 | " Test for too many edit argument errors |
| 1126 | func Test_too_many_edit_args() |
| 1127 | " Can't catch the output of gvim. |
| 1128 | CheckNotGui |
| 1129 | CheckEnglish |
| 1130 | let l = systemlist(GetVimProg() .. ' - -') |
| 1131 | call assert_match('^Too many edit arguments: "-"', l[1]) |
| 1132 | endfunc |
| 1133 | |
Bram Moolenaar | df4c9af | 2021-01-11 19:54:42 +0100 | [diff] [blame] | 1134 | " Test starting vim with various names: vim, ex, view, evim, etc. |
| 1135 | func Test_progname() |
| 1136 | CheckUnix |
| 1137 | |
| 1138 | call mkdir('Xprogname', 'p') |
| 1139 | call writefile(['silent !date', |
| 1140 | \ 'call writefile([mode(1), ' |
| 1141 | \ .. '&insertmode, &diff, &readonly, &updatecount, ' |
| 1142 | \ .. 'join(split(execute("message"), "\n")[1:])], "Xprogname_out")', |
| 1143 | \ 'qall'], 'Xprogname_after') |
| 1144 | |
| 1145 | " +---------------------------------------------- progname |
| 1146 | " | +--------------------------------- mode(1) |
| 1147 | " | | +--------------------------- &insertmode |
| 1148 | " | | | +---------------------- &diff |
| 1149 | " | | | | +----------------- &readonly |
| 1150 | " | | | | | +-------- &updatecount |
| 1151 | " | | | | | | +--- :messages |
| 1152 | " | | | | | | | |
| 1153 | let expectations = { |
| 1154 | \ 'vim': ['n', '0', '0', '0', '200', ''], |
| 1155 | \ 'gvim': ['n', '0', '0', '0', '200', ''], |
| 1156 | \ 'ex': ['ce', '0', '0', '0', '200', ''], |
| 1157 | \ 'exim': ['cv', '0', '0', '0', '200', ''], |
| 1158 | \ 'view': ['n', '0', '0', '1', '10000', ''], |
| 1159 | \ 'gview': ['n', '0', '0', '1', '10000', ''], |
| 1160 | \ 'evim': ['n', '1', '0', '0', '200', ''], |
| 1161 | \ 'eview': ['n', '1', '0', '1', '10000', ''], |
| 1162 | \ 'rvim': ['n', '0', '0', '0', '200', 'line 1: E145: Shell commands and some functionality not allowed in rvim'], |
| 1163 | \ 'rgvim': ['n', '0', '0', '0', '200', 'line 1: E145: Shell commands and some functionality not allowed in rvim'], |
| 1164 | \ 'rview': ['n', '0', '0', '1', '10000', 'line 1: E145: Shell commands and some functionality not allowed in rvim'], |
| 1165 | \ 'rgview': ['n', '0', '0', '1', '10000', 'line 1: E145: Shell commands and some functionality not allowed in rvim'], |
| 1166 | \ 'vimdiff': ['n', '0', '1', '0', '200', ''], |
| 1167 | \ 'gvimdiff': ['n', '0', '1', '0', '200', '']} |
| 1168 | |
| 1169 | let prognames = ['vim', 'gvim', 'ex', 'exim', 'view', 'gview', |
| 1170 | \ 'evim', 'eview', 'rvim', 'rgvim', 'rview', 'rgview', |
| 1171 | \ 'vimdiff', 'gvimdiff'] |
| 1172 | |
| 1173 | for progname in prognames |
Bram Moolenaar | 240309c | 2021-03-14 16:20:37 +0100 | [diff] [blame] | 1174 | let run_with_gui = (progname =~# 'g') || (has('gui') && (progname ==# 'evim' || progname ==# 'eview')) |
| 1175 | |
| 1176 | if empty($DISPLAY) && run_with_gui |
| 1177 | " Can't run gvim, gview (etc.) if $DISPLAY is not setup. |
| 1178 | continue |
Bram Moolenaar | df4c9af | 2021-01-11 19:54:42 +0100 | [diff] [blame] | 1179 | endif |
| 1180 | |
| 1181 | exe 'silent !ln -s -f ' ..exepath(GetVimProg()) .. ' Xprogname/' .. progname |
| 1182 | |
| 1183 | let stdout_stderr = '' |
| 1184 | if progname =~# 'g' |
| 1185 | let stdout_stderr = system('Xprogname/'..progname..' -f --clean --not-a-term -S Xprogname_after') |
| 1186 | else |
| 1187 | exe 'sil !Xprogname/'..progname..' -f --clean --not-a-term -S Xprogname_after' |
| 1188 | endif |
| 1189 | |
| 1190 | if progname =~# 'g' && !has('gui') |
| 1191 | call assert_equal("E25: GUI cannot be used: Not enabled at compile time\n", stdout_stderr, progname) |
| 1192 | else |
Bram Moolenaar | 240309c | 2021-03-14 16:20:37 +0100 | [diff] [blame] | 1193 | " GUI motif can output some warnings like this: |
| 1194 | " Warning: |
| 1195 | " Name: subMenu |
| 1196 | " Class: XmCascadeButton |
| 1197 | " Illegal mnemonic character; Could not convert X KEYSYM to a keycode |
| 1198 | " So don't check that stderr is empty with GUI Motif. |
| 1199 | if run_with_gui && !has('gui_motif') |
| 1200 | call assert_equal('', stdout_stderr, progname) |
| 1201 | endif |
Bram Moolenaar | df4c9af | 2021-01-11 19:54:42 +0100 | [diff] [blame] | 1202 | call assert_equal(expectations[progname], readfile('Xprogname_out'), progname) |
| 1203 | endif |
| 1204 | |
| 1205 | call delete('Xprogname/' .. progname) |
| 1206 | call delete('Xprogname_out') |
| 1207 | endfor |
| 1208 | |
| 1209 | call delete('Xprogname_after') |
| 1210 | call delete('Xprogname', 'd') |
| 1211 | endfunc |
| 1212 | |
Bram Moolenaar | cde0ff3 | 2020-04-04 14:00:39 +0200 | [diff] [blame] | 1213 | " vim: shiftwidth=2 sts=2 expandtab |