runnvim.sh (2266B)
1 #!/usr/bin/env bash 2 3 main() {( 4 local separator="================================================================================" 5 local oldesttest= 6 if test "$1" = "--oldesttest" ; then 7 shift 8 oldesttest=1 9 fi 10 local root="$1" ; shift 11 local nvim_prg="$1" ; shift 12 local test_name="$1" ; shift 13 14 local tlog="$test_name.tlog" 15 16 export NVIM_TEST_ARGC=$# 17 local arg 18 local i=0 19 # shellcheck disable=SC2034 # (unused "arg", used in "eval"). 20 for arg ; do 21 eval "export NVIM_TEST_ARG$i=\"\$arg\"" 22 i=$(( i+1 )) 23 done 24 25 BUILD_DIR="$(dirname "$nvim_prg")/.." 26 export BUILD_DIR 27 export FAILED=0 28 29 . $(dirname $0)/test.sh 30 31 # Redirect XDG_CONFIG_HOME so users local config doesn't interfere 32 export XDG_CONFIG_HOME="$root" 33 34 export VIMRUNTIME="$root/runtime" 35 if ! "$nvim_prg" \ 36 -u NONE -i NONE \ 37 --headless \ 38 --cmd 'set shortmess+=I noswapfile noundofile nomore' \ 39 -S runnvim.vim \ 40 "$tlog" > "out-$tlog" 2> "err-$tlog" 41 then 42 fail "$test_name" "Nvim exited with non-zero code" 43 fi 44 { 45 echo "Stdout of :terminal runner" 46 echo "$separator" 47 cat "out-$tlog" 48 echo "$separator" 49 echo "Stderr of :terminal runner" 50 echo "$separator" 51 cat "err-$tlog" 52 echo "$separator" 53 } >> "$tlog" 54 if test "$oldesttest" = 1 ; then 55 if ! diff -q test.out "$test_name.ok" > /dev/null 2>&1 ; then 56 if test -f test.out ; then 57 fail "$test_name" "Oldest test .out file differs from .ok file" 58 { 59 echo "Diff between test.out and $test_name.ok" 60 echo "$separator" 61 diff -a test.out "$test_name.ok" 62 echo "$separator" 63 } >> "$tlog" 64 else 65 echo "No output in test.out" >> "$tlog" 66 fi 67 fi 68 fi 69 valgrind_check . 70 if test -n "$LOG_DIR" ; then 71 check_sanitizer "$LOG_DIR" 72 fi 73 check_core_dumps 74 if test "$FAILED" = 1 ; then 75 cat "$tlog" 76 fi 77 rm -f "$tlog" 78 if test "$FAILED" = 1 ; then 79 echo "Test $test_name failed, see output above and summary for more details" >> test.log 80 # When Neovim crashed/aborted it might not have created messages. 81 # test.log itself is used as an indicator to exit non-zero in the Makefile. 82 if ! test -f message; then 83 cp -a test.log messages 84 fi 85 fi 86 )} 87 88 main "$@"