@@ -522,29 +522,6 @@ func Test_terminal_env()
522522 exe buf . ' bwipe'
523523endfunc
524524
525- " must be last, we can't go back from GUI to terminal
526- func Test_zz_terminal_in_gui ()
527- if ! CanRunGui ()
528- return
529- endif
530-
531- " Ignore the "failed to create input context" error.
532- call test_ignore_error (' E285:' )
533-
534- gui - f
535-
536- call assert_equal (1 , winnr (' $' ))
537- let buf = Run_shell_in_terminal ({' term_finish' : ' close' })
538- call Stop_shell_in_terminal (buf )
539- call term_wait (buf )
540-
541- " closing window wipes out the terminal buffer a with finished job
542- call WaitForAssert ({- > assert_equal (1 , winnr (' $' ))})
543- call assert_equal (" " , bufname (buf ))
544-
545- unlet g: job
546- endfunc
547-
548525func Test_terminal_list_args ()
549526 let buf = term_start ([&shell , &shellcmdflag , ' echo "123"' ])
550527 call assert_fails (buf . ' bwipe' , ' E517' )
@@ -1546,3 +1523,58 @@ func Test_terminwinscroll()
15461523
15471524 exe buf . ' bwipe!'
15481525endfunc
1526+
1527+ " must be nearly the last, we can't go back from GUI to terminal
1528+ func Test_zz1_terminal_in_gui ()
1529+ if ! CanRunGui ()
1530+ return
1531+ endif
1532+
1533+ " Ignore the "failed to create input context" error.
1534+ call test_ignore_error (' E285:' )
1535+
1536+ gui - f
1537+
1538+ call assert_equal (1 , winnr (' $' ))
1539+ let buf = Run_shell_in_terminal ({' term_finish' : ' close' })
1540+ call Stop_shell_in_terminal (buf )
1541+ call term_wait (buf )
1542+
1543+ " closing window wipes out the terminal buffer a with finished job
1544+ call WaitForAssert ({- > assert_equal (1 , winnr (' $' ))})
1545+ call assert_equal (" " , bufname (buf ))
1546+
1547+ unlet g: job
1548+ endfunc
1549+
1550+ func Test_zz2_terminal_guioptions_bang ()
1551+ if ! has (' gui_running' )
1552+ return
1553+ endif
1554+ set guioptions += !
1555+
1556+ let filename = ' Xtestscript'
1557+ if has (' win32' )
1558+ let filename .= ' .bat'
1559+ let prefix = ' '
1560+ let contents = [' @echo off' , ' exit %1' ]
1561+ else
1562+ let filename .= ' .sh'
1563+ let prefix = ' ./'
1564+ let contents = [' #!/bin/sh' , ' exit $1' ]
1565+ endif
1566+ call writefile (contents, filename)
1567+ call setfperm (filename, ' rwxrwx---' )
1568+
1569+ " Check if v:shell_error is equal to the exit status.
1570+ let exitval = 0
1571+ execute printf (' :!%s%s %d' , prefix, filename, exitval)
1572+ call assert_equal (exitval, v: shell_error )
1573+
1574+ let exitval = 9
1575+ execute printf (' :!%s%s %d' , prefix, filename, exitval)
1576+ call assert_equal (exitval, v: shell_error )
1577+
1578+ set guioptions &
1579+ call delete (filename)
1580+ endfunc
0 commit comments