blob: 6efa348e5ad29671da4f909eb6c0faab6c3b1520 [file] [log] [blame]
Bram Moolenaar07282f02019-10-10 16:46:17 +02001source shared.vim
2
Bram Moolenaar7f829ca2020-01-31 22:12:41 +01003command -nargs=1 MissingFeature throw 'Skipped: ' .. <args> .. ' feature missing'
4
Bram Moolenaarb46fecd2019-06-15 17:58:09 +02005" Command to check for the presence of a feature.
6command -nargs=1 CheckFeature call CheckFeature(<f-args>)
7func CheckFeature(name)
8 if !has(a:name)
Bram Moolenaar7f829ca2020-01-31 22:12:41 +01009 MissingFeature a:name
Bram Moolenaarb46fecd2019-06-15 17:58:09 +020010 endif
11endfunc
12
13" Command to check for the presence of a working option.
14command -nargs=1 CheckOption call CheckOption(<f-args>)
15func CheckOption(name)
16 if !exists('+' .. a:name)
17 throw 'Skipped: ' .. a:name .. ' option not supported'
18 endif
19endfunc
20
21" Command to check for the presence of a function.
22command -nargs=1 CheckFunction call CheckFunction(<f-args>)
23func CheckFunction(name)
24 if !exists('*' .. a:name)
25 throw 'Skipped: ' .. a:name .. ' function missing'
26 endif
27endfunc
Bram Moolenaar4641a122019-07-29 22:10:23 +020028
Bram Moolenaar8c5a2782019-08-07 23:07:07 +020029" Command to check for the presence of an Ex command
30command -nargs=1 CheckCommand call CheckCommand(<f-args>)
31func CheckCommand(name)
32 if !exists(':' .. a:name)
33 throw 'Skipped: ' .. a:name .. ' command not supported'
34 endif
35endfunc
36
37" Command to check for the presence of a shell command
38command -nargs=1 CheckExecutable call CheckExecutable(<f-args>)
39func CheckExecutable(name)
40 if !executable(a:name)
41 throw 'Skipped: ' .. a:name .. ' program not executable'
42 endif
43endfunc
44
Bram Moolenaar4641a122019-07-29 22:10:23 +020045" Command to check for running on MS-Windows
46command CheckMSWindows call CheckMSWindows()
47func CheckMSWindows()
48 if !has('win32')
49 throw 'Skipped: only works on MS-Windows'
50 endif
51endfunc
52
Bram Moolenaar8c5a2782019-08-07 23:07:07 +020053" Command to check for NOT running on MS-Windows
54command CheckNotMSWindows call CheckNotMSWindows()
55func CheckNotMSWindows()
56 if has('win32')
57 throw 'Skipped: does not work on MS-Windows'
58 endif
59endfunc
60
Bram Moolenaar4641a122019-07-29 22:10:23 +020061" Command to check for running on Unix
62command CheckUnix call CheckUnix()
63func CheckUnix()
64 if !has('unix')
65 throw 'Skipped: only works on Unix'
66 endif
67endfunc
Bram Moolenaar3c8ee622019-08-03 22:55:50 +020068
Bram Moolenaar9134f1e2019-11-29 20:26:13 +010069" Command to check for not running on a BSD system.
70" TODO: using this checks should not be needed
71command CheckNotBSD call CheckNotBSD()
72func CheckNotBSD()
73 if has('bsd')
74 throw 'Skipped: does not work on BSD'
75 endif
76endfunc
77
Bram Moolenaar3c8ee622019-08-03 22:55:50 +020078" Command to check that making screendumps is supported.
79" Caller must source screendump.vim
80command CheckScreendump call CheckScreendump()
81func CheckScreendump()
82 if !CanRunVimInTerminal()
83 throw 'Skipped: cannot make screendumps'
84 endif
85endfunc
86
87" Command to check that we can Run Vim in a terminal window
88command CheckRunVimInTerminal call CheckRunVimInTerminal()
89func CheckRunVimInTerminal()
90 if !CanRunVimInTerminal()
91 throw 'Skipped: cannot run Vim in a terminal window'
92 endif
93endfunc
Bram Moolenaar8c5a2782019-08-07 23:07:07 +020094
95" Command to check that we can run the GUI
96command CheckCanRunGui call CheckCanRunGui()
97func CheckCanRunGui()
98 if !has('gui') || ($DISPLAY == "" && !has('gui_running'))
Bram Moolenaar25143152019-08-09 14:13:57 +020099 throw 'Skipped: cannot start the GUI'
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200100 endif
101endfunc
102
103" Command to check that we are using the GUI
104command CheckGui call CheckGui()
105func CheckGui()
106 if !has('gui_running')
107 throw 'Skipped: only works in the GUI'
108 endif
109endfunc
110
111" Command to check that not currently using the GUI
112command CheckNotGui call CheckNotGui()
113func CheckNotGui()
114 if has('gui_running')
115 throw 'Skipped: only works in the terminal'
116 endif
117endfunc
Bram Moolenaar07282f02019-10-10 16:46:17 +0200118
119" Command to check that test is not running as root
120command CheckNotRoot call CheckNotRoot()
121func CheckNotRoot()
122 if IsRoot()
123 throw 'Skipped: cannot run test as root'
124 endif
125endfunc