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