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