mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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 eb6dd3e42d
This commit is contained in:
parent
5a1c93584f
commit
acdede50ce
@ -1,7 +1,8 @@
|
|||||||
-- TODO(jkeyes): remove this and use the upstream version as soon as it is
|
-- TODO(jkeyes): Use the upstream version when busted releases it. (But how to
|
||||||
-- available in a release of busted.
|
-- inject our call to global_helpers.read_nvim_log() ?)
|
||||||
|
|
||||||
local pretty = require 'pl.pretty'
|
local pretty = require 'pl.pretty'
|
||||||
|
local global_helpers = require('test.helpers')
|
||||||
|
|
||||||
return function(options)
|
return function(options)
|
||||||
local busted = require 'busted'
|
local busted = require 'busted'
|
||||||
@ -18,6 +19,7 @@ return function(options)
|
|||||||
end
|
end
|
||||||
|
|
||||||
handler.suiteEnd = function()
|
handler.suiteEnd = function()
|
||||||
|
io.write(global_helpers.read_nvim_log())
|
||||||
print('1..' .. counter)
|
print('1..' .. counter)
|
||||||
io.flush()
|
io.flush()
|
||||||
return nil, true
|
return nil, true
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
local s = require 'say'
|
local s = require 'say'
|
||||||
local pretty = require 'pl.pretty'
|
local pretty = require 'pl.pretty'
|
||||||
local term = require 'term'
|
local term = require 'term'
|
||||||
|
local global_helpers = require('test.helpers')
|
||||||
|
|
||||||
local colors
|
local colors
|
||||||
|
|
||||||
@ -200,6 +201,7 @@ return function(options)
|
|||||||
local tests = (testCount == 1 and 'test' or 'tests')
|
local tests = (testCount == 1 and 'test' or 'tests')
|
||||||
local files = (fileCount == 1 and 'file' or 'files')
|
local files = (fileCount == 1 and 'file' or 'files')
|
||||||
io.write(globalTeardown)
|
io.write(globalTeardown)
|
||||||
|
io.write(global_helpers.read_nvim_log())
|
||||||
io.write(suiteEndString:format(testCount, tests, fileCount, files, elapsedTime_ms))
|
io.write(suiteEndString:format(testCount, tests, fileCount, files, elapsedTime_ms))
|
||||||
io.write(getSummaryString())
|
io.write(getSummaryString())
|
||||||
io.flush()
|
io.flush()
|
||||||
|
@ -7,7 +7,7 @@ _stat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
top_make() {
|
top_make() {
|
||||||
echo '================================================================================'
|
printf '%78s\n' | tr ' ' '='
|
||||||
# Travis has 1.5 virtual cores according to:
|
# Travis has 1.5 virtual cores according to:
|
||||||
# http://docs.travis-ci.com/user/speeding-up-the-build/#Paralellizing-your-build-on-one-VM
|
# http://docs.travis-ci.com/user/speeding-up-the-build/#Paralellizing-your-build-on-one-VM
|
||||||
ninja "$@"
|
ninja "$@"
|
||||||
|
@ -39,13 +39,6 @@ enter_suite() {
|
|||||||
|
|
||||||
exit_suite() {
|
exit_suite() {
|
||||||
set +x
|
set +x
|
||||||
if test -f "$NVIM_LOG_FILE" ; then
|
|
||||||
printf "===============================================================================\n"
|
|
||||||
printf "NVIM_LOG_FILE: $NVIM_LOG_FILE\n"
|
|
||||||
cat "$NVIM_LOG_FILE" 2>/dev/null || printf '(empty)'
|
|
||||||
printf "\n"
|
|
||||||
rm -rf "$NVIM_LOG_FILE"
|
|
||||||
fi
|
|
||||||
travis_fold end "${NVIM_TEST_CURRENT_SUITE}"
|
travis_fold end "${NVIM_TEST_CURRENT_SUITE}"
|
||||||
if test $FAILED -ne 0 ; then
|
if test $FAILED -ne 0 ; then
|
||||||
echo "Suite ${NVIM_TEST_CURRENT_SUITE} failed, summary:"
|
echo "Suite ${NVIM_TEST_CURRENT_SUITE} failed, summary:"
|
||||||
|
@ -136,7 +136,6 @@ local function check_logs()
|
|||||||
fd:close()
|
fd:close()
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
if #lines > 0 then
|
if #lines > 0 then
|
||||||
-- local out = os.getenv('TRAVIS_CI_BUILD') and io.stdout or io.stderr
|
|
||||||
local out = io.stdout
|
local out = io.stdout
|
||||||
out:write(start_msg .. '\n')
|
out:write(start_msg .. '\n')
|
||||||
out:write('= ' .. table.concat(lines, '\n= ') .. '\n')
|
out:write('= ' .. table.concat(lines, '\n= ') .. '\n')
|
||||||
@ -674,6 +673,37 @@ local function write_file(name, text, no_dedent, append)
|
|||||||
file:close()
|
file:close()
|
||||||
end
|
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 = {
|
local module = {
|
||||||
REMOVE_THIS = REMOVE_THIS,
|
REMOVE_THIS = REMOVE_THIS,
|
||||||
argss_to_cmd = argss_to_cmd,
|
argss_to_cmd = argss_to_cmd,
|
||||||
@ -703,9 +733,10 @@ local module = {
|
|||||||
popen_r = popen_r,
|
popen_r = popen_r,
|
||||||
popen_w = popen_w,
|
popen_w = popen_w,
|
||||||
read_file = read_file,
|
read_file = read_file,
|
||||||
|
read_nvim_log = read_nvim_log,
|
||||||
repeated_read_cmd = repeated_read_cmd,
|
repeated_read_cmd = repeated_read_cmd,
|
||||||
sleep = sleep,
|
|
||||||
shallowcopy = shallowcopy,
|
shallowcopy = shallowcopy,
|
||||||
|
sleep = sleep,
|
||||||
table_flatten = table_flatten,
|
table_flatten = table_flatten,
|
||||||
tmpname = tmpname,
|
tmpname = tmpname,
|
||||||
uname = uname,
|
uname = uname,
|
||||||
|
Loading…
Reference in New Issue
Block a user