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 FAILED=0
FAIL_SUMMARY="" FAIL_SUMMARY=""
TMP_ROOT="$ROOT/tests/tmp"
FAILURES_FILE="$ROOT/tests/failures"
fi fi
enter_suite() { enter_suite() {
local suite_name="$1" local suite_name="$1" ; shift
export POWERLINE_CURRENT_SUITE="${POWERLINE_CURRENT_SUITE}/$suite_name" export POWERLINE_CURRENT_SUITE="${POWERLINE_CURRENT_SUITE}/$suite_name"
} }
exit_suite() { exit_suite() {
rm_tmp_dir
if test $FAILED -ne 0 ; then if test $FAILED -ne 0 ; then
echo "Suite ${POWERLINE_CURRENT_SUITE} failed, summary:" echo "Suite ${POWERLINE_CURRENT_SUITE} failed, summary:"
echo "${FAIL_SUMMARY}" echo "${FAIL_SUMMARY}"
@ -31,14 +35,37 @@ fail() {
shift shift
allow_failure=A allow_failure=A
fi fi
local test_name="$1" local test_name="$1" ; shift
local fail_char="$allow_failure$2" local fail_char="$allow_failure$1" ; shift
local message="$3" local message="$1" ; shift
local full_msg="$fail_char $POWERLINE_CURRENT_SUITE|$test_name :: $message" local full_msg="$fail_char $POWERLINE_CURRENT_SUITE|$test_name :: $message"
FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}" FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}"
echo "Failed: $full_msg" echo "Failed: $full_msg"
echo "$full_msg" >> "$ROOT/tests/failures" echo "$full_msg" >> "$FAILURES_FILE"
if test "x$allow_failure" = "x" ; then if test "x$allow_failure" = "x" ; then
FAILED=1 FAILED=1
fi 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=[]' export POWERLINE_THEME_OVERRIDES='default.segments.left=[]'
test_script() { test_script() {
local vim="$1" local vim="$1" ; shift
local script="$2" local script="$1" ; shift
echo "Running script $script with $vim" echo "Running script $script with $vim"
if ! test -e "$vim" ; then if ! test -e "$vim" ; then
return 0 return 0
@ -28,8 +28,12 @@ test_script() {
fi fi
} }
TMPDIR="$(make_tmp_dir vim)"
TEST_SCRIPT_ROOT="$ROOT/tests/test_vim/tests" TEST_SCRIPT_ROOT="$ROOT/tests/test_vim/tests"
cd "$TMPDIR"
for script in "$TEST_SCRIPT_ROOT"/*.vim ; do for script in "$TEST_SCRIPT_ROOT"/*.vim ; do
if test "${script%.old.vim}" = "${script}" ; then if test "${script%.old.vim}" = "${script}" ; then
test_script "$NEW_VIM" "$script" 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'] let g:powerline_config_paths = [expand('<sfile>:p:h:h:h:h') . '/powerline/config_files']
try try
source powerline/bindings/vim/plugin/powerline.vim source <sfile>:p:h:h:h:h/powerline/bindings/vim/plugin/powerline.vim
catch catch
call writefile(['Unexpected exception:', v:exception], 'message.fail') call writefile(['Unexpected exception:', v:exception], 'message.fail')
cquit cquit

View File

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

View File

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

View File

@ -1,7 +1,7 @@
#!/usr/bin/vim -S #!/usr/bin/vim -S
set encoding=utf-8 set encoding=utf-8
let g:powerline_config_paths = [expand('<sfile>:p:h:h:h:h') . '/powerline/config_files'] 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 edit abc
tabedit def tabedit def
tabedit ghi 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:pyfiles_root=expand('<sfile>:p:h').'/pyfiles'
let g:root=expand('<sfile>:p:h:h:h') 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 LST :call writefile(<args>, g:mf, 'a') | cquit
command -nargs=1 ERR :LST [<args>] command -nargs=1 ERR :LST [<args>]