comparison src/testdir/test_excmd.vim @ 19852:12518b40c161 v8.2.0482

patch 8.2.0482: channel and sandbox code not sufficiently tested Commit: https://github.com/vim/vim/commit/ca68ae13114619df3e4c195b41ad0575516f5ff6 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Mar 30 19:32:53 2020 +0200 patch 8.2.0482: channel and sandbox code not sufficiently tested Problem: Channel and sandbox code not sufficiently tested. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5855)
author Bram Moolenaar <Bram@vim.org>
date Mon, 30 Mar 2020 19:45:05 +0200
parents 2dc8d3e6993e
children 252d2bb90394
comparison
equal deleted inserted replaced
19851:e259e7903c55 19852:12518b40c161
407 call setline(1, ['foo', "\tbar"]) 407 call setline(1, ['foo', "\tbar"])
408 call assert_equal([' bar'], split(execute('deletep'), "\n")) 408 call assert_equal([' bar'], split(execute('deletep'), "\n"))
409 close! 409 close!
410 endfunc 410 endfunc
411 411
412 " Test for commands that are blocked in a sandbox
413 func Sandbox_tests()
414 call assert_fails("call histadd(':', 'ls')", 'E48:')
415 call assert_fails("call mkdir('Xdir')", 'E48:')
416 call assert_fails("call rename('a', 'b')", 'E48:')
417 call assert_fails("call setbufvar(1, 'myvar', 1)", 'E48:')
418 call assert_fails("call settabvar(1, 'myvar', 1)", 'E48:')
419 call assert_fails("call settabwinvar(1, 1, 'myvar', 1)", 'E48:')
420 call assert_fails("call setwinvar(1, 'myvar', 1)", 'E48:')
421 call assert_fails("call timer_start(100, '')", 'E48:')
422 if has('channel')
423 call assert_fails("call prompt_setcallback(1, '')", 'E48:')
424 call assert_fails("call prompt_setinterrupt(1, '')", 'E48:')
425 call assert_fails("call prompt_setprompt(1, '')", 'E48:')
426 endif
427 call assert_fails("let $TESTVAR=1", 'E48:')
428 call assert_fails("call feedkeys('ivim')", 'E48:')
429 call assert_fails("source! Xfile", 'E48:')
430 call assert_fails("call delete('Xfile')", 'E48:')
431 call assert_fails("call writefile([], 'Xfile')", 'E48:')
432 call assert_fails('!ls', 'E48:')
433 call assert_fails('shell', 'E48:')
434 call assert_fails('stop', 'E48:')
435 call assert_fails('exe "normal \<C-Z>"', 'E48:')
436 set insertmode
437 call assert_fails('call feedkeys("\<C-Z>", "xt")', 'E48:')
438 set insertmode&
439 call assert_fails('suspend', 'E48:')
440 call assert_fails('call system("ls")', 'E48:')
441 call assert_fails('call systemlist("ls")', 'E48:')
442 if has('clientserver')
443 call assert_fails('let s=remote_expr("gvim", "2+2")', 'E48:')
444 if !has('win32')
445 " remote_foreground() doesn't thrown an error message on MS-Windows
446 call assert_fails('call remote_foreground("gvim")', 'E48:')
447 endif
448 call assert_fails('let s=remote_peek("gvim")', 'E48:')
449 call assert_fails('let s=remote_read("gvim")', 'E48:')
450 call assert_fails('let s=remote_send("gvim", "abc")', 'E48:')
451 call assert_fails('let s=server2client("gvim", "abc")', 'E48:')
452 endif
453 if has('terminal')
454 call assert_fails('terminal', 'E48:')
455 call assert_fails('call term_start("vim")', 'E48:')
456 call assert_fails('call term_dumpwrite(1, "Xfile")', 'E48:')
457 endif
458 if has('channel')
459 call assert_fails("call ch_logfile('chlog')", 'E48:')
460 call assert_fails("call ch_open('localhost:8765')", 'E48:')
461 endif
462 if has('job')
463 call assert_fails("call job_start('vim')", 'E48:')
464 endif
465 if has('unix') && has('libcall')
466 call assert_fails("echo libcall('libc.so', 'getenv', 'HOME')", 'E48:')
467 endif
468 if has('unix')
469 call assert_fails('cd `pwd`', 'E48:')
470 endif
471 endfunc
472
473 func Test_sandbox()
474 sandbox call Sandbox_tests()
475 endfunc
476
412 " vim: shiftwidth=2 sts=2 expandtab 477 " vim: shiftwidth=2 sts=2 expandtab