diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-07-30 01:15:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-30 01:15:11 +0200 |
commit | b3ca7112c6fd964fbd114aa38d7fa39420c424d4 (patch) | |
tree | 187ecce8722e2a5f4023359ffa6c3d36e5576c40 | |
parent | a4d1505435712055ab4269bc3db7ac3ba3e1ba28 (diff) | |
parent | a118134af1ef08884dfceb9e9cd9bf2ba662b7d8 (diff) | |
download | rneovim-b3ca7112c6fd964fbd114aa38d7fa39420c424d4.tar.gz rneovim-b3ca7112c6fd964fbd114aa38d7fa39420c424d4.tar.bz2 rneovim-b3ca7112c6fd964fbd114aa38d7fa39420c424d4.zip |
Merge #7093 from justinmk/fix-qb
-rw-r--r-- | busted/outputHandlers/TAP.lua | 92 | ||||
-rw-r--r-- | src/nvim/testdir/test_normal.vim | 26 |
2 files changed, 108 insertions, 10 deletions
diff --git a/busted/outputHandlers/TAP.lua b/busted/outputHandlers/TAP.lua new file mode 100644 index 0000000000..ff93a7cc75 --- /dev/null +++ b/busted/outputHandlers/TAP.lua @@ -0,0 +1,92 @@ +-- TODO(jkeyes): remove this and use the upstream version as soon as it is +-- available in a release of busted. + +local pretty = require 'pl.pretty' + +return function(options) + local busted = require 'busted' + local handler = require 'busted.outputHandlers.base'() + + local success = 'ok %u - %s' + local failure = 'not ' .. success + local skip = 'ok %u - # SKIP %s' + local counter = 0 + + handler.suiteReset = function() + counter = 0 + return nil, true + end + + handler.suiteEnd = function() + print('1..' .. counter) + io.flush() + return nil, true + end + + local function showFailure(t) + local message = t.message + local trace = t.trace or {} + + if message == nil then + message = 'Nil error' + elseif type(message) ~= 'string' then + message = pretty.write(message) + end + + print(failure:format(counter, t.name)) + print('# ' .. t.element.trace.short_src .. ' @ ' .. t.element.trace.currentline) + if t.randomseed then print('# Random seed: ' .. t.randomseed) end + print('# Failure message: ' .. message:gsub('\n', '\n# ')) + if options.verbose and trace.traceback then + print('# ' .. trace.traceback:gsub('^\n', '', 1):gsub('\n', '\n# ')) + end + end + + handler.testStart = function(element, parent) + local trace = element.trace + if options.verbose and trace and trace.short_src then + local fileline = trace.short_src .. ' @ ' .. trace.currentline .. ': ' + local testName = fileline .. handler.getFullName(element) + print('# ' .. testName) + end + io.flush() + + return nil, true + end + + handler.testEnd = function(element, parent, status, trace) + counter = counter + 1 + if status == 'success' then + local t = handler.successes[#handler.successes] + print(success:format(counter, t.name)) + elseif status == 'pending' then + local t = handler.pendings[#handler.pendings] + print(skip:format(counter, (t.message or t.name))) + elseif status == 'failure' then + showFailure(handler.failures[#handler.failures]) + elseif status == 'error' then + showFailure(handler.errors[#handler.errors]) + end + io.flush() + + return nil, true + end + + handler.error = function(element, parent, message, debug) + if element.descriptor ~= 'it' then + counter = counter + 1 + showFailure(handler.errors[#handler.errors]) + end + io.flush() + + return nil, true + end + + busted.subscribe({ 'suite', 'reset' }, handler.suiteReset) + busted.subscribe({ 'suite', 'end' }, handler.suiteEnd) + busted.subscribe({ 'test', 'start' }, handler.testStart, { predicate = handler.cancelOnPending }) + busted.subscribe({ 'test', 'end' }, handler.testEnd, { predicate = handler.cancelOnPending }) + busted.subscribe({ 'error' }, handler.error) + + return handler +end diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index 6261625801..4747d5704d 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -1255,21 +1255,27 @@ func! Test_normal22_zet() " Test for ZZ " let shell = &shell " let &shell = 'sh' - call writefile(['1', '2'], 'Xfile') + + " Remove any stale test files from previous run. + for file in ['Xfile_Test_normal22_zet'] + call delete(file) + endfor + + call writefile(['1', '2'], 'Xfile_Test_normal22_zet') let args = ' --headless -u NONE -N -U NONE -i NONE --noplugins' - call system(v:progpath . args . ' -c "%d" -c ":norm! ZZ" Xfile') - let a = readfile('Xfile') + call system(v:progpath . args . ' -c "%d" -c ":norm! ZZ" Xfile_Test_normal22_zet') + let a = readfile('Xfile_Test_normal22_zet') call assert_equal([], a) " Test for ZQ - call writefile(['1', '2'], 'Xfile') - call system(v:progpath . args . ' -c "%d" -c ":norm! ZQ" Xfile') - let a = readfile('Xfile') + call writefile(['1', '2'], 'Xfile_Test_normal22_zet') + call system(v:progpath . args . ' -c "%d" -c ":norm! ZQ" Xfile_Test_normal22_zet') + let a = readfile('Xfile_Test_normal22_zet') call assert_equal(['1', '2'], a) - " clean up - for file in ['Xfile'] - call delete(file) - endfor + " Nvim: This sometimes hangs the TSAN build. + " for file in ['Xfile_Test_normal22_zet'] + " call delete(file) + " endfor " let &shell = shell endfunc |