Mercurial > vim
diff src/testdir/test_terminal.vim @ 14139:4d3f6bf86bec v8.1.0087
patch 8.1.0087: v:shell_error is always zero when using terminal for "!cmd"
commit https://github.com/vim/vim/commit/f9c3883b11b33f0c548df5e949ba59fde74d3e7b
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jun 19 19:59:20 2018 +0200
patch 8.1.0087: v:shell_error is always zero when using terminal for "!cmd"
Problem: v:shell_error is always zero when using terminal for "!cmd".
Solution: Use "exitval" of terminal-job. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/2994)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 19 Jun 2018 20:00:08 +0200 |
parents | f39150ec146e |
children | 43efca4c482f |
line wrap: on
line diff
--- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -522,29 +522,6 @@ func Test_terminal_env() exe buf . 'bwipe' endfunc -" must be last, we can't go back from GUI to terminal -func Test_zz_terminal_in_gui() - if !CanRunGui() - return - endif - - " Ignore the "failed to create input context" error. - call test_ignore_error('E285:') - - gui -f - - call assert_equal(1, winnr('$')) - let buf = Run_shell_in_terminal({'term_finish': 'close'}) - call Stop_shell_in_terminal(buf) - call term_wait(buf) - - " closing window wipes out the terminal buffer a with finished job - call WaitForAssert({-> assert_equal(1, winnr('$'))}) - call assert_equal("", bufname(buf)) - - unlet g:job -endfunc - func Test_terminal_list_args() let buf = term_start([&shell, &shellcmdflag, 'echo "123"']) call assert_fails(buf . 'bwipe', 'E517') @@ -1546,3 +1523,58 @@ func Test_terminwinscroll() exe buf . 'bwipe!' endfunc + +" must be nearly the last, we can't go back from GUI to terminal +func Test_zz1_terminal_in_gui() + if !CanRunGui() + return + endif + + " Ignore the "failed to create input context" error. + call test_ignore_error('E285:') + + gui -f + + call assert_equal(1, winnr('$')) + let buf = Run_shell_in_terminal({'term_finish': 'close'}) + call Stop_shell_in_terminal(buf) + call term_wait(buf) + + " closing window wipes out the terminal buffer a with finished job + call WaitForAssert({-> assert_equal(1, winnr('$'))}) + call assert_equal("", bufname(buf)) + + unlet g:job +endfunc + +func Test_zz2_terminal_guioptions_bang() + if !has('gui_running') + return + endif + set guioptions+=! + + let filename = 'Xtestscript' + if has('win32') + let filename .= '.bat' + let prefix = '' + let contents = ['@echo off', 'exit %1'] + else + let filename .= '.sh' + let prefix = './' + let contents = ['#!/bin/sh', 'exit $1'] + endif + call writefile(contents, filename) + call setfperm(filename, 'rwxrwx---') + + " Check if v:shell_error is equal to the exit status. + let exitval = 0 + execute printf(':!%s%s %d', prefix, filename, exitval) + call assert_equal(exitval, v:shell_error) + + let exitval = 9 + execute printf(':!%s%s %d', prefix, filename, exitval) + call assert_equal(exitval, v:shell_error) + + set guioptions& + call delete(filename) +endfunc