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