robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #38542 fix/skip s390x failures527684c8dd

master
8.0 KiB286 linesraw
1source shared.vim
2source term_util.vim
3
4command -nargs=1 MissingFeature throw 'Skipped: ' .. <args> .. ' feature missing'
5
6" Command to check for the presence of a feature.
7command -nargs=1 CheckFeature call CheckFeature(<f-args>)
8func CheckFeature(name)
9  " if !has(a:name, 1)
10  "   throw 'Checking for non-existent feature ' .. a:name
11  " endif
12  if !has(a:name)
13    MissingFeature a:name
14  endif
15endfunc
16
17" Command to check for the absence of a feature.
18command -nargs=1 CheckNotFeature call CheckNotFeature(<f-args>)
19func CheckNotFeature(name)
20  " if !has(a:name, 1)
21  "   throw 'Checking for non-existent feature ' .. a:name
22  " endif
23  if has(a:name)
24    throw 'Skipped: ' .. a:name .. ' feature present'
25  endif
26endfunc
27
28" Command to check for the presence of a working option.
29command -nargs=1 CheckOption call CheckOption(<f-args>)
30func CheckOption(name)
31  if !exists('&' .. a:name)
32    throw 'Checking for non-existent option ' .. a:name
33  endif
34  if !exists('+' .. a:name)
35    throw 'Skipped: ' .. a:name .. ' option not supported'
36  endif
37endfunc
38
39" Command to check for the presence of a function.
40command -nargs=1 CheckFunction call CheckFunction(<f-args>)
41func CheckFunction(name)
42  if !exists('*' .. a:name)
43    throw 'Skipped: ' .. a:name .. ' function missing'
44  endif
45endfunc
46
47" Command to check for the presence of an Ex command
48command -nargs=1 CheckCommand call CheckCommand(<f-args>)
49func CheckCommand(name)
50  if !exists(':' .. a:name)
51    throw 'Skipped: ' .. a:name .. ' command not supported'
52  endif
53endfunc
54
55" Command to check for the presence of a shell command
56command -nargs=1 CheckExecutable call CheckExecutable(<f-args>)
57func CheckExecutable(name)
58  if !executable(a:name)
59    throw 'Skipped: ' .. a:name .. ' program not executable'
60  endif
61endfunc
62
63" Command to check for the presence of python.  Argument should have been
64" obtained with PythonProg()
65func CheckPython(name)
66  if a:name == ''
67    throw 'Skipped: python command not available'
68  endif
69endfunc
70
71" Command to check for running on MS-Windows
72command CheckMSWindows call CheckMSWindows()
73func CheckMSWindows()
74  if !has('win32')
75    throw 'Skipped: only works on MS-Windows'
76  endif
77endfunc
78
79" Command to check for NOT running on MS-Windows
80command CheckNotMSWindows call CheckNotMSWindows()
81func CheckNotMSWindows()
82  if has('win32')
83    throw 'Skipped: does not work on MS-Windows'
84  endif
85endfunc
86
87" Command to check for running on Unix
88command CheckUnix call CheckUnix()
89func CheckUnix()
90  if !has('unix')
91    throw 'Skipped: only works on Unix'
92  endif
93endfunc
94
95" Command to check for running on Linux
96command CheckLinux call CheckLinux()
97func CheckLinux()
98  if !has('linux')
99    throw 'Skipped: only works on Linux'
100  endif
101endfunc
102
103" Command to check for not running on a BSD system.
104command CheckNotBSD call CheckNotBSD()
105func CheckNotBSD()
106  if has('bsd')
107    throw 'Skipped: does not work on BSD'
108  endif
109endfunc
110
111" Command to check for not running on OpenBSD
112command CheckNotOpenBSD call CheckNotOpenBSD()
113func CheckNotOpenBSD()
114  if has('bsd')
115    let uname = trim(system('uname'))
116    if uname == 'OpenBSD'
117      throw 'Skipped: does not work on OpenBSD'
118    endif
119  endif
120endfunc
121
122" Command to check for not running on a MacOS
123command CheckNotMac call CheckNotMac()
124func CheckNotMac()
125  if has('mac')
126    throw 'Skipped: does not work on MacOS'
127  endif
128endfunc
129
130" Command to check for not running on a MacOS M1 system.
131command CheckNotMacM1 call CheckNotMacM1()
132func CheckNotMacM1()
133  if has('mac') && system('uname -a') =~ '\<arm64\>'
134    throw 'Skipped: does not work on MacOS M1'
135  endif
136endfunc
137
138func SetupWindowSizeToForVisualDumps()
139  " The dumps used as reference in these tests were created with a terminal
140  " width of 75 columns. The vim window that uses the remainder of the GUI
141  " window width must be at least 3 columns. In theory this means we need the
142  " GUI shell to provide 78+ columns. However the GTK3 resize logic is flaky,
143  " sometimes resulting in X11 Configure events that are narrower than
144  " expected by a number of pixels equal to 2 column widths. Therefore
145  " setting 80 columns ensures that the GUI shell can still provide 78+
146  " columns. This is very likely papering over a GTK3 resize bug but one that
147  " has existed for a very long time. Establishing this workaround is meant to
148  " get the GTK3 code working under CI so that we can focus on removing this
149  " over the long term.
150  if &columns != 80
151    set columns=80
152  endif
153  " Without resetting lines, some GTK3 resize events can carry over between
154  " tests, which invalidate assumptions in the scrollbar offset calculations.
155  if &lines != 25
156    set lines=25
157  endif
158endfunc
159
160" Command to check that making screendumps is supported.
161" Caller must source screendump.vim
162command CheckScreendump call CheckScreendump()
163func CheckScreendump()
164  let g:check_screendump_called = v:true
165  if !CanRunVimInTerminal()
166    throw 'Skipped: cannot make screendumps'
167  endif
168  if has('gui_running')
169    call SetupWindowSizeToForVisualDumps()
170  endif
171endfunc
172
173" Command to check that we can Run Vim in a terminal window
174command CheckRunVimInTerminal call CheckRunVimInTerminal()
175func CheckRunVimInTerminal()
176  if !CanRunVimInTerminal()
177    throw 'Skipped: cannot run Vim in a terminal window'
178  endif
179endfunc
180
181" Command to check that we can run the GUI
182command CheckCanRunGui call CheckCanRunGui()
183func CheckCanRunGui()
184  if !has('gui') || ($DISPLAY == "" && !has('gui_running'))
185    throw 'Skipped: cannot start the GUI'
186  endif
187endfunc
188
189" Command to Check for an environment variable
190command -nargs=1 CheckEnv call CheckEnv(<f-args>)
191func CheckEnv(name)
192  if empty(eval('$' .. a:name))
193    throw 'Skipped: Environment variable ' .. a:name .. ' is not set'
194  endif
195endfunc
196
197" Command to check that we are using the GUI
198command CheckGui call CheckGui()
199func CheckGui()
200  if !has('gui_running')
201    throw 'Skipped: only works in the GUI'
202  endif
203endfunc
204
205" Command to check that not currently using the GUI
206command CheckNotGui call CheckNotGui()
207func CheckNotGui()
208  if has('gui_running')
209    throw 'Skipped: only works in the terminal'
210  endif
211endfunc
212
213" Command to check that test is not running as root
214command CheckNotRoot call CheckNotRoot()
215func CheckNotRoot()
216  if IsRoot()
217    throw 'Skipped: cannot run test as root'
218  endif
219endfunc
220
221" Command to check that the current language is English
222command CheckEnglish call CheckEnglish()
223func CheckEnglish()
224  if v:lang != "C" && v:lang !~ '^[Ee]n'
225      throw 'Skipped: only works in English language environment'
226  endif
227endfunc
228
229" Command to check for not running under ASAN
230command CheckNotAsan call CheckNotAsan()
231func CheckNotAsan()
232  if execute('verbose version') =~# '-fsanitize=[a-z,]*\<address\>'
233    throw 'Skipped: does not work with ASAN'
234  endif
235endfunc
236
237" Command to check for not running under valgrind
238command CheckNotValgrind call CheckNotValgrind()
239func CheckNotValgrind()
240  if RunningWithValgrind()
241    throw 'Skipped: does not work well with valgrind'
242  endif
243endfunc
244
245" Command to check for not running on s390x (too slow for some timing tests)
246command CheckNotS390 call CheckNotS390()
247func CheckNotS390()
248  if has('unix') && trim(system('uname -m')) == 's390x'
249    throw 'Skipped: does not work well on s390x'
250  endif
251endfunc
252
253" Command to check for X11 based GUI
254command CheckX11BasedGui call CheckX11BasedGui()
255func CheckX11BasedGui()
256  if !g:x11_based_gui
257    throw 'Skipped: requires X11 based GUI'
258  endif
259endfunc
260
261" Command to check for satisfying any of the conditions.
262" e.g. CheckAnyOf Feature:bsd Feature:sun Linux
263command -nargs=+ CheckAnyOf call CheckAnyOf(<f-args>)
264func CheckAnyOf(...)
265  let excp = []
266  for arg in a:000
267    try
268      exe 'Check' .. substitute(arg, ':', ' ', '')
269      return
270    catch /^Skipped:/
271      let excp += [substitute(v:exception, '^Skipped:\s*', '', '')]
272    endtry
273  endfor
274  throw 'Skipped: ' .. join(excp, '; ')
275endfunc
276
277" Command to check for satisfying all of the conditions.
278" e.g. CheckAllOf Unix Gui Option:ballooneval
279command -nargs=+ CheckAllOf call CheckAllOf(<f-args>)
280func CheckAllOf(...)
281  for arg in a:000
282    exe 'Check' .. substitute(arg, ':', ' ', '')
283  endfor
284endfunc
285
286" vim: shiftwidth=2 sts=2 expandtab