blob: 687610195b758a30392eda9b690a271f4cbb93c5 [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)
9 if !has(a:name)
Bram Moolenaar7f829ca2020-01-31 22:12:41 +010010 MissingFeature a:name
Bram Moolenaarb46fecd2019-06-15 17:58:09 +020011 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
Bram Moolenaar4641a122019-07-29 22:10:23 +020029
Bram Moolenaar8c5a2782019-08-07 23:07:07 +020030" 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
Bram Moolenaar4641a122019-07-29 22:10:23 +020046" 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
Bram Moolenaar8c5a2782019-08-07 23:07:07 +020054" 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
Bram Moolenaar4641a122019-07-29 22:10:23 +020062" 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
Bram Moolenaar3c8ee622019-08-03 22:55:50 +020069
Bram Moolenaar9134f1e2019-11-29 20:26:13 +010070" 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
Bram Moolenaar3c8ee622019-08-03 22:55:50 +020079" 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
Bram Moolenaar8c5a2782019-08-07 23:07:07 +020095
96" Command to check that we can run the GUI
97command CheckCanRunGui call CheckCanRunGui()
98func CheckCanRunGui()
99 if !has('gui') || ($DISPLAY == "" && !has('gui_running'))
Bram Moolenaar25143152019-08-09 14:13:57 +0200100 throw 'Skipped: cannot start the GUI'
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200101 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
Bram Moolenaar07282f02019-10-10 16:46:17 +0200119
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