added t/err.sh for testing errors
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
hyung-hwan 2024-05-04 00:49:27 +09:00
parent b6a512f90f
commit 4ed8651821
7 changed files with 146 additions and 12 deletions

View File

@ -166,9 +166,10 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/ar-lib \
$(top_srcdir)/ac/compile $(top_srcdir)/ac/config.guess \ $(top_srcdir)/ac/compile $(top_srcdir)/ac/config.guess \
$(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \ $(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \
$(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing \ $(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing \
$(top_srcdir)/ac/tap-driver.sh $(top_srcdir)/pkgs/hawk.spec.in \ $(top_srcdir)/ac/tap-driver.sh $(top_srcdir)/ac/test-driver \
README.md ac/ar-lib ac/compile ac/config.guess ac/config.sub \ $(top_srcdir)/pkgs/hawk.spec.in README.md ac/ar-lib ac/compile \
ac/depcomp ac/install-sh ac/ltmain.sh ac/missing ac/config.guess ac/config.sub ac/depcomp ac/install-sh \
ac/ltmain.sh ac/missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION) distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir) top_distdir = $(distdir)

4
configure vendored
View File

@ -3176,7 +3176,7 @@ as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H"
as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H" as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H"
# Auxiliary files required by this configure script. # Auxiliary files required by this configure script.
ac_aux_files="config.guess config.sub ltmain.sh tap-driver.sh compile ar-lib missing install-sh" ac_aux_files="config.guess config.sub ltmain.sh test-driver tap-driver.sh compile ar-lib missing install-sh"
# Locations in which to look for auxiliary files. # Locations in which to look for auxiliary files.
ac_aux_dir_candidates="${srcdir}/ac" ac_aux_dir_candidates="${srcdir}/ac"
@ -5409,6 +5409,8 @@ esac
# Check whether --enable-silent-rules was given. # Check whether --enable-silent-rules was given.
if test ${enable_silent_rules+y} if test ${enable_silent_rules+y}
then : then :

View File

@ -14,6 +14,7 @@ AM_INIT_AUTOMAKE([-Wall -Werror subdir-objects foreign])
AM_PROG_AR AM_PROG_AR
AC_REQUIRE_AUX_FILE([tap-driver.sh]) AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_REQUIRE_AUX_FILE([test-driver])
dnl enable silent rules if automake supports them. dnl enable silent rules if automake supports them.
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])

View File

@ -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 err.sh \
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 =

View File

@ -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 err.sh \
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
View 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
View 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