2019-08-26 03:21:53 -07:00
|
|
|
#!/usr/bin/env bash
|
2018-03-17 16:38:27 -07:00
|
|
|
|
|
|
|
main() {(
|
2018-03-18 14:53:40 -07:00
|
|
|
local separator="================================================================================"
|
2018-03-17 16:38:27 -07:00
|
|
|
local oldesttest=
|
|
|
|
if test "$1" = "--oldesttest" ; then
|
|
|
|
shift
|
|
|
|
oldesttest=1
|
|
|
|
fi
|
|
|
|
local root="$1" ; shift
|
|
|
|
local nvim_prg="$1" ; shift
|
|
|
|
local test_name="$1" ; shift
|
|
|
|
|
|
|
|
local tlog="$test_name.tlog"
|
|
|
|
|
|
|
|
export NVIM_TEST_ARGC=$#
|
|
|
|
local arg
|
|
|
|
local i=0
|
2019-08-26 03:21:53 -07:00
|
|
|
# shellcheck disable=SC2034 # (unused "arg", used in "eval").
|
2018-03-17 16:38:27 -07:00
|
|
|
for arg ; do
|
|
|
|
eval "export NVIM_TEST_ARG$i=\"\$arg\""
|
|
|
|
i=$(( i+1 ))
|
|
|
|
done
|
|
|
|
|
2019-08-26 03:21:53 -07:00
|
|
|
BUILD_DIR="$(dirname "$nvim_prg")/.."
|
|
|
|
export BUILD_DIR
|
2018-03-17 16:38:27 -07:00
|
|
|
export FAILED=0
|
|
|
|
|
2023-02-08 08:21:05 -07:00
|
|
|
. $(dirname $0)/test.sh
|
2018-03-17 16:38:27 -07:00
|
|
|
|
2023-01-27 02:48:00 -07:00
|
|
|
# Redirect XDG_CONFIG_HOME so users local config doesn't interfere
|
|
|
|
export XDG_CONFIG_HOME="$root"
|
|
|
|
|
2018-03-17 16:38:27 -07:00
|
|
|
export VIMRUNTIME="$root/runtime"
|
|
|
|
if ! "$nvim_prg" \
|
|
|
|
-u NONE -i NONE \
|
|
|
|
--headless \
|
|
|
|
--cmd 'set shortmess+=I noswapfile noundofile nomore' \
|
|
|
|
-S runnvim.vim \
|
2018-03-18 14:53:40 -07:00
|
|
|
"$tlog" > "out-$tlog" 2> "err-$tlog"
|
2018-03-17 16:38:27 -07:00
|
|
|
then
|
2022-03-13 07:07:22 -07:00
|
|
|
fail "$test_name" "Nvim exited with non-zero code"
|
2018-03-17 16:38:27 -07:00
|
|
|
fi
|
2019-08-26 03:21:53 -07:00
|
|
|
{
|
|
|
|
echo "Stdout of :terminal runner"
|
|
|
|
echo "$separator"
|
|
|
|
cat "out-$tlog"
|
|
|
|
echo "$separator"
|
|
|
|
echo "Stderr of :terminal runner"
|
|
|
|
echo "$separator"
|
|
|
|
cat "err-$tlog"
|
|
|
|
echo "$separator"
|
|
|
|
} >> "$tlog"
|
2018-03-17 16:38:27 -07:00
|
|
|
if test "$oldesttest" = 1 ; then
|
|
|
|
if ! diff -q test.out "$test_name.ok" > /dev/null 2>&1 ; then
|
|
|
|
if test -f test.out ; then
|
2022-03-13 07:07:22 -07:00
|
|
|
fail "$test_name" "Oldest test .out file differs from .ok file"
|
2019-08-26 03:21:53 -07:00
|
|
|
{
|
|
|
|
echo "Diff between test.out and $test_name.ok"
|
|
|
|
echo "$separator"
|
|
|
|
diff -a test.out "$test_name.ok"
|
|
|
|
echo "$separator"
|
|
|
|
} >> "$tlog"
|
2018-03-17 16:38:27 -07:00
|
|
|
else
|
|
|
|
echo "No output in test.out" >> "$tlog"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
valgrind_check .
|
|
|
|
if test -n "$LOG_DIR" ; then
|
2019-08-14 09:27:08 -07:00
|
|
|
check_sanitizer "$LOG_DIR"
|
2018-03-17 16:38:27 -07:00
|
|
|
fi
|
|
|
|
check_core_dumps
|
|
|
|
if test "$FAILED" = 1 ; then
|
|
|
|
cat "$tlog"
|
|
|
|
fi
|
|
|
|
rm -f "$tlog"
|
|
|
|
if test "$FAILED" = 1 ; then
|
|
|
|
echo "Test $test_name failed, see output above and summary for more details" >> test.log
|
2019-12-02 10:26:40 -07:00
|
|
|
# When Neovim crashed/aborted it might not have created messages.
|
|
|
|
# test.log itself is used as an indicator to exit non-zero in the Makefile.
|
|
|
|
if ! test -f message; then
|
|
|
|
cp -a test.log messages
|
|
|
|
fi
|
2018-03-17 16:38:27 -07:00
|
|
|
fi
|
|
|
|
)}
|
|
|
|
|
|
|
|
main "$@"
|