Mercurial > vim
comparison src/testdir/runtest.vim @ 19734:2bd03926397a v8.2.0423
patch 8.2.0423: in some environments a few tests are expected to fail
Commit: https://github.com/vim/vim/commit/ce436de5a9b94886baf023b3d22193cc68d0e9d1
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 21 15:17:20 2020 +0100
patch 8.2.0423: in some environments a few tests are expected to fail
Problem: In some environments a few tests are expected to fail.
Solution: Add $TEST_MAY_FAIL to list tests that should not cause make to
fail.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 21 Mar 2020 15:30:05 +0100 |
parents | e73167dd8cac |
children | 1c7f92a1100e |
comparison
equal
deleted
inserted
replaced
19733:5a056e3b60d9 | 19734:2bd03926397a |
---|---|
4 " | 4 " |
5 " To execute only specific test functions, add a second argument. It will be | 5 " To execute only specific test functions, add a second argument. It will be |
6 " matched against the names of the Test_ function. E.g.: | 6 " matched against the names of the Test_ function. E.g.: |
7 " ../vim -u NONE -S runtest.vim test_channel.vim open_delay | 7 " ../vim -u NONE -S runtest.vim test_channel.vim open_delay |
8 " The output can be found in the "messages" file. | 8 " The output can be found in the "messages" file. |
9 " | |
10 " If the environment variable $TEST_FILTER is set then only test functions | |
11 " matching this pattern are executed. E.g. for sh/bash: | |
12 " export TEST_FILTER=Test_channel | |
13 " For csh: | |
14 " setenv TEST_FILTER Test_channel | |
15 " | |
16 " To ignore failure for tests that are known to fail in a certain environment, | |
17 " set $TEST_MAY_FAIL to a comma separated list of function names. E.g. for | |
18 " sh/bash: | |
19 " export TEST_MAY_FAIL=Test_channel_one,Test_channel_other | |
20 " The failure report will then not be included in the test.log file and | |
21 " "make test" will not fail. | |
9 " | 22 " |
10 " The test script may contain anything, only functions that start with | 23 " The test script may contain anything, only functions that start with |
11 " "Test_" are special. These will be invoked and should contain assert | 24 " "Test_" are special. These will be invoked and should contain assert |
12 " functions. See test_assert.vim for an example. | 25 " functions. See test_assert.vim for an example. |
13 " | 26 " |
207 endif | 220 endif |
208 call add(s:messages, message) | 221 call add(s:messages, message) |
209 let s:done += 1 | 222 let s:done += 1 |
210 endfunc | 223 endfunc |
211 | 224 |
212 func AfterTheTest() | 225 func AfterTheTest(func_name) |
213 if len(v:errors) > 0 | 226 if len(v:errors) > 0 |
214 let s:fail += 1 | 227 if match(s:may_fail_list, '^' .. a:func_name) >= 0 |
215 call add(s:errors, 'Found errors in ' . s:test . ':') | 228 let s:fail_expected += 1 |
216 call extend(s:errors, v:errors) | 229 call add(s:errors_expected, 'Found errors in ' . s:test . ':') |
230 call extend(s:errors_expected, v:errors) | |
231 else | |
232 let s:fail += 1 | |
233 call add(s:errors, 'Found errors in ' . s:test . ':') | |
234 call extend(s:errors, v:errors) | |
235 endif | |
217 let v:errors = [] | 236 let v:errors = [] |
218 endif | 237 endif |
219 endfunc | 238 endfunc |
220 | 239 |
221 func EarlyExit(test) | 240 func EarlyExit(test) |
227 call FinishTesting() | 246 call FinishTesting() |
228 endfunc | 247 endfunc |
229 | 248 |
230 " This function can be called by a test if it wants to abort testing. | 249 " This function can be called by a test if it wants to abort testing. |
231 func FinishTesting() | 250 func FinishTesting() |
232 call AfterTheTest() | 251 call AfterTheTest('') |
233 | 252 |
234 " Don't write viminfo on exit. | 253 " Don't write viminfo on exit. |
235 set viminfo= | 254 set viminfo= |
236 | 255 |
237 " Clean up files created by setup.vim | 256 " Clean up files created by setup.vim |
238 call delete('XfakeHOME', 'rf') | 257 call delete('XfakeHOME', 'rf') |
239 | 258 |
240 if s:fail == 0 | 259 if s:fail == 0 && s:fail_expected == 0 |
241 " Success, create the .res file so that make knows it's done. | 260 " Success, create the .res file so that make knows it's done. |
242 exe 'split ' . fnamemodify(g:testname, ':r') . '.res' | 261 exe 'split ' . fnamemodify(g:testname, ':r') . '.res' |
243 write | 262 write |
244 endif | 263 endif |
245 | 264 |
273 let message = s:fail . ' FAILED:' | 292 let message = s:fail . ' FAILED:' |
274 echo message | 293 echo message |
275 call add(s:messages, message) | 294 call add(s:messages, message) |
276 call extend(s:messages, s:errors) | 295 call extend(s:messages, s:errors) |
277 endif | 296 endif |
297 if s:fail_expected > 0 | |
298 let message = s:fail_expected . ' FAILED (matching $TEST_MAY_FAIL):' | |
299 echo message | |
300 call add(s:messages, message) | |
301 call extend(s:messages, s:errors_expected) | |
302 endif | |
278 | 303 |
279 " Add SKIPPED messages | 304 " Add SKIPPED messages |
280 call extend(s:messages, s:skipped) | 305 call extend(s:messages, s:skipped) |
281 | 306 |
282 " Append messages to the file "messages" | 307 " Append messages to the file "messages" |
292 " Source the test script. First grab the file name, in case the script | 317 " Source the test script. First grab the file name, in case the script |
293 " navigates away. g:testname can be used by the tests. | 318 " navigates away. g:testname can be used by the tests. |
294 let g:testname = expand('%') | 319 let g:testname = expand('%') |
295 let s:done = 0 | 320 let s:done = 0 |
296 let s:fail = 0 | 321 let s:fail = 0 |
322 let s:fail_expected = 0 | |
297 let s:errors = [] | 323 let s:errors = [] |
324 let s:errors_expected = [] | |
298 let s:messages = [] | 325 let s:messages = [] |
299 let s:skipped = [] | 326 let s:skipped = [] |
300 if expand('%') =~ 'test_vimscript.vim' | 327 if expand('%') =~ 'test_vimscript.vim' |
301 " this test has intentional s:errors, don't use try/catch. | 328 " this test has intentional errors, don't use try/catch. |
302 source % | 329 source % |
303 else | 330 else |
304 try | 331 try |
305 source % | 332 source % |
306 catch /^\cskipped/ | 333 catch /^\cskipped/ |
365 let s:filtered = len(s:tests) | 392 let s:filtered = len(s:tests) |
366 let s:tests = filter(s:tests, 'v:val =~ $TEST_FILTER') | 393 let s:tests = filter(s:tests, 'v:val =~ $TEST_FILTER') |
367 let s:filtered -= len(s:tests) | 394 let s:filtered -= len(s:tests) |
368 endif | 395 endif |
369 | 396 |
397 let s:may_fail_list = [] | |
398 if $TEST_MAY_FAIL != '' | |
399 " Split the list at commas and add () to make it match s:test. | |
400 let s:may_fail_list = split($TEST_MAY_FAIL, ',')->map({i, v -> v .. '()'}) | |
401 endif | |
402 | |
370 " Execute the tests in alphabetical order. | 403 " Execute the tests in alphabetical order. |
371 for s:test in sort(s:tests) | 404 for s:test in sort(s:tests) |
372 " Silence, please! | 405 " Silence, please! |
373 set belloff=all | 406 set belloff=all |
374 let prev_error = '' | 407 let prev_error = '' |
417 break | 450 break |
418 endif | 451 endif |
419 endwhile | 452 endwhile |
420 endif | 453 endif |
421 | 454 |
422 call AfterTheTest() | 455 call AfterTheTest(s:test) |
423 endfor | 456 endfor |
424 | 457 |
425 call FinishTesting() | 458 call FinishTesting() |
426 | 459 |
427 " vim: shiftwidth=2 sts=2 expandtab | 460 " vim: shiftwidth=2 sts=2 expandtab |