blob: 0bbe7caf94ea1dfc7d820850687e0ec8d8178dca [file] [log] [blame]
Bram Moolenaar07282f02019-10-10 16:46:17 +02001source shared.vim
Bram Moolenaar3180fe62020-02-02 13:47:06 +01002source term_util.vim
Bram Moolenaar07282f02019-10-10 16:46:17 +02003
Bram Moolenaar7f829ca2020-01-31 22:12:41 +01004command -nargs=1 MissingFeature throw 'Skipped: ' .. <args> .. ' feature missing'
5
Bram Moolenaarb46fecd2019-06-15 17:58:09 +02006" Command to check for the presence of a feature.
7command -nargs=1 CheckFeature call CheckFeature(<f-args>)
8func CheckFeature(name)
Bram Moolenaar79296512020-03-22 16:17:14 +01009 if !has(a:name, 1)
10 throw 'Checking for non-existent feature ' .. a:name
11 endif
Bram Moolenaarb46fecd2019-06-15 17:58:09 +020012 if !has(a:name)
Bram Moolenaar7f829ca2020-01-31 22:12:41 +010013 MissingFeature a:name
Bram Moolenaarb46fecd2019-06-15 17:58:09 +020014 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 'Skipped: ' .. a:name .. ' option not supported'
22 endif
23endfunc
24
25" Command to check for the presence of a function.
26command -nargs=1 CheckFunction call CheckFunction(<f-args>)
27func CheckFunction(name)
28 if !exists('*' .. a:name)
29 throw 'Skipped: ' .. a:name .. ' function missing'
30 endif
31endfunc
Bram Moolenaar4641a122019-07-29 22:10:23 +020032
Bram Moolenaar8c5a2782019-08-07 23:07:07 +020033" Command to check for the presence of an Ex command
34command -nargs=1 CheckCommand call CheckCommand(<f-args>)
35func CheckCommand(name)
36 if !exists(':' .. a:name)
37 throw 'Skipped: ' .. a:name .. ' command not supported'
38 endif
39endfunc
40
41" Command to check for the presence of a shell command
42command -nargs=1 CheckExecutable call CheckExecutable(<f-args>)
43func CheckExecutable(name)
44 if !executable(a:name)
45 throw 'Skipped: ' .. a:name .. ' program not executable'
46 endif
47endfunc
48
Bram Moolenaar4641a122019-07-29 22:10:23 +020049" Command to check for running on MS-Windows
50command CheckMSWindows call CheckMSWindows()
51func CheckMSWindows()
52 if !has('win32')
53 throw 'Skipped: only works on MS-Windows'
54 endif
55endfunc
56
Bram Moolenaar8c5a2782019-08-07 23:07:07 +020057" Command to check for NOT running on MS-Windows
58command CheckNotMSWindows call CheckNotMSWindows()
59func CheckNotMSWindows()
60 if has('win32')
61 throw 'Skipped: does not work on MS-Windows'
62 endif
63endfunc
64
Bram Moolenaar4641a122019-07-29 22:10:23 +020065" Command to check for running on Unix
66command CheckUnix call CheckUnix()
67func CheckUnix()
68 if !has('unix')
69 throw 'Skipped: only works on Unix'
70 endif
71endfunc
Bram Moolenaar3c8ee622019-08-03 22:55:50 +020072
Bram Moolenaar9134f1e2019-11-29 20:26:13 +010073" Command to check for not running on a BSD system.
74" TODO: using this checks should not be needed
75command CheckNotBSD call CheckNotBSD()
76func CheckNotBSD()
77 if has('bsd')
78 throw 'Skipped: does not work on BSD'
79 endif
80endfunc
81
Bram Moolenaar3c8ee622019-08-03 22:55:50 +020082" Command to check that making screendumps is supported.
83" Caller must source screendump.vim
84command CheckScreendump call CheckScreendump()
85func CheckScreendump()
86 if !CanRunVimInTerminal()
87 throw 'Skipped: cannot make screendumps'
88 endif
89endfunc
90
91" Command to check that we can Run Vim in a terminal window
92command CheckRunVimInTerminal call CheckRunVimInTerminal()
93func CheckRunVimInTerminal()
94 if !CanRunVimInTerminal()
95 throw 'Skipped: cannot run Vim in a terminal window'
96 endif
97endfunc
Bram Moolenaar8c5a2782019-08-07 23:07:07 +020098
99" Command to check that we can run the GUI
100command CheckCanRunGui call CheckCanRunGui()
101func CheckCanRunGui()
102 if !has('gui') || ($DISPLAY == "" && !has('gui_running'))
Bram Moolenaar25143152019-08-09 14:13:57 +0200103 throw 'Skipped: cannot start the GUI'
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200104 endif
105endfunc
106
107" Command to check that we are using the GUI
108command CheckGui call CheckGui()
109func CheckGui()
110 if !has('gui_running')
111 throw 'Skipped: only works in the GUI'
112 endif
113endfunc
114
115" Command to check that not currently using the GUI
116command CheckNotGui call CheckNotGui()
117func CheckNotGui()
118 if has('gui_running')
119 throw 'Skipped: only works in the terminal'
120 endif
121endfunc
Bram Moolenaar07282f02019-10-10 16:46:17 +0200122
123" Command to check that test is not running as root
124command CheckNotRoot call CheckNotRoot()
125func CheckNotRoot()
126 if IsRoot()
127 throw 'Skipped: cannot run test as root'
128 endif
129endfunc