diff src/testdir/check.vim @ 17657:0da9bc55c31a v8.1.1826

patch 8.1.1826: tests use hand coded feature and option checks commit https://github.com/vim/vim/commit/8c5a278fc508da6dfe50e69b6ee734451aa4eafb Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 7 23:07:07 2019 +0200 patch 8.1.1826: tests use hand coded feature and option checks Problem: Tests use hand coded feature and option checks. Solution: Use the commands from check.vim in more tests.
author Bram Moolenaar <Bram@vim.org>
date Wed, 07 Aug 2019 23:15:07 +0200
parents d7708560b77c
children 923154c51bef
line wrap: on
line diff
--- a/src/testdir/check.vim
+++ b/src/testdir/check.vim
@@ -22,6 +22,22 @@ func CheckFunction(name)
   endif
 endfunc
 
+" Command to check for the presence of an Ex command
+command -nargs=1 CheckCommand call CheckCommand(<f-args>)
+func CheckCommand(name)
+  if !exists(':' .. a:name)
+    throw 'Skipped: ' .. a:name .. ' command not supported'
+  endif
+endfunc
+
+" Command to check for the presence of a shell command
+command -nargs=1 CheckExecutable call CheckExecutable(<f-args>)
+func CheckExecutable(name)
+  if !executable(a:name)
+    throw 'Skipped: ' .. a:name .. ' program not executable'
+  endif
+endfunc
+
 " Command to check for running on MS-Windows
 command CheckMSWindows call CheckMSWindows()
 func CheckMSWindows()
@@ -30,6 +46,14 @@ func CheckMSWindows()
   endif
 endfunc
 
+" Command to check for NOT running on MS-Windows
+command CheckNotMSWindows call CheckNotMSWindows()
+func CheckNotMSWindows()
+  if has('win32')
+    throw 'Skipped: does not work on MS-Windows'
+  endif
+endfunc
+
 " Command to check for running on Unix
 command CheckUnix call CheckUnix()
 func CheckUnix()
@@ -54,3 +78,27 @@ func CheckRunVimInTerminal()
     throw 'Skipped: cannot run Vim in a terminal window'
   endif
 endfunc
+
+" Command to check that we can run the GUI
+command CheckCanRunGui call CheckCanRunGui()
+func CheckCanRunGui()
+  if !has('gui') || ($DISPLAY == "" && !has('gui_running'))
+    throw 'Skipped: cannot run start the GUI'
+  endif
+endfunc
+
+" Command to check that we are using the GUI
+command CheckGui call CheckGui()
+func CheckGui()
+  if !has('gui_running')
+    throw 'Skipped: only works in the GUI'
+  endif
+endfunc
+
+" Command to check that not currently using the GUI
+command CheckNotGui call CheckNotGui()
+func CheckNotGui()
+  if has('gui_running')
+    throw 'Skipped: only works in the terminal'
+  endif
+endfunc