added t/err.sh for testing errors
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
b6a512f90f
commit
09ce5dfea7
@ -14,8 +14,11 @@ LDFLAGS_COMMON=-L$(abs_builddir)/../lib -L$(libdir)
|
|||||||
LIBADD_COMMON = ../lib/libhawk.la $(LIBM)
|
LIBADD_COMMON = ../lib/libhawk.la $(LIBM)
|
||||||
|
|
||||||
check_SCRIPTS = h-001.hawk h-002.hawk h-003.hawk h-004.hawk h-009.hawk
|
check_SCRIPTS = h-001.hawk h-002.hawk h-003.hawk h-004.hawk h-009.hawk
|
||||||
|
|
||||||
|
check_ERRORS = e-001.err
|
||||||
|
|
||||||
##noinst_SCRIPTS = $(check_SCRIPTS)
|
##noinst_SCRIPTS = $(check_SCRIPTS)
|
||||||
EXTRA_DIST = $(check_SCRIPTS) tap.inc \
|
EXTRA_DIST = $(check_SCRIPTS) $(check_ERRORS) tap.inc \
|
||||||
journal-toc.hawk journal-toc.in journal-toc.out journal-toc-html.out \
|
journal-toc.hawk journal-toc.in journal-toc.out journal-toc-html.out \
|
||||||
bibtex-to-html.hawk bibtex-to-html.out
|
bibtex-to-html.hawk bibtex-to-html.out
|
||||||
|
|
||||||
@ -55,9 +58,14 @@ t_006_LDFLAGS = $(LDFLAGS_COMMON)
|
|||||||
t_006_LDADD = $(LIBADD_COMMON)
|
t_006_LDADD = $(LIBADD_COMMON)
|
||||||
|
|
||||||
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/ac/tap-driver.sh
|
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/ac/tap-driver.sh
|
||||||
TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
|
TESTS = $(check_PROGRAMS) $(check_SCRIPTS) $(check_ERRORS)
|
||||||
|
|
||||||
|
TEST_EXTENSIONS = .hawk .err
|
||||||
|
|
||||||
TEST_EXTENSIONS = .hawk
|
|
||||||
HAWK_LOG_DRIVER = $(LOG_DRIVER)
|
HAWK_LOG_DRIVER = $(LOG_DRIVER)
|
||||||
HAWK_LOG_COMPILER = ../bin/hawk
|
HAWK_LOG_COMPILER = ../bin/hawk
|
||||||
AM_HAWK_LOG_FLAGS = -vTDIR=${abs_srcdir} --modlibdirs=../lib/.libs:../mod/.libs -f
|
AM_HAWK_LOG_FLAGS = -vTDIR=${abs_srcdir} --modlibdirs=../lib/.libs:../mod/.libs -f
|
||||||
|
|
||||||
|
ERR_LOG_DRIVER = $(SHELL) $(top_srcdir)/ac/test-driver
|
||||||
|
ERR_LOG_COMPILER = $(SHELL) $(abs_srcdir)/err.sh ../bin/hawk -vTDIR=${abs_srcdir} --modlibdirs=../lib/.libs:../mod/.libs -f
|
||||||
|
AM_ERR_LOG_FLAGS =
|
||||||
|
@ -409,9 +409,12 @@ am__set_b = \
|
|||||||
esac
|
esac
|
||||||
am__test_logs1 = $(TESTS:=.log)
|
am__test_logs1 = $(TESTS:=.log)
|
||||||
am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
|
am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
|
||||||
TEST_LOGS = $(am__test_logs2:.hawk.log=.log)
|
am__test_logs3 = $(am__test_logs2:.hawk.log=.log)
|
||||||
HAWK_LOG_COMPILE = $(HAWK_LOG_COMPILER) $(AM_HAWK_LOG_FLAGS) \
|
HAWK_LOG_COMPILE = $(HAWK_LOG_COMPILER) $(AM_HAWK_LOG_FLAGS) \
|
||||||
$(HAWK_LOG_FLAGS)
|
$(HAWK_LOG_FLAGS)
|
||||||
|
TEST_LOGS = $(am__test_logs3:.err.log=.log)
|
||||||
|
ERR_LOG_COMPILE = $(ERR_LOG_COMPILER) $(AM_ERR_LOG_FLAGS) \
|
||||||
|
$(ERR_LOG_FLAGS)
|
||||||
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/depcomp
|
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/depcomp
|
||||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
ACLOCAL = @ACLOCAL@
|
ACLOCAL = @ACLOCAL@
|
||||||
@ -579,7 +582,8 @@ CFLAGS_COMMON =
|
|||||||
LDFLAGS_COMMON = -L$(abs_builddir)/../lib -L$(libdir)
|
LDFLAGS_COMMON = -L$(abs_builddir)/../lib -L$(libdir)
|
||||||
LIBADD_COMMON = ../lib/libhawk.la $(LIBM)
|
LIBADD_COMMON = ../lib/libhawk.la $(LIBM)
|
||||||
check_SCRIPTS = h-001.hawk h-002.hawk h-003.hawk h-004.hawk h-009.hawk
|
check_SCRIPTS = h-001.hawk h-002.hawk h-003.hawk h-004.hawk h-009.hawk
|
||||||
EXTRA_DIST = $(check_SCRIPTS) tap.inc \
|
check_ERRORS = e-001.err
|
||||||
|
EXTRA_DIST = $(check_SCRIPTS) $(check_ERRORS) tap.inc \
|
||||||
journal-toc.hawk journal-toc.in journal-toc.out journal-toc-html.out \
|
journal-toc.hawk journal-toc.in journal-toc.out journal-toc-html.out \
|
||||||
bibtex-to-html.hawk bibtex-to-html.out
|
bibtex-to-html.hawk bibtex-to-html.out
|
||||||
|
|
||||||
@ -611,15 +615,18 @@ t_006_CFLAGS = $(CFLAGS_COMMON)
|
|||||||
t_006_LDFLAGS = $(LDFLAGS_COMMON)
|
t_006_LDFLAGS = $(LDFLAGS_COMMON)
|
||||||
t_006_LDADD = $(LIBADD_COMMON)
|
t_006_LDADD = $(LIBADD_COMMON)
|
||||||
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/ac/tap-driver.sh
|
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/ac/tap-driver.sh
|
||||||
TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
|
TESTS = $(check_PROGRAMS) $(check_SCRIPTS) $(check_ERRORS)
|
||||||
TEST_EXTENSIONS = .hawk
|
TEST_EXTENSIONS = .hawk .err
|
||||||
HAWK_LOG_DRIVER = $(LOG_DRIVER)
|
HAWK_LOG_DRIVER = $(LOG_DRIVER)
|
||||||
HAWK_LOG_COMPILER = ../bin/hawk
|
HAWK_LOG_COMPILER = ../bin/hawk
|
||||||
AM_HAWK_LOG_FLAGS = -vTDIR=${abs_srcdir} --modlibdirs=../lib/.libs:../mod/.libs -f
|
AM_HAWK_LOG_FLAGS = -vTDIR=${abs_srcdir} --modlibdirs=../lib/.libs:../mod/.libs -f
|
||||||
|
ERR_LOG_DRIVER = $(SHELL) $(top_srcdir)/ac/test-driver
|
||||||
|
ERR_LOG_COMPILER = $(SHELL) $(abs_srcdir)/err.sh ../bin/hawk -vTDIR=${abs_srcdir} --modlibdirs=../lib/.libs:../mod/.libs -f
|
||||||
|
AM_ERR_LOG_FLAGS =
|
||||||
all: all-am
|
all: all-am
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
.SUFFIXES: .c .hawk .hawk$(EXEEXT) .lo .log .o .obj .trs
|
.SUFFIXES: .c .err .err$(EXEEXT) .hawk .hawk$(EXEEXT) .lo .log .o .obj .trs
|
||||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||||
@for dep in $?; do \
|
@for dep in $?; do \
|
||||||
case '$(am__configure_deps)' in \
|
case '$(am__configure_deps)' in \
|
||||||
@ -1065,6 +1072,20 @@ t-006.log: t-006$(EXEEXT)
|
|||||||
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
|
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
|
||||||
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_HAWK_LOG_DRIVER_FLAGS) $(HAWK_LOG_DRIVER_FLAGS) -- $(HAWK_LOG_COMPILE) \
|
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_HAWK_LOG_DRIVER_FLAGS) $(HAWK_LOG_DRIVER_FLAGS) -- $(HAWK_LOG_COMPILE) \
|
||||||
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
|
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
|
||||||
|
.err.log:
|
||||||
|
@p='$<'; \
|
||||||
|
$(am__set_b); \
|
||||||
|
$(am__check_pre) $(ERR_LOG_DRIVER) --test-name "$$f" \
|
||||||
|
--log-file $$b.log --trs-file $$b.trs \
|
||||||
|
$(am__common_driver_flags) $(AM_ERR_LOG_DRIVER_FLAGS) $(ERR_LOG_DRIVER_FLAGS) -- $(ERR_LOG_COMPILE) \
|
||||||
|
"$$tst" $(AM_TESTS_FD_REDIRECT)
|
||||||
|
@am__EXEEXT_TRUE@.err$(EXEEXT).log:
|
||||||
|
@am__EXEEXT_TRUE@ @p='$<'; \
|
||||||
|
@am__EXEEXT_TRUE@ $(am__set_b); \
|
||||||
|
@am__EXEEXT_TRUE@ $(am__check_pre) $(ERR_LOG_DRIVER) --test-name "$$f" \
|
||||||
|
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
|
||||||
|
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_ERR_LOG_DRIVER_FLAGS) $(ERR_LOG_DRIVER_FLAGS) -- $(ERR_LOG_COMPILE) \
|
||||||
|
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
|
||||||
distdir: $(BUILT_SOURCES)
|
distdir: $(BUILT_SOURCES)
|
||||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||||
|
|
||||||
|
24
t/e-001.err
Normal file
24
t/e-001.err
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
BEGIN {
|
||||||
|
##ERROR: unexpected end of input
|
||||||
|
---
|
||||||
|
|
||||||
|
function abc(x { ##ERROR: comma expected in place of
|
||||||
|
}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
@argv = 10 ##ERROR: invalid assignment statement
|
||||||
|
}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
@argc = 10 ##ERROR: invalid assignment statement
|
||||||
|
}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
@nil = 10 ##ERROR: invalid assignment statement
|
||||||
|
}
|
77
t/err.sh
Normal file
77
t/err.sh
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
for i in $@; do :; done
|
||||||
|
script="$i"
|
||||||
|
|
||||||
|
run_partfile() {
|
||||||
|
l_cmd="";
|
||||||
|
l_nargs=$#
|
||||||
|
|
||||||
|
while [ $# -gt 3 ]
|
||||||
|
do
|
||||||
|
l_cmd="$l_cmd $1"
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
l_script="$1"
|
||||||
|
shift ## skip the original script.
|
||||||
|
l_partno="$1"
|
||||||
|
shift ## partno
|
||||||
|
|
||||||
|
l_partfile="$1"
|
||||||
|
l_cmd="$l_cmd $l_partfile"
|
||||||
|
|
||||||
|
l_expected_errinfo=$(grep -n -o -E "##ERROR: .+" "$l_partfile" 2>/dev/null)
|
||||||
|
[ -z "$l_expected_errinfo" ] && {
|
||||||
|
echo "ERROR: INVALID TESTER - $l_script($l_partno) contains no ERROR information"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
l_expected_errline=$(echo $l_expected_errinfo | cut -d: -f1)
|
||||||
|
l_xlen=$(echo $l_expected_errline | wc -c)
|
||||||
|
l_xlen=$(expr $l_xlen + 10)
|
||||||
|
l_expected_errmsg=$(echo $l_expected_errinfo | cut -c${l_xlen}-)
|
||||||
|
l_output=`$l_cmd 2>&1`
|
||||||
|
## the regular expression is not escaped properly. the error information must not
|
||||||
|
## include specifial regex characters to avoid problems.
|
||||||
|
echo "$l_output" | grep -E "ERROR: .+ LINE ${l_expected_errline} .+ FILE ${l_partfile} - ${l_expected_errmsg}" >/dev/null 2>&1 || {
|
||||||
|
echo "ERROR: error not raised at line $l_expected_errline - $l_script($l_partno) - $l_output"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "OK"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ever_failed=0
|
||||||
|
partfile=`mktemp`
|
||||||
|
partno=0
|
||||||
|
partlines=0
|
||||||
|
> "$partfile"
|
||||||
|
|
||||||
|
## dash behaves differently for read -r.
|
||||||
|
## while \n is read in literally by bash or other shells, dash converts it to a new-line
|
||||||
|
while IFS= read -r line
|
||||||
|
do
|
||||||
|
if [ "$line" = "---" ]
|
||||||
|
then
|
||||||
|
[ $partlines -gt 0 ] && {
|
||||||
|
run_partfile "$@" "$partno" "$partfile" || ever_failed=1
|
||||||
|
}
|
||||||
|
partno=`expr $partno + 1`
|
||||||
|
partlines=0
|
||||||
|
> "$partfile"
|
||||||
|
else
|
||||||
|
echo "$line" >> "$partfile"
|
||||||
|
partlines=`expr $partlines + 1`
|
||||||
|
fi
|
||||||
|
done < "$script"
|
||||||
|
|
||||||
|
[ $partlines -gt 0 ] && {
|
||||||
|
run_partfile "$@" "$partno" "$partfile" || ever_failed=1
|
||||||
|
}
|
||||||
|
|
||||||
|
rm -f "$partfile"
|
||||||
|
exit $ever_failed
|
||||||
|
|
Loading…
Reference in New Issue
Block a user