diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-03-24 12:59:59 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-03-24 12:59:59 -0300 |
commit | ed1070bb24d61cfeb13c7afa65de64540dabe535 (patch) | |
tree | 751ad22670cb9b40329a84773e783ba3b8c357f3 | |
parent | 5860d65f9cf4205b845e4fb5e8512ef8929cf227 (diff) | |
parent | 1ee7ca7bc0739526bf07ddc0cfc9fbbd18523591 (diff) | |
download | rneovim-ed1070bb24d61cfeb13c7afa65de64540dabe535.tar.gz rneovim-ed1070bb24d61cfeb13c7afa65de64540dabe535.tar.bz2 rneovim-ed1070bb24d61cfeb13c7afa65de64540dabe535.zip |
Merge PR #2146 'Improve functional test debuggability and efficiency'
-rw-r--r-- | cmake/RunTests.cmake | 12 | ||||
-rw-r--r-- | test/functional/autocmd/tabnew_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/helpers.lua | 19 | ||||
-rw-r--r-- | test/functional/job/job_spec.lua | 8 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 24 | ||||
-rw-r--r-- | third-party/cmake/BuildLuarocks.cmake | 8 | ||||
-rw-r--r-- | third-party/utfTerminalDetailed.lua | 9 |
7 files changed, 57 insertions, 25 deletions
diff --git a/cmake/RunTests.cmake b/cmake/RunTests.cmake index 6262cbc383..0858ea24ac 100644 --- a/cmake/RunTests.cmake +++ b/cmake/RunTests.cmake @@ -17,9 +17,17 @@ if(BUSTED_OUTPUT_TYPE STREQUAL junit) set(EXTRA_ARGS OUTPUT_FILE ${BUILD_DIR}/${TEST_TYPE}test-junit.xml) endif() +if(DEFINED ENV{TEST_TAG}) + set(TEST_TAG "--tags=$ENV{TEST_TAG}") +endif() + +if(DEFINED ENV{TEST_FILTER}) + set(TEST_TAG "--filter=$ENV{TEST_FILTER}") +endif() + execute_process( - COMMAND ${BUSTED_PRG} -v -o ${BUSTED_OUTPUT_TYPE} - --helper=${TEST_DIR}/${TEST_TYPE}/preload.lua + COMMAND ${BUSTED_PRG} ${TEST_TAG} ${TEST_FILTER} -v -o ${BUSTED_OUTPUT_TYPE} + --lazy --helper=${TEST_DIR}/${TEST_TYPE}/preload.lua --lpath=${BUILD_DIR}/?.lua ${TEST_PATH} WORKING_DIRECTORY ${WORKING_DIR} ERROR_VARIABLE err diff --git a/test/functional/autocmd/tabnew_spec.lua b/test/functional/autocmd/tabnew_spec.lua index 970ca19726..d80644cd92 100644 --- a/test/functional/autocmd/tabnew_spec.lua +++ b/test/functional/autocmd/tabnew_spec.lua @@ -4,8 +4,8 @@ local clear, nvim, buffer, curbuf, curwin, eq, neq, ok = helpers.eq, helpers.neq, helpers.ok describe('TabNew', function() + setup(clear) describe('au TabNew', function() - clear() describe('with * as <afile>', function() it('matches when opening any new tab', function() nvim('command', 'au! TabNew * echom "tabnew:".tabpagenr().":".bufnr("")') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 5627b1fae2..393b42dda5 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -162,15 +162,20 @@ local function rawfeed(...) end end +local function spawn(argv) + local loop = Loop.new() + local msgpack_stream = MsgpackStream.new(loop) + local async_session = AsyncSession.new(msgpack_stream) + local session = Session.new(async_session) + loop:spawn(argv) + return session +end + local function clear() if session then session:exit(0) end - local loop = Loop.new() - local msgpack_stream = MsgpackStream.new(loop) - local async_session = AsyncSession.new(msgpack_stream) - session = Session.new(async_session) - loop:spawn(nvim_argv) + session = spawn(nvim_argv) end local function insert(...) @@ -271,10 +276,9 @@ local function expect(contents) return eq(dedent(contents), curbuf_contents()) end -clear() - return { clear = clear, + spawn = spawn, dedent = dedent, source = source, rawfeed = rawfeed, @@ -292,6 +296,7 @@ return { expect = expect, ok = ok, nvim = nvim, + nvim_prog = nvim_prog, nvim_dir = nvim_dir, buffer = buffer, window = window, diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua index 0d561ec4d7..c74ae047c5 100644 --- a/test/functional/job/job_spec.lua +++ b/test/functional/job/job_spec.lua @@ -6,10 +6,14 @@ local clear, nvim, eq, neq, ok, expect, eval, next_message, run, stop, session helpers.stop, helpers.session local nvim_dir, insert = helpers.nvim_dir, helpers.insert -local channel = nvim('get_api_info')[1] describe('jobs', function() - before_each(clear) + local channel + + before_each(function() + clear() + channel = nvim('get_api_info')[1] + end) -- Creates the string to make an autocmd to notify us. local notify_str = function(expr1, expr2) diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index f79d634536..c60944bbb0 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -123,16 +123,26 @@ if os.getenv('CI_TARGET') then default_screen_timeout = default_screen_timeout * 3 end -local colors = request('vim_get_color_map') -local colornames = {} -for name, rgb in pairs(colors) do +do + local spawn, nvim_prog = helpers.spawn, helpers.nvim_prog + local session = spawn({nvim_prog, '-u', 'NONE', '-N', '--embed'}) + local status, rv = session:request('vim_get_color_map') + if not status then + print('failed to get color map') + os.exit(1) + end + local colors = rv + local colornames = {} + for name, rgb in pairs(colors) do -- we disregard the case that colornames might not be unique, as -- this is just a helper to get any canonical name of a color colornames[rgb] = name + end + session:exit(0) + Screen.colors = colors + Screen.colornames = colornames end -Screen.colors = colors - function Screen.debug(command) if not command then command = 'pynvim -n -c ' @@ -497,8 +507,8 @@ function pprint_attrs(attrs) for f, v in pairs(attrs) do local desc = tostring(v) if f == "foreground" or f == "background" then - if colornames[v] ~= nil then - desc = "Screen.colors."..colornames[v] + if Screen.colornames[v] ~= nil then + desc = "Screen.colors."..Screen.colornames[v] end end table.insert(items, f.." = "..desc) diff --git a/third-party/cmake/BuildLuarocks.cmake b/third-party/cmake/BuildLuarocks.cmake index bc7eff6279..baa3425918 100644 --- a/third-party/cmake/BuildLuarocks.cmake +++ b/third-party/cmake/BuildLuarocks.cmake @@ -36,11 +36,11 @@ add_custom_command(OUTPUT ${DEPS_LIB_DIR}/luarocks/rocks/stable-busted-deps COMMAND ${DEPS_BIN_DIR}/luarocks ARGS build dkjson 2.5-1 CC=${DEPS_C_COMPILER} LD=${DEPS_C_COMPILER} COMMAND ${DEPS_BIN_DIR}/luarocks - ARGS build say 1.2-1 CC=${DEPS_C_COMPILER} LD=${DEPS_C_COMPILER} + ARGS build say 1.3-0 CC=${DEPS_C_COMPILER} LD=${DEPS_C_COMPILER} COMMAND ${DEPS_BIN_DIR}/luarocks - ARGS build luassert 1.7.2-0 CC=${DEPS_C_COMPILER} LD=${DEPS_C_COMPILER} + ARGS build luassert 1.7.4-0 CC=${DEPS_C_COMPILER} LD=${DEPS_C_COMPILER} COMMAND ${DEPS_BIN_DIR}/luarocks - ARGS build ansicolors 1.0.2-3 CC=${DEPS_C_COMPILER} LD=${DEPS_C_COMPILER} + ARGS build lua-term 0.1-1 CC=${DEPS_C_COMPILER} LD=${DEPS_C_COMPILER} COMMAND ${DEPS_BIN_DIR}/luarocks ARGS build penlight 1.0.0-1 CC=${DEPS_C_COMPILER} LD=${DEPS_C_COMPILER} COMMAND ${DEPS_BIN_DIR}/luarocks @@ -56,7 +56,7 @@ add_custom_target(stable-busted-deps add_custom_command(OUTPUT ${DEPS_BIN_DIR}/busted COMMAND ${DEPS_BIN_DIR}/luarocks - ARGS build busted 2.0.rc4 CC=${DEPS_C_COMPILER} LD=${DEPS_C_COMPILER} + ARGS build https://raw.githubusercontent.com/Olivine-Labs/busted/master/busted-scm-0.rockspec CC=${DEPS_C_COMPILER} LD=${DEPS_C_COMPILER} COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/utfTerminalDetailed.lua ${DEPS_INSTALL_DIR}/share/lua/5.1/busted/outputHandlers DEPENDS stable-busted-deps) diff --git a/third-party/utfTerminalDetailed.lua b/third-party/utfTerminalDetailed.lua index 4d7a7c1d6f..5a52dfa958 100644 --- a/third-party/utfTerminalDetailed.lua +++ b/third-party/utfTerminalDetailed.lua @@ -1,13 +1,18 @@ -- busted output handler that immediately prints file and test names before -- tests are executed. It simplifies identifying which tests are -- hanging/crashing -local ansicolors = require 'ansicolors' +if package.config:sub(1,1) == '\\' and not os.getenv("ANSICON") then + -- Disable colors on Windows. + colors = setmetatable({}, {__index = function() return function(s) return s end end}) +else + colors = require 'term.colors' +end return function(options, busted) local handler = require 'busted.outputHandlers.utfTerminal'(options, busted) handler.fileStart = function(name) - io.write('\n' .. ansicolors('%{cyan}' .. name) .. ':') + io.write('\n' .. colors.cyan(name) .. ':') end handler.testStart = function(element, parent, status, debug) |