comparison src/testdir/runtest.vim @ 8370:cd7ea16d1300 v7.4.1477

commit https://github.com/vim/vim/commit/b5760a1ce5b700fc32b8bd11948ee189a847c59e Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 3 13:10:44 2016 +0100 patch 7.4.1477 Problem: Test_reltime is flaky, it depends on timing. Solution: When it fails run it a second time.
author Christian Brabandt <cb@256bit.org>
date Thu, 03 Mar 2016 13:15:04 +0100
parents 71aabce3142e
children fb764adba294
comparison
equal deleted inserted replaced
8369:9e0b636dd96d 8370:cd7ea16d1300
70 endif 70 endif
71 close 71 close
72 return lnum - top - 1 72 return lnum - top - 1
73 endfunc 73 endfunc
74 74
75 function RunTheTest(test)
76 echo 'Executing ' . a:test
77 if exists("*SetUp")
78 call SetUp()
79 endif
80
81 call add(s:messages, 'Executing ' . a:test)
82 let s:done += 1
83 try
84 exe 'call ' . a:test
85 catch
86 call add(v:errors, 'Caught exception in ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint)
87 endtry
88
89 if exists("*TearDown")
90 call TearDown()
91 endif
92 endfunc
75 93
76 " Source the test script. First grab the file name, in case the script 94 " Source the test script. First grab the file name, in case the script
77 " navigates away. g:testname can be used by the tests. 95 " navigates away. g:testname can be used by the tests.
78 let g:testname = expand('%') 96 let g:testname = expand('%')
79 let s:done = 0 97 let s:done = 0
90 let s:fail += 1 108 let s:fail += 1
91 call add(s:errors, 'Caught exception: ' . v:exception . ' @ ' . v:throwpoint) 109 call add(s:errors, 'Caught exception: ' . v:exception . ' @ ' . v:throwpoint)
92 endtry 110 endtry
93 endif 111 endif
94 112
113 " Names of flaky tests.
114 let s:flaky = ['Test_reltime()']
115
95 " Locate Test_ functions and execute them. 116 " Locate Test_ functions and execute them.
96 set nomore 117 set nomore
97 redir @q 118 redir @q
98 silent function /^Test_ 119 silent function /^Test_
99 redir END 120 redir END
104 let s:tests = filter(s:tests, 'v:val =~ argv(1)') 125 let s:tests = filter(s:tests, 'v:val =~ argv(1)')
105 endif 126 endif
106 127
107 " Execute the tests in alphabetical order. 128 " Execute the tests in alphabetical order.
108 for s:test in sort(s:tests) 129 for s:test in sort(s:tests)
109 echo 'Executing ' . s:test 130 call RunTheTest(s:test)
110 if exists("*SetUp") 131
111 call SetUp() 132 if len(v:errors) > 0 && index(s:flaky, s:test) >= 0
133 call add(s:messages, 'Flaky test failed, running it again')
134 let v:errors = []
135 call RunTheTest(s:test)
112 endif 136 endif
113
114 call add(s:messages, 'Executing ' . s:test)
115 let s:done += 1
116 try
117 exe 'call ' . s:test
118 catch
119 call add(v:errors, 'Caught exception in ' . s:test . ': ' . v:exception . ' @ ' . v:throwpoint)
120 endtry
121 137
122 if len(v:errors) > 0 138 if len(v:errors) > 0
123 let s:fail += 1 139 let s:fail += 1
124 call add(s:errors, 'Found errors in ' . s:test . ':') 140 call add(s:errors, 'Found errors in ' . s:test . ':')
125 call extend(s:errors, v:errors) 141 call extend(s:errors, v:errors)
126 let v:errors = [] 142 let v:errors = []
127 endif 143 endif
128 144
129 if exists("*TearDown")
130 call TearDown()
131 endif
132 endfor 145 endfor
133 146
134 if s:fail == 0 147 if s:fail == 0
135 " Success, create the .res file so that make knows it's done. 148 " Success, create the .res file so that make knows it's done.
136 exe 'split ' . fnamemodify(g:testname, ':r') . '.res' 149 exe 'split ' . fnamemodify(g:testname, ':r') . '.res'