blob: 6c3b1be4ff1608ede13dfad8c061dfcfff72ce7f [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
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
Bram Moolenaar8c5a2782019-08-07 23:07:07 +020083
84" Command to check that we can run the GUI
85command CheckCanRunGui call CheckCanRunGui()
86func CheckCanRunGui()
87 if !has('gui') || ($DISPLAY == "" && !has('gui_running'))
Bram Moolenaar25143152019-08-09 14:13:57 +020088 throw 'Skipped: cannot start the GUI'
Bram Moolenaar8c5a2782019-08-07 23:07:07 +020089 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
Bram Moolenaar07282f02019-10-10 16:46:17 +0200107
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