blob: 6509c0cc16473d16d129ef9cf085a1fa5006461b [file] [log] [blame]
Bram Moolenaar66459b72016-08-06 19:01:55 +02001" Tests for startup.
Bram Moolenaarb9a46fe2016-07-29 18:13:42 +02002
Bram Moolenaar66459b72016-08-06 19:01:55 +02003source shared.vim
Bram Moolenaarc75e8122019-04-21 15:55:10 +02004source screendump.vim
Bram Moolenaar66459b72016-08-06 19:01:55 +02005
6" Check that loading startup.vim works.
Bram Moolenaarb9a46fe2016-07-29 18:13:42 +02007func Test_startup_script()
8 set compatible
9 source $VIMRUNTIME/defaults.vim
10
11 call assert_equal(0, &compatible)
12endfunc
Bram Moolenaar66459b72016-08-06 19:01:55 +020013
14" Verify the order in which plugins are loaded:
15" 1. plugins in non-after directories
16" 2. packages
17" 3. plugins in after directories
18func Test_after_comes_later()
Bram Moolenaar32860432016-08-06 19:24:23 +020019 if !has('packages')
20 return
21 endif
Bram Moolenaar66459b72016-08-06 19:01:55 +020022 let before = [
Bram Moolenaar446cce62016-08-06 21:37:27 +020023 \ 'set nocp viminfo+=nviminfo',
24 \ 'set guioptions+=M',
Bram Moolenaar66459b72016-08-06 19:01:55 +020025 \ 'let $HOME = "/does/not/exist"',
26 \ 'set loadplugins',
Bram Moolenaar07ecfa62017-06-27 14:43:55 +020027 \ 'set rtp=Xhere,Xafter,Xanother',
Bram Moolenaar66459b72016-08-06 19:01:55 +020028 \ 'set packpath=Xhere,Xafter',
29 \ 'set nomore',
Bram Moolenaar07ecfa62017-06-27 14:43:55 +020030 \ 'let g:sequence = ""',
Bram Moolenaar66459b72016-08-06 19:01:55 +020031 \ ]
32 let after = [
33 \ 'redir! > Xtestout',
34 \ 'scriptnames',
35 \ 'redir END',
Bram Moolenaar07ecfa62017-06-27 14:43:55 +020036 \ 'redir! > Xsequence',
37 \ 'echo g:sequence',
38 \ 'redir END',
Bram Moolenaar66459b72016-08-06 19:01:55 +020039 \ 'quit',
40 \ ]
41 call mkdir('Xhere/plugin', 'p')
Bram Moolenaar07ecfa62017-06-27 14:43:55 +020042 call writefile(['let g:sequence .= "here "'], 'Xhere/plugin/here.vim')
43 call mkdir('Xanother/plugin', 'p')
44 call writefile(['let g:sequence .= "another "'], 'Xanother/plugin/another.vim')
Bram Moolenaar66459b72016-08-06 19:01:55 +020045 call mkdir('Xhere/pack/foo/start/foobar/plugin', 'p')
Bram Moolenaar07ecfa62017-06-27 14:43:55 +020046 call writefile(['let g:sequence .= "pack "'], 'Xhere/pack/foo/start/foobar/plugin/foo.vim')
Bram Moolenaar66459b72016-08-06 19:01:55 +020047
48 call mkdir('Xafter/plugin', 'p')
Bram Moolenaar07ecfa62017-06-27 14:43:55 +020049 call writefile(['let g:sequence .= "after "'], 'Xafter/plugin/later.vim')
Bram Moolenaar66459b72016-08-06 19:01:55 +020050
Bram Moolenaar472a0a82016-08-06 22:31:42 +020051 if RunVim(before, after, '')
Bram Moolenaar66459b72016-08-06 19:01:55 +020052
Bram Moolenaar83b3c3d2016-08-06 19:16:43 +020053 let lines = readfile('Xtestout')
Bram Moolenaar07ecfa62017-06-27 14:43:55 +020054 let expected = ['Xbefore.vim', 'here.vim', 'another.vim', 'foo.vim', 'later.vim', 'Xafter.vim']
Bram Moolenaar83b3c3d2016-08-06 19:16:43 +020055 let found = []
56 for line in lines
57 for one in expected
58 if line =~ one
59 call add(found, one)
60 endif
61 endfor
Bram Moolenaar66459b72016-08-06 19:01:55 +020062 endfor
Bram Moolenaar83b3c3d2016-08-06 19:16:43 +020063 call assert_equal(expected, found)
64 endif
Bram Moolenaar66459b72016-08-06 19:01:55 +020065
Bram Moolenaar07ecfa62017-06-27 14:43:55 +020066 call assert_equal('here another pack after', substitute(join(readfile('Xsequence', 1), ''), '\s\+$', '', ''))
67
Bram Moolenaar66459b72016-08-06 19:01:55 +020068 call delete('Xtestout')
Bram Moolenaar07ecfa62017-06-27 14:43:55 +020069 call delete('Xsequence')
Bram Moolenaar66459b72016-08-06 19:01:55 +020070 call delete('Xhere', 'rf')
Bram Moolenaar07ecfa62017-06-27 14:43:55 +020071 call delete('Xanother', 'rf')
Bram Moolenaar66459b72016-08-06 19:01:55 +020072 call delete('Xafter', 'rf')
73endfunc
Bram Moolenaar472a0a82016-08-06 22:31:42 +020074
Bram Moolenaarce876aa2017-06-04 17:47:42 +020075func Test_pack_in_rtp_when_plugins_run()
76 if !has('packages')
77 return
78 endif
79 let before = [
80 \ 'set nocp viminfo+=nviminfo',
81 \ 'set guioptions+=M',
82 \ 'let $HOME = "/does/not/exist"',
83 \ 'set loadplugins',
84 \ 'set rtp=Xhere',
85 \ 'set packpath=Xhere',
86 \ 'set nomore',
87 \ ]
88 let after = [
89 \ 'quit',
90 \ ]
91 call mkdir('Xhere/plugin', 'p')
92 call writefile(['redir! > Xtestout', 'silent set runtimepath?', 'silent! call foo#Trigger()', 'redir END'], 'Xhere/plugin/here.vim')
93 call mkdir('Xhere/pack/foo/start/foobar/autoload', 'p')
94 call writefile(['function! foo#Trigger()', 'echo "autoloaded foo"', 'endfunction'], 'Xhere/pack/foo/start/foobar/autoload/foo.vim')
95
96 if RunVim(before, after, '')
97
98 let lines = filter(readfile('Xtestout'), '!empty(v:val)')
99 call assert_match('Xhere[/\\]pack[/\\]foo[/\\]start[/\\]foobar', get(lines, 0))
100 call assert_match('autoloaded foo', get(lines, 1))
101 endif
102
103 call delete('Xtestout')
104 call delete('Xhere', 'rf')
105endfunc
106
Bram Moolenaar472a0a82016-08-06 22:31:42 +0200107func Test_help_arg()
Bram Moolenaar3321e9d2016-08-06 23:03:59 +0200108 if !has('unix') && has('gui')
109 " this doesn't work with gvim on MS-Windows
110 return
111 endif
Bram Moolenaar472a0a82016-08-06 22:31:42 +0200112 if RunVim([], [], '--help >Xtestout')
113 let lines = readfile('Xtestout')
114 call assert_true(len(lines) > 20)
Bram Moolenaarba98bef2016-08-07 15:51:39 +0200115 call assert_match('Vi IMproved', lines[0])
Bram Moolenaar472a0a82016-08-06 22:31:42 +0200116
117 " check if couple of lines are there
Bram Moolenaar50fa8dd2016-08-09 22:58:21 +0200118 let found = []
Bram Moolenaar472a0a82016-08-06 22:31:42 +0200119 for line in lines
120 if line =~ '-R.*Readonly mode'
Bram Moolenaar50fa8dd2016-08-09 22:58:21 +0200121 call add(found, 'Readonly mode')
Bram Moolenaar472a0a82016-08-06 22:31:42 +0200122 endif
Bram Moolenaar50fa8dd2016-08-09 22:58:21 +0200123 " Watch out for a second --version line in the Gnome version.
124 if line =~ '--version.*Print version information and exit'
125 call add(found, "--version")
Bram Moolenaar472a0a82016-08-06 22:31:42 +0200126 endif
127 endfor
Bram Moolenaar50fa8dd2016-08-09 22:58:21 +0200128 call assert_equal(['Readonly mode', '--version'], found)
Bram Moolenaar472a0a82016-08-06 22:31:42 +0200129 endif
130 call delete('Xtestout')
131endfunc
Bram Moolenaarba98bef2016-08-07 15:51:39 +0200132
133func Test_compatible_args()
134 let after = [
135 \ 'call writefile([string(&compatible)], "Xtestout")',
136 \ 'set viminfo+=nviminfo',
137 \ 'quit',
138 \ ]
139 if RunVim([], after, '-C')
140 let lines = readfile('Xtestout')
141 call assert_equal('1', lines[0])
142 endif
143
144 if RunVim([], after, '-N')
145 let lines = readfile('Xtestout')
146 call assert_equal('0', lines[0])
147 endif
148
149 call delete('Xtestout')
150endfunc
151
Bram Moolenaar8f4499b2018-09-16 16:28:11 +0200152" Test the -o[N] and -O[N] arguments to open N windows split
153" horizontally or vertically.
154func Test_o_arg()
155 let after = [
156 \ 'call writefile([winnr("$"),
157 \ winheight(1), winheight(2), &lines,
158 \ winwidth(1), winwidth(2), &columns,
159 \ bufname(winbufnr(1)), bufname(winbufnr(2))],
160 \ "Xtestout")',
161 \ 'qall',
162 \ ]
163 if RunVim([], after, '-o2')
164 " Open 2 windows split horizontally. Expect:
165 " - 2 windows
166 " - both windows should have the same or almost the same height
167 " - sum of both windows height (+ 3 for both statusline and Ex command)
168 " should be equal to the number of lines
169 " - both windows should have the same width which should be equal to the
170 " number of columns
171 " - buffer of both windows should have no name
172 let [wn, wh1, wh2, ln, ww1, ww2, cn, bn1, bn2] = readfile('Xtestout')
173 call assert_equal('2', wn)
174 call assert_inrange(0, 1, wh1 - wh2)
175 call assert_equal(string(wh1 + wh2 + 3), ln)
176 call assert_equal(ww1, ww2)
177 call assert_equal(ww1, cn)
178 call assert_equal('', bn1)
179 call assert_equal('', bn2)
180 endif
181
182 if RunVim([], after, '-o foo bar')
183 " Same expectations as for -o2 but buffer names should be foo and bar
184 let [wn, wh1, wh2, ln, ww1, ww2, cn, bn1, bn2] = readfile('Xtestout')
185 call assert_equal('2', wn)
186 call assert_inrange(0, 1, wh1 - wh2)
187 call assert_equal(string(wh1 + wh2 + 3), ln)
188 call assert_equal(ww1, ww2)
189 call assert_equal(ww1, cn)
190 call assert_equal('foo', bn1)
191 call assert_equal('bar', bn2)
192 endif
193
194 if RunVim([], after, '-O2')
195 " Open 2 windows split vertically. Expect:
196 " - 2 windows
197 " - both windows should have the same or almost the same width
Bram Moolenaar036b09c2018-09-21 12:54:06 +0200198 " - sum of both windows width (+ 1 for the separator) should be equal to
199 " the number of columns
Bram Moolenaar8f4499b2018-09-16 16:28:11 +0200200 " - both windows should have the same height
201 " - window height (+ 2 for the statusline and Ex command) should be equal
202 " to the number of lines
Bram Moolenaar9e81db92018-09-18 22:37:31 +0200203 " - buffer of both windows should have no name
Bram Moolenaar8f4499b2018-09-16 16:28:11 +0200204 let [wn, wh1, wh2, ln, ww1, ww2, cn, bn1, bn2] = readfile('Xtestout')
205 call assert_equal('2', wn)
206 call assert_inrange(0, 1, ww1 - ww2)
207 call assert_equal(string(ww1 + ww2 + 1), cn)
208 call assert_equal(wh1, wh2)
209 call assert_equal(string(wh1 + 2), ln)
210 call assert_equal('', bn1)
211 call assert_equal('', bn2)
212 endif
213
214 if RunVim([], after, '-O foo bar')
215 " Same expectations as for -O2 but buffer names should be foo and bar
216 let [wn, wh1, wh2, ln, ww1, ww2, cn, bn1, bn2] = readfile('Xtestout')
217 call assert_equal('2', wn)
218 call assert_inrange(0, 1, ww1 - ww2)
219 call assert_equal(string(ww1 + ww2 + 1), cn)
220 call assert_equal(wh1, wh2)
221 call assert_equal(string(wh1 + 2), ln)
222 call assert_equal('foo', bn1)
223 call assert_equal('bar', bn2)
224 endif
225
226 call delete('Xtestout')
227endfunc
228
Bram Moolenaar9e81db92018-09-18 22:37:31 +0200229" Test the -p[N] argument to open N tabpages.
230func Test_p_arg()
231 let after = [
232 \ 'call writefile(split(execute("tabs"), "\n"), "Xtestout")',
233 \ 'qall',
234 \ ]
235 if RunVim([], after, '-p2')
236 let lines = readfile('Xtestout')
237 call assert_equal(4, len(lines))
238 call assert_equal('Tab page 1', lines[0])
239 call assert_equal('> [No Name]', lines[1])
240 call assert_equal('Tab page 2', lines[2])
241 call assert_equal(' [No Name]', lines[3])
242 endif
243
244 if RunVim([], after, '-p foo bar')
245 let lines = readfile('Xtestout')
246 call assert_equal(4, len(lines))
247 call assert_equal('Tab page 1', lines[0])
248 call assert_equal('> foo', lines[1])
249 call assert_equal('Tab page 2', lines[2])
250 call assert_equal(' bar', lines[3])
251 endif
252
253 call delete('Xtestout')
254endfunc
255
Bram Moolenaar4b1c9a92018-09-19 21:06:31 +0200256" Test the -V[N] argument to set the 'verbose' option to [N]
Bram Moolenaar9e81db92018-09-18 22:37:31 +0200257func Test_V_arg()
Bram Moolenaar4b1c9a92018-09-19 21:06:31 +0200258 if has('gui_running')
259 " Can't catch the output of gvim.
260 return
261 endif
Bram Moolenaar9e81db92018-09-18 22:37:31 +0200262 let out = system(GetVimCommand() . ' --clean -es -X -V0 -c "set verbose?" -cq')
263 call assert_equal(" verbose=0\n", out)
264
265 let out = system(GetVimCommand() . ' --clean -es -X -V2 -c "set verbose?" -cq')
Bram Moolenaar4b1c9a92018-09-19 21:06:31 +0200266 call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nSearching for \"filetype\.vim\".*\n", out)
267 call assert_match(" verbose=2\n", out)
Bram Moolenaar9e81db92018-09-18 22:37:31 +0200268
269 let out = system(GetVimCommand() . ' --clean -es -X -V15 -c "set verbose?" -cq')
Bram Moolenaar4b1c9a92018-09-19 21:06:31 +0200270 call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nline 1: \" The default vimrc file\..* verbose=15\n", out)
Bram Moolenaar9e81db92018-09-18 22:37:31 +0200271endfunc
272
Bram Moolenaar54948182018-12-28 18:32:56 +0100273" Test the '-q [errorfile]' argument.
274func Test_q_arg()
275 let source_file = has('win32') ? '..\memfile.c' : '../memfile.c'
276 let after = [
277 \ 'call writefile([&errorfile, string(getpos("."))], "Xtestout")',
278 \ 'copen',
279 \ 'w >> Xtestout',
280 \ 'qall'
281 \ ]
282
283 " Test with default argument '-q'.
284 call assert_equal('errors.err', &errorfile)
285 call writefile(["../memfile.c:1482:5: error: expected ';' before '}' token"], 'errors.err')
286 if RunVim([], after, '-q')
287 let lines = readfile('Xtestout')
288 call assert_equal(['errors.err',
289 \ '[0, 1482, 5, 0]',
290 \ source_file . "|1482 col 5| error: expected ';' before '}' token"],
291 \ lines)
292 endif
293 call delete('Xtestout')
294 call delete('errors.err')
295
296 " Test with explicit argument '-q Xerrors' (with space).
297 call writefile(["../memfile.c:1482:5: error: expected ';' before '}' token"], 'Xerrors')
298 if RunVim([], after, '-q Xerrors')
299 let lines = readfile('Xtestout')
300 call assert_equal(['Xerrors',
301 \ '[0, 1482, 5, 0]',
302 \ source_file . "|1482 col 5| error: expected ';' before '}' token"],
303 \ lines)
304 endif
305 call delete('Xtestout')
306
307 " Test with explicit argument '-qXerrors' (without space).
308 if RunVim([], after, '-qXerrors')
309 let lines = readfile('Xtestout')
310 call assert_equal(['Xerrors',
311 \ '[0, 1482, 5, 0]',
312 \ source_file . "|1482 col 5| error: expected ';' before '}' token"],
313 \ lines)
314 endif
315
316 call delete('Xtestout')
317 call delete('Xerrors')
318endfunc
319
Bram Moolenaar036b09c2018-09-21 12:54:06 +0200320" Test the -V[N]{filename} argument to set the 'verbose' option to N
321" and set 'verbosefile' to filename.
322func Test_V_file_arg()
Bram Moolenaar4841a7c2018-09-22 14:08:49 +0200323 if RunVim([], [], ' --clean -V2Xverbosefile -c "set verbose? verbosefile?" -cq')
Bram Moolenaar036b09c2018-09-21 12:54:06 +0200324 let out = join(readfile('Xverbosefile'), "\n")
325 call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\n", out)
326 call assert_match("\n verbose=2\n", out)
327 call assert_match("\n verbosefile=Xverbosefile", out)
328 endif
329
330 call delete('Xverbosefile')
331endfunc
332
333" Test the -m, -M and -R arguments:
334" -m resets 'write'
335" -M resets 'modifiable' and 'write'
336" -R sets 'readonly'
337func Test_m_M_R()
338 let after = [
339 \ 'call writefile([&write, &modifiable, &readonly, &updatecount], "Xtestout")',
340 \ 'qall',
341 \ ]
342 if RunVim([], after, '')
343 let lines = readfile('Xtestout')
344 call assert_equal(['1', '1', '0', '200'], lines)
345 endif
346 if RunVim([], after, '-m')
347 let lines = readfile('Xtestout')
348 call assert_equal(['0', '1', '0', '200'], lines)
349 endif
350 if RunVim([], after, '-M')
351 let lines = readfile('Xtestout')
352 call assert_equal(['0', '0', '0', '200'], lines)
353 endif
354 if RunVim([], after, '-R')
355 let lines = readfile('Xtestout')
356 call assert_equal(['1', '1', '1', '10000'], lines)
357 endif
358
359 call delete('Xtestout')
360endfunc
361
Bram Moolenaar9e81db92018-09-18 22:37:31 +0200362" Test the -A, -F and -H arguments (Arabic, Farsi and Hebrew modes).
363func Test_A_F_H_arg()
364 let after = [
365 \ 'call writefile([&rightleft, &arabic, &fkmap, &hkmap], "Xtestout")',
366 \ 'qall',
367 \ ]
Bram Moolenaar4b1c9a92018-09-19 21:06:31 +0200368 " Use silent Ex mode to avoid the hit-Enter prompt for the warning that
369 " 'encoding' is not utf-8.
370 if has('arabic') && &encoding == 'utf-8' && RunVim([], after, '-e -s -A')
Bram Moolenaar9e81db92018-09-18 22:37:31 +0200371 let lines = readfile('Xtestout')
372 call assert_equal(['1', '1', '0', '0'], lines)
373 endif
374
375 if has('farsi') && RunVim([], after, '-F')
376 let lines = readfile('Xtestout')
377 call assert_equal(['1', '0', '1', '0'], lines)
378 endif
379
380 if has('rightleft') && RunVim([], after, '-H')
381 let lines = readfile('Xtestout')
382 call assert_equal(['1', '0', '0', '1'], lines)
383 endif
384
385 call delete('Xtestout')
386endfunc
387
Bram Moolenaarba98bef2016-08-07 15:51:39 +0200388func Test_file_args()
389 let after = [
390 \ 'call writefile(argv(), "Xtestout")',
391 \ 'qall',
392 \ ]
393 if RunVim([], after, '')
394 let lines = readfile('Xtestout')
395 call assert_equal(0, len(lines))
396 endif
397
398 if RunVim([], after, 'one')
399 let lines = readfile('Xtestout')
400 call assert_equal(1, len(lines))
401 call assert_equal('one', lines[0])
402 endif
403
404 if RunVim([], after, 'one two three')
405 let lines = readfile('Xtestout')
406 call assert_equal(3, len(lines))
407 call assert_equal('one', lines[0])
408 call assert_equal('two', lines[1])
409 call assert_equal('three', lines[2])
410 endif
411
412 if RunVim([], after, 'one -c echo two')
413 let lines = readfile('Xtestout')
414 call assert_equal(2, len(lines))
415 call assert_equal('one', lines[0])
416 call assert_equal('two', lines[1])
417 endif
418
419 if RunVim([], after, 'one -- -c echo two')
420 let lines = readfile('Xtestout')
421 call assert_equal(4, len(lines))
422 call assert_equal('one', lines[0])
423 call assert_equal('-c', lines[1])
424 call assert_equal('echo', lines[2])
425 call assert_equal('two', lines[3])
426 endif
427
428 call delete('Xtestout')
429endfunc
430
431func Test_startuptime()
432 if !has('startuptime')
433 return
434 endif
435 let after = ['qall']
436 if RunVim([], after, '--startuptime Xtestout one')
437 let lines = readfile('Xtestout')
438 let expected = ['--- VIM STARTING ---', 'parsing arguments',
439 \ 'shell init', 'inits 3', 'start termcap', 'opening buffers']
440 let found = []
441 for line in lines
442 for exp in expected
443 if line =~ exp
444 call add(found, exp)
445 endif
446 endfor
447 endfor
448 call assert_equal(expected, found)
449 endif
450 call delete('Xtestout')
451endfunc
Bram Moolenaar3a938382016-08-07 16:36:40 +0200452
453func Test_read_stdin()
454 let after = [
455 \ 'write Xtestout',
456 \ 'quit!',
457 \ ]
458 if RunVimPiped([], after, '-', 'echo something | ')
459 let lines = readfile('Xtestout')
Bram Moolenaare4a76ad2016-08-07 16:50:10 +0200460 " MS-Windows adds a space after the word
461 call assert_equal(['something'], split(lines[0]))
Bram Moolenaar3a938382016-08-07 16:36:40 +0200462 endif
463 call delete('Xtestout')
464endfunc
Bram Moolenaar08cab962017-03-04 14:37:18 +0100465
Bram Moolenaar4bfa8af2018-02-03 15:14:46 +0100466func Test_set_shell()
467 let after = [
468 \ 'call writefile([&shell], "Xtestout")',
469 \ 'quit!',
470 \ ]
471 let $SHELL = '/bin/with space/sh'
472 if RunVimPiped([], after, '', '')
473 let lines = readfile('Xtestout')
474 " MS-Windows adds a space after the word
475 call assert_equal('/bin/with\ space/sh', lines[0])
476 endif
477 call delete('Xtestout')
478endfunc
479
Bram Moolenaar08cab962017-03-04 14:37:18 +0100480func Test_progpath()
481 " Tests normally run with "./vim" or "../vim", these must have been expanded
482 " to a full path.
483 if has('unix')
484 call assert_equal('/', v:progpath[0])
485 elseif has('win32')
486 call assert_equal(':', v:progpath[1])
487 call assert_match('[/\\]', v:progpath[2])
488 endif
489
490 " Only expect "vim" to appear in v:progname.
491 call assert_match('vim\c', v:progname)
492endfunc
Bram Moolenaard5d37532017-03-27 23:02:07 +0200493
494func Test_silent_ex_mode()
495 if !has('unix') || has('gui_running')
496 " can't get output of Vim.
497 return
498 endif
499
500 " This caused an ml_get error.
501 let out = system(GetVimCommand() . '-u NONE -es -c''set verbose=1|h|exe "%norm\<c-y>\<c-d>"'' -c cq')
502 call assert_notmatch('E315:', out)
503endfunc
Bram Moolenaar85045a72017-04-02 16:54:09 +0200504
505func Test_default_term()
506 if !has('unix') || has('gui_running')
507 " can't get output of Vim.
508 return
509 endif
510
511 let save_term = $TERM
Bram Moolenaar08f88b12017-04-02 17:21:16 +0200512 let $TERM = 'unknownxxx'
Bram Moolenaar85045a72017-04-02 16:54:09 +0200513 let out = system(GetVimCommand() . ' -c''set term'' -c cq')
514 call assert_match("defaulting to 'ansi'", out)
515 let $TERM = save_term
516endfunc
Bram Moolenaar09ca9322017-09-26 17:40:45 +0200517
518func Test_zzz_startinsert()
519 " Test :startinsert
520 call writefile(['123456'], 'Xtestout')
521 let after = [
522 \ ':startinsert',
Bram Moolenaar036b09c2018-09-21 12:54:06 +0200523 \ 'call feedkeys("foobar\<c-o>:wq\<cr>","t")'
Bram Moolenaar09ca9322017-09-26 17:40:45 +0200524 \ ]
525 if RunVim([], after, 'Xtestout')
526 let lines = readfile('Xtestout')
527 call assert_equal(['foobar123456'], lines)
528 endif
529 " Test :startinsert!
530 call writefile(['123456'], 'Xtestout')
531 let after = [
532 \ ':startinsert!',
Bram Moolenaar036b09c2018-09-21 12:54:06 +0200533 \ 'call feedkeys("foobar\<c-o>:wq\<cr>","t")'
Bram Moolenaar09ca9322017-09-26 17:40:45 +0200534 \ ]
535 if RunVim([], after, 'Xtestout')
536 let lines = readfile('Xtestout')
537 call assert_equal(['123456foobar'], lines)
538 endif
539 call delete('Xtestout')
540endfunc
Bram Moolenaar97c2c052019-02-22 13:42:07 +0100541
542func Test_issue_3969()
543 if has('gui_running')
544 " Can't catch the output of gvim.
545 return
546 endif
547 " Check that message is not truncated.
548 let out = system(GetVimCommand() . ' -es -X -V1 -c "echon ''hello''" -cq')
549 call assert_equal('hello', out)
550endfunc
Bram Moolenaarc75e8122019-04-21 15:55:10 +0200551
552func Test_start_with_tabs()
553 if !CanRunVimInTerminal()
554 return
555 endif
556
557 let buf = RunVimInTerminal('-p a b c', {})
558 call VerifyScreenDump(buf, 'Test_start_with_tabs', {})
559
560 " clean up
561 call StopVimInTerminal(buf)
562endfunc