xref: /vim-8.2.3635/src/testdir/check.vim (revision 2e693a88)
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 that making screendumps is supported.
68" Caller must source screendump.vim
69command CheckScreendump call CheckScreendump()
70func CheckScreendump()
71  if !CanRunVimInTerminal()
72    throw 'Skipped: cannot make screendumps'
73  endif
74endfunc
75
76" Command to check that we can Run Vim in a terminal window
77command CheckRunVimInTerminal call CheckRunVimInTerminal()
78func CheckRunVimInTerminal()
79  if !CanRunVimInTerminal()
80    throw 'Skipped: cannot run Vim in a terminal window'
81  endif
82endfunc
83
84" Command to check that we can run the GUI
85command CheckCanRunGui call CheckCanRunGui()
86func CheckCanRunGui()
87  if !has('gui') || ($DISPLAY == "" && !has('gui_running'))
88    throw 'Skipped: cannot start the GUI'
89  endif
90endfunc
91
92" Command to check that we are using the GUI
93command CheckGui call CheckGui()
94func CheckGui()
95  if !has('gui_running')
96    throw 'Skipped: only works in the GUI'
97  endif
98endfunc
99
100" Command to check that not currently using the GUI
101command CheckNotGui call CheckNotGui()
102func CheckNotGui()
103  if has('gui_running')
104    throw 'Skipped: only works in the terminal'
105  endif
106endfunc
107
108" Command to check that test is not running as root
109command CheckNotRoot call CheckNotRoot()
110func CheckNotRoot()
111  if IsRoot()
112    throw 'Skipped: cannot run test as root'
113  endif
114endfunc
115