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