Mercurial > vim
changeset 8029:770dd91ad9f7 v7.4.1309
commit https://github.com/vim/vim/commit/00af60bbb6cc7e8ccafddb30a1964f891b800bce
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 13 14:06:14 2016 +0100
patch 7.4.1309
Problem: When a test fails not all relevant info is listed.
Solution: Add the errors to the messages.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 13 Feb 2016 14:15:04 +0100 |
parents | 085a06fde9ad |
children | 05f57db9d8da |
files | src/testdir/runtest.vim src/version.c |
diffstat | 2 files changed, 37 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/runtest.vim +++ b/src/testdir/runtest.vim @@ -19,6 +19,10 @@ " " If cleanup after each Test_ function is needed, define a TearDown function. " It will be called after each Test_ function. +" +" When debugging a test it can be useful to add messages to v:errors: +" call add(v:errors, "this happened") + " Without the +eval feature we can't run these tests, bail out. so small.vim @@ -65,21 +69,21 @@ endfunc " Source the test script. First grab the file name, in case the script -" navigates away. -let testname = expand('%') -let done = 0 -let fail = 0 -let errors = [] -let messages = [] +" navigates away. g:testname can be used by the tests. +let g:testname = expand('%') +let s:done = 0 +let s:fail = 0 +let s:errors = [] +let s:messages = [] if expand('%') =~ 'test_viml.vim' - " this test has intentional errors, don't use try/catch. + " this test has intentional s:errors, don't use try/catch. source % else try source % catch - let fail += 1 - call add(errors, 'Caught exception: ' . v:exception . ' @ ' . v:throwpoint) + let s:fail += 1 + call add(s:errors, 'Caught exception: ' . v:exception . ' @ ' . v:throwpoint) endtry endif @@ -88,27 +92,26 @@ set nomore redir @q function /^Test_ redir END -let tests = split(substitute(@q, 'function \(\k*()\)', '\1', 'g')) +let s:tests = split(substitute(@q, 'function \(\k*()\)', '\1', 'g')) " Execute the tests in alphabetical order. - for test in sort(tests) + for s:test in sort(s:tests) if exists("*SetUp") call SetUp() endif - call add(messages, 'Executing ' . test) - let done += 1 + call add(s:messages, 'Executing ' . s:test) + let s:done += 1 try - exe 'call ' . test + exe 'call ' . s:test catch - let fail += 1 - call add(v:errors, 'Caught exception in ' . test . ': ' . v:exception . ' @ ' . v:throwpoint) + call add(v:errors, 'Caught exception in ' . s:test . ': ' . v:exception . ' @ ' . v:throwpoint) endtry if len(v:errors) > 0 - let fail += 1 - call add(errors, 'Found errors in ' . test . ':') - call extend(errors, v:errors) + let s:fail += 1 + call add(s:errors, 'Found errors in ' . s:test . ':') + call extend(s:errors, v:errors) let v:errors = [] endif @@ -117,35 +120,36 @@ let tests = split(substitute(@q, 'functi endif endfor -if fail == 0 +if s:fail == 0 " Success, create the .res file so that make knows it's done. - exe 'split ' . fnamemodify(testname, ':r') . '.res' + exe 'split ' . fnamemodify(g:testname, ':r') . '.res' write endif -if len(errors) > 0 +if len(s:errors) > 0 " Append errors to test.log split test.log call append(line('$'), '') - call append(line('$'), 'From ' . testname . ':') - call append(line('$'), errors) + call append(line('$'), 'From ' . g:testname . ':') + call append(line('$'), s:errors) write endif -let message = 'Executed ' . done . (done > 1 ? ' tests': ' test') +let message = 'Executed ' . s:done . (s:done > 1 ? ' tests' : ' test') echo message -call add(messages, message) -if fail > 0 - let message = fail . ' FAILED' +call add(s:messages, message) +if s:fail > 0 + let message = s:fail . ' FAILED:' echo message - call add(messages, message) + call add(s:messages, message) + call extend(s:messages, s:errors) endif " Append messages to "messages" split messages call append(line('$'), '') -call append(line('$'), 'From ' . testname . ':') -call append(line('$'), messages) +call append(line('$'), 'From ' . g:testname . ':') +call append(line('$'), s:messages) write qall!