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