Move messages.fail to a temporary directory

This commit is contained in:
Foo 2017-04-30 15:30:15 +03:00
parent 82ca32edc9
commit 53a7d1046e
8 changed files with 44 additions and 13 deletions

View File

@ -7,14 +7,18 @@ if test -z "$FAILED" ; then
FAILED=0
FAIL_SUMMARY=""
TMP_ROOT="$ROOT/tests/tmp"
FAILURES_FILE="$ROOT/tests/failures"
fi
enter_suite() {
local suite_name="$1"
local suite_name="$1" ; shift
export POWERLINE_CURRENT_SUITE="${POWERLINE_CURRENT_SUITE}/$suite_name"
}
exit_suite() {
rm_tmp_dir
if test $FAILED -ne 0 ; then
echo "Suite ${POWERLINE_CURRENT_SUITE} failed, summary:"
echo "${FAIL_SUMMARY}"
@ -31,14 +35,37 @@ fail() {
shift
allow_failure=A
fi
local test_name="$1"
local fail_char="$allow_failure$2"
local message="$3"
local test_name="$1" ; shift
local fail_char="$allow_failure$1" ; shift
local message="$1" ; shift
local full_msg="$fail_char $POWERLINE_CURRENT_SUITE|$test_name :: $message"
FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}"
echo "Failed: $full_msg"
echo "$full_msg" >> "$ROOT/tests/failures"
echo "$full_msg" >> "$FAILURES_FILE"
if test "x$allow_failure" = "x" ; then
FAILED=1
fi
}
make_tmp_dir() {
local suffix="$1" ; shift
local tmpdir="$TMP_ROOT/$suffix/"
if test -d "$tmpdir" ; then
rm -r "$tmpdir"
fi
mkdir -p "$tmpdir"
printf '%s' "$tmpdir"
}
rm_tmp_dir() {
if test -e "$FAILURES_FILE" ; then
return 0
fi
if test -d "$TMP_ROOT" ; then
rm -r "$TMP_ROOT"
fi
}

View File

@ -10,8 +10,8 @@ export POWERLINE_CONFIG_OVERRIDES='common.default_top_theme=ascii'
export POWERLINE_THEME_OVERRIDES='default.segments.left=[]'
test_script() {
local vim="$1"
local script="$2"
local vim="$1" ; shift
local script="$1" ; shift
echo "Running script $script with $vim"
if ! test -e "$vim" ; then
return 0
@ -28,8 +28,12 @@ test_script() {
fi
}
TMPDIR="$(make_tmp_dir vim)"
TEST_SCRIPT_ROOT="$ROOT/tests/test_vim/tests"
cd "$TMPDIR"
for script in "$TEST_SCRIPT_ROOT"/*.vim ; do
if test "${script%.old.vim}" = "${script}" ; then
test_script "$NEW_VIM" "$script"

View File

@ -14,7 +14,7 @@ endif
let g:powerline_config_paths = [expand('<sfile>:p:h:h:h:h') . '/powerline/config_files']
try
source powerline/bindings/vim/plugin/powerline.vim
source <sfile>:p:h:h:h:h/powerline/bindings/vim/plugin/powerline.vim
catch
call writefile(['Unexpected exception:', v:exception], 'message.fail')
cquit

View File

@ -4,7 +4,7 @@ let g:powerline_config_paths = [expand('<sfile>:p:h:h:h:h') . '/powerline/config
set laststatus=2
redir => g:messages
try
source powerline/bindings/vim/plugin/powerline.vim
source <sfile>:p:h:h:h:h/powerline/bindings/vim/plugin/powerline.vim
redrawstatus!
vsplit
redrawstatus!

View File

@ -5,7 +5,7 @@ set showtabline=2
edit `="\xFF"`
redir => g:messages
try
source powerline/bindings/vim/plugin/powerline.vim
source <sfile>:p:h:h:h:h/powerline/bindings/vim/plugin/powerline.vim
redrawstatus!
catch
call writefile(['Unexpected exception', v:exception], 'message.fail')

View File

@ -4,7 +4,7 @@ let g:powerline_config_paths = [expand('<sfile>:p:h:h:h:h') . '/powerline/config
tabedit abc
tabedit def
try
source powerline/bindings/vim/plugin/powerline.vim
source <sfile>:p:h:h:h:h/powerline/bindings/vim/plugin/powerline.vim
catch
call writefile([v:exception], 'message.fail')
cquit

View File

@ -1,7 +1,7 @@
#!/usr/bin/vim -S
set encoding=utf-8
let g:powerline_config_paths = [expand('<sfile>:p:h:h:h:h') . '/powerline/config_files']
source powerline/bindings/vim/plugin/powerline.vim
source <sfile>:p:h:h:h:h/powerline/bindings/vim/plugin/powerline.vim
edit abc
tabedit def
tabedit ghi

View File

@ -2,7 +2,7 @@ let g:powerline_use_var_handler = 1
let g:pyfiles_root=expand('<sfile>:p:h').'/pyfiles'
let g:root=expand('<sfile>:p:h:h:h')
let g:mf=g:root.'/message.fail'
let g:mf=fnamemodify('message.fail', ':p')
command -nargs=1 LST :call writefile(<args>, g:mf, 'a') | cquit
command -nargs=1 ERR :LST [<args>]