diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-08-28 22:13:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-28 22:13:34 +0200 |
commit | acdede50cebf7d247e55356be828ebaba43c0d3d (patch) | |
tree | 271f6fcad0ef4ae10f995517a15b2712bbf293e9 /test/helpers.lua | |
parent | 5a1c93584fcce86b1e45b7f96ffd93bdc9f80570 (diff) | |
download | rneovim-acdede50cebf7d247e55356be828ebaba43c0d3d.tar.gz rneovim-acdede50cebf7d247e55356be828ebaba43c0d3d.tar.bz2 rneovim-acdede50cebf7d247e55356be828ebaba43c0d3d.zip |
test: Dump $NVIM_LOG_FILE contents (#8926)
Do this at the test-framework level instead of CI (Travis) scripts.
Then it works for QuickBuild and AppVeyor.
ref eb6dd3e42dc38460e8624dc5faef894e21c6aa26
Diffstat (limited to 'test/helpers.lua')
-rw-r--r-- | test/helpers.lua | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/test/helpers.lua b/test/helpers.lua index 22b5c68735..013fe60596 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -136,7 +136,6 @@ local function check_logs() fd:close() os.remove(file) if #lines > 0 then - -- local out = os.getenv('TRAVIS_CI_BUILD') and io.stdout or io.stderr local out = io.stdout out:write(start_msg .. '\n') out:write('= ' .. table.concat(lines, '\n= ') .. '\n') @@ -674,6 +673,37 @@ local function write_file(name, text, no_dedent, append) file:close() end +local function isCI() + local is_travis = nil ~= os.getenv('TRAVIS') + local is_appveyor = nil ~= os.getenv('APPVEYOR') + local is_quickbuild = nil ~= os.getenv('PR_NUMBER') + return is_travis or is_appveyor or is_quickbuild +end + +-- Gets the contents of $NVIM_LOG_FILE for printing to the build log. +-- Also removes the file, if the current environment looks like CI. +local function read_nvim_log() + local logfile = os.getenv('NVIM_LOG_FILE') or '.nvimlog' + local logtext = read_file(logfile) + local lines = {} + for l in string.gmatch(logtext or '', "[^\n]+") do -- Split at newlines. + table.insert(lines, l) + end + local log = (('-'):rep(78)..'\n' + ..string.format('$NVIM_LOG_FILE: %s\n', logfile) + ..(logtext and (isCI() and '' or '(last 10 lines)\n') or '(empty)\n')) + local keep = (isCI() and #lines or math.min(10, #lines)) + local startidx = math.max(1, #lines - keep + 1) + for i = startidx, (startidx + keep - 1) do + log = log..lines[i]..'\n' + end + log = log..('-'):rep(78)..'\n' + if isCI() then + os.remove(logfile) + end + return log +end + local module = { REMOVE_THIS = REMOVE_THIS, argss_to_cmd = argss_to_cmd, @@ -703,9 +733,10 @@ local module = { popen_r = popen_r, popen_w = popen_w, read_file = read_file, + read_nvim_log = read_nvim_log, repeated_read_cmd = repeated_read_cmd, - sleep = sleep, shallowcopy = shallowcopy, + sleep = sleep, table_flatten = table_flatten, tmpname = tmpname, uname = uname, |