Commit 9b3c9049 authored by Akim Demaille's avatar Akim Demaille
Browse files

vcsn-diagnose: help users track failures

That's only an initial stab.
parent 87be1c6c
......@@ -14,7 +14,7 @@
- ../configure CPPFLAGS="$CPPFLAGS" CC="$CC" CXX="$CXX" CXXFLAGS="$CXXFLAGS"
- make
- if [[ $CHECK == "installcheck" ]]; then make install; fi
- make $CHECK
- make "$CHECK"
- ccache -s
artifacts:
when: always
......
......@@ -98,6 +98,7 @@ COMMAND can be:
- notebook: run Vcsn as an IPython Notebook.
- python, ipython: run Python/IPython.
- diagnose: check that Vcsn is properly installed.
- doc: open the documentation.
- gdb: run gdb with a type pretty-printer.
......@@ -215,7 +216,11 @@ case $1 in
(config)
shift
config "$@";;
exec config "$@";;
(check|diagnose|doctor)
shift
exec vcsn-diagnose "$@";;
(doc)
shift
......
......@@ -20,6 +20,7 @@ python_scripts = \
dist_pkglibexec_SCRIPTS = \
$(python_scripts) \
%D%/vcsn-diagnose \
%D%/vcsn-gdb \
%D%/vcsn-notebook
......
#! /bin/bash
# Don't run under /bin/sh, on Debian Sid it's a very poor version of
# dash that behaves incorrectly with local (`local a=$1` IFS-splits $1
# and complains about additional arguments), that does not support
# arithmetics, and `$'...'` strings.
#
# We could fight for portability. Or do interesting things in our
# lives.
set -e
red=$'\e[0;31m'
gre=$'\e[0;32m'
std=$'\e[0m'
# Prefer `/tmp` rather than `-t xxx`, as it ends in the very longuish
# `/var/folders/...` on macOS.
tmp=$(mktemp -d "/tmp/$(basename "$0").XXXX")
ls $tmp
exec 3>$tmp/diagnose.log
# Goes to the log file.
log ()
{
printf >&3 "%s\n" "$@"
}
# Goes to the stdout and the log file.
output ()
{
log "$@"
printf "%s\n" "$@"
}
fail ()
{
local msg="${red}FAIL${std}: $1"
shift
output "$msg" "${@}"
((++nfail))
}
pass ()
{
local msg="${gre}PASS${std}: $1"
shift
output "$msg" "${@}"
((++npass))
}
# check COMMAND EXPECTED-OUTPUT
#
# Check that something works.
check ()
{
local cmd=$1
local exp=$2
local out
out=$(eval "$cmd" |
# Remove window title escape sequence that IPython adds
# to its output.
sed -e $'s/\033]0;[^\a]*\a//')
if [[ $out = "$exp" ]]; then
pass "$cmd"
else
fail "invalid result" " cmd: $cmd" " expected: $exp" "effective: $out"
fi
}
# info COMMAND
#
# Log some information. Information is available in $info_result.
info ()
{
local cmd=$1
if info_result=$(eval "${cmd}"); then
pass "$cmd: $info_result"
else
fail "$cmd"
fi
}
check_tools ()
{
check 'vcsn cat -Ee a' 'a'
# Force a context instantiation.
check 'vcsn cat -C "lal(abc), zmin" -Ee a' 'a'
}
check_python ()
{
local python=$1
info "vcsn $python --version"
# Check this is Python 3.
info "vcsn $python -c 'import sys; print(sys.version_info)'"
check "vcsn $python -c 'import vcsn; print(vcsn.B.expression(\"ab\"))'" \
"ab"
check "vcsn $python -c 'import vcsn; print(vcsn.context(\"lal, zmin\"))'" \
"{...} -> Zmin"
}
# Main.
info "command -v vcsn"
info "vcsn version"
check_tools
check_python python
check_python ipython
if (( nfail == 0 )); then
output "All seems well"
else
output "$nfail tests failed, please send $tmp.tar.bz2 to vcsn-bugs@lrde.epita.fr"
fi
cd "$(dirname "$tmp")" && tar cfj "$tmp.tar.bz2" "$(basename "$tmp")"
rm -rf "$tmp"
(( nfail == 0 ))
#! /bin/sh
run 0 stdout -vcsn diagnose </dev/null
sed -E \
-e 's,(.*PASS[^:]*: [^:]*): .*,\1: ...,' \
<stdout >output
run 0 - -cat output <<EOF
PASS: which vcsn: ...
PASS: vcsn version: ...
PASS: vcsn cat -Ee a
PASS: vcsn cat -C "lal(abc), zmin" -Ee a
PASS: vcsn python --version: ...
PASS: vcsn python -c 'import sys; print(sys.version_info)': ...
PASS: vcsn python -c 'import vcsn; print(vcsn.B.expression("ab"))'
PASS: vcsn python -c 'import vcsn; print(vcsn.context("lal, zmin"))'
PASS: vcsn ipython --version: ...
PASS: vcsn ipython -c 'import sys; print(sys.version_info)': ...
PASS: vcsn ipython -c 'import vcsn; print(vcsn.B.expression("ab"))'
PASS: vcsn ipython -c 'import vcsn; print(vcsn.context("lal, zmin"))'
All seems well
EOF
......@@ -12,12 +12,14 @@
## The Vcsn Group consists of people listed in the `AUTHORS' file.
%C%_TESTS = \
%D%/diagnose.chk \
%D%/evaluate.chk \
%D%/help.chk
dist_TESTS += $(%C%_TESTS)
$(%C%_TESTS:.chk=.log): libexec/vcsn-tools
%D%/diagnose.log: libexec/vcsn-diagnose
.PHONY: check-tools
check-tools:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment