1source shared.vim 2source term_util.vim 3 4command -nargs=1 MissingFeature throw 'Skipped: ' .. <args> .. ' feature missing' 5 6" Command to check for the presence of a feature. 7command -nargs=1 CheckFeature call CheckFeature(<f-args>) 8func CheckFeature(name) 9 if !has(a:name) 10 MissingFeature a:name 11 endif 12endfunc 13 14" Command to check for the presence of a working option. 15command -nargs=1 CheckOption call CheckOption(<f-args>) 16func CheckOption(name) 17 if !exists('+' .. a:name) 18 throw 'Skipped: ' .. a:name .. ' option not supported' 19 endif 20endfunc 21 22" Command to check for the presence of a function. 23command -nargs=1 CheckFunction call CheckFunction(<f-args>) 24func CheckFunction(name) 25 if !exists('*' .. a:name) 26 throw 'Skipped: ' .. a:name .. ' function missing' 27 endif 28endfunc 29 30" Command to check for the presence of an Ex command 31command -nargs=1 CheckCommand call CheckCommand(<f-args>) 32func CheckCommand(name) 33 if !exists(':' .. a:name) 34 throw 'Skipped: ' .. a:name .. ' command not supported' 35 endif 36endfunc 37 38" Command to check for the presence of a shell command 39command -nargs=1 CheckExecutable call CheckExecutable(<f-args>) 40func CheckExecutable(name) 41 if !executable(a:name) 42 throw 'Skipped: ' .. a:name .. ' program not executable' 43 endif 44endfunc 45 46" Command to check for running on MS-Windows 47command CheckMSWindows call CheckMSWindows() 48func CheckMSWindows() 49 if !has('win32') 50 throw 'Skipped: only works on MS-Windows' 51 endif 52endfunc 53 54" Command to check for NOT running on MS-Windows 55command CheckNotMSWindows call CheckNotMSWindows() 56func CheckNotMSWindows() 57 if has('win32') 58 throw 'Skipped: does not work on MS-Windows' 59 endif 60endfunc 61 62" Command to check for running on Unix 63command CheckUnix call CheckUnix() 64func CheckUnix() 65 if !has('unix') 66 throw 'Skipped: only works on Unix' 67 endif 68endfunc 69 70" Command to check for not running on a BSD system. 71" TODO: using this checks should not be needed 72command CheckNotBSD call CheckNotBSD() 73func CheckNotBSD() 74 if has('bsd') 75 throw 'Skipped: does not work on BSD' 76 endif 77endfunc 78 79" Command to check that making screendumps is supported. 80" Caller must source screendump.vim 81command CheckScreendump call CheckScreendump() 82func CheckScreendump() 83 if !CanRunVimInTerminal() 84 throw 'Skipped: cannot make screendumps' 85 endif 86endfunc 87 88" Command to check that we can Run Vim in a terminal window 89command CheckRunVimInTerminal call CheckRunVimInTerminal() 90func CheckRunVimInTerminal() 91 if !CanRunVimInTerminal() 92 throw 'Skipped: cannot run Vim in a terminal window' 93 endif 94endfunc 95 96" Command to check that we can run the GUI 97command CheckCanRunGui call CheckCanRunGui() 98func CheckCanRunGui() 99 if !has('gui') || ($DISPLAY == "" && !has('gui_running')) 100 throw 'Skipped: cannot start the GUI' 101 endif 102endfunc 103 104" Command to check that we are using the GUI 105command CheckGui call CheckGui() 106func CheckGui() 107 if !has('gui_running') 108 throw 'Skipped: only works in the GUI' 109 endif 110endfunc 111 112" Command to check that not currently using the GUI 113command CheckNotGui call CheckNotGui() 114func CheckNotGui() 115 if has('gui_running') 116 throw 'Skipped: only works in the terminal' 117 endif 118endfunc 119 120" Command to check that test is not running as root 121command CheckNotRoot call CheckNotRoot() 122func CheckNotRoot() 123 if IsRoot() 124 throw 'Skipped: cannot run test as root' 125 endif 126endfunc 127