xref: /vim-8.2.3635/src/testdir/check.vim (revision 5f1920ad)
1source shared.vim
2
3" 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
26
27" 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
43" 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
51" 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
59" 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
66
67" 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
76" 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
92
93" Command to check that we can run the GUI
94command CheckCanRunGui call CheckCanRunGui()
95func CheckCanRunGui()
96  if !has('gui') || ($DISPLAY == "" && !has('gui_running'))
97    throw 'Skipped: cannot start the GUI'
98  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
116
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
124