enhanced the test runner for errors to support multiple scripts in a single file
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
hyung-hwan 2024-02-05 02:43:50 +09:00
parent d99a514278
commit 4d5f2266b4
13 changed files with 137 additions and 80 deletions

View File

@ -16,14 +16,6 @@ check_ERRORS = \
do-5001.err \ do-5001.err \
do-5002.err \ do-5002.err \
feed-5001.err \ feed-5001.err \
feed-5002.err \
feed-5003.err \
feed-5004.err \
feed-5005.err \
feed-5006.err \
feed-5007.err \
feed-5008.err \
feed-5009.err \
mlist-5001.err \ mlist-5001.err \
var-5001.err \ var-5001.err \
var-5002.err \ var-5002.err \

View File

@ -487,14 +487,6 @@ check_ERRORS = \
do-5001.err \ do-5001.err \
do-5002.err \ do-5002.err \
feed-5001.err \ feed-5001.err \
feed-5002.err \
feed-5003.err \
feed-5004.err \
feed-5005.err \
feed-5006.err \
feed-5007.err \
feed-5008.err \
feed-5009.err \
mlist-5001.err \ mlist-5001.err \
var-5001.err \ var-5001.err \
var-5002.err \ var-5002.err \

View File

@ -3,22 +3,73 @@
for i in $@; do :; done for i in $@; do :; done
script="$i" script="$i"
expected_errinfo=$(grep -n -o -E "##ERROR: .+" "$script" 2>/dev/null) run_partfile() {
[ -z "$expected_errinfo" ] && { l_cmd="";
echo "INVALID TESTER - $script contains no ERROR information" l_nargs=$#
exit 1
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:.+${l_partfile}\[${l_expected_errline},[[:digit:]]+\] ${l_expected_errmsg}" >/dev/null 2>&1 || {
echo "ERROR: error not raised - $l_script($l_partno) - $l_output"
return 1
}
echo "OK"
return 0
} }
expected_errline=$(echo $expected_errinfo | cut -d: -f1)
xlen=$(echo $expected_errline | wc -c)
xlen=$(expr $xlen + 10)
expected_errmsg=$(echo $expected_errinfo | cut -c${xlen}-)
output=$($@ 2>&1) ever_failed=0
## the regular expression is not escaped properly. the error information must not partfile=`mktemp`
## include specifial regex characters to avoid problems. partno=0
echo "$output" | grep -E "ERROR:.+${script}\[${expected_errline},[[:digit:]]+\] ${expected_errmsg}" || { partlines=0
echo "$script - $output" > "$partfile"
exit 1
## TODO: don't use while read 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
} }
exit 0
rm -f "$partfile"
exit $ever_failed

View File

@ -1,2 +1,69 @@
## you can't have another colon before the method.. ## you can't have another colon before the method..
(obj: :method) ##ERROR: syntax error - : disallowed (obj: :method) ##ERROR: syntax error - : disallowed
---
## while EOL is ignored in explicitly parenthesized XLIST, a semicolon must not be.
(printf
"hello, world\n"
)
(printf; ##ERROR: syntax error - unexpected semicolon
"hello, world\n"
)
---
## semicolon inside #{} must raise a syntax error
a := #{
"k1":
"hello k1\n",
"k2":
"hello k2\n"; ##ERROR: syntax error - unexpected semicolon
};
---
{
;;;
(do
(printf "hello\n")
(printf "hello\n")
);;
k := [10 ; 20 ]; ##ERROR: syntax error - unexpected semicolon
}
---
## a code point greater than 255 is illegal in the character literal prefix fixed with b.
printf "[%c] [#x%x] [%d]\n" '★' '★' #x2605;
printf "[%c]\n" b'★'; ##ERROR: syntax error - wrong character literal
---
## #b can be followed by [ or binary digits.
printf "%O\n" #b[ 10 20 30 ];
printf "%010b\n" #b0101;
printf "%O\n" #bxy; ##ERROR: syntax error - neither valid radixed number nor valid directive #bxy
---
printf :*; ##ERROR: syntax error - prohibited in this context
---
defun :: fun1() { ##ERROR: syntax error - function name not symbol in defun
return 10;
};
---
defun :* fun1() { ##ERROR: syntax error - function name not symbol in defun
return 10;
};

View File

@ -1,8 +0,0 @@
## while EOL is ignored in explicitly parenthesized XLIST, a semicolon must not be.
(printf
"hello, world\n"
)
(printf; ##ERROR: syntax error - unexpected semicolon
"hello, world\n"
)

View File

@ -1,9 +0,0 @@
## semicolon inside #{} must raise a syntax error
a := #{
"k1":
"hello k1\n",
"k2":
"hello k2\n"; ##ERROR: syntax error - unexpected semicolon
};

View File

@ -1,11 +0,0 @@
{
;;;
(do
(printf "hello\n")
(printf "hello\n")
);;
k := [10 ; 20 ]; ##ERROR: syntax error - unexpected semicolon
}

View File

@ -1,4 +0,0 @@
## a code point greater than 255 is illegal in the character literal prefix fixed with b.
printf "[%c] [#x%x] [%d]\n" '★' '★' #x2605;
printf "[%c]\n" b'★'; ##ERROR: syntax error - wrong character literal

View File

@ -1,6 +0,0 @@
## #b can be followed by [ or binary digits.
printf "%O\n" #b[ 10 20 30 ];
printf "%010b\n" #b0101;
printf "%O\n" #bxy; ##ERROR: syntax error - neither valid radixed number nor valid directive #bxy

View File

@ -1 +0,0 @@
printf :*; ##ERROR: syntax error - prohibited in this context

View File

@ -1,3 +0,0 @@
defun :: fun1() { ##ERROR: syntax error - function name not symbol in defun
return 10;
};

View File

@ -1,3 +0,0 @@
defun :* fun1() { ##ERROR: syntax error - function name not symbol in defun
return 10;
};

View File

@ -1,6 +1,6 @@
set t ( set t (
class | x | { class | x | {
defun :* make() { set x 1234; return self; }; defun :* make() { x := 1234; return self; };
defun get-x() { return x }; defun get-x() { return x };
} }
); );
@ -16,11 +16,11 @@ if (nqv? t 1234) { printf "ERROR: t must be 1234\n" } \
else { printf "OK: t is %d\n" t }; else { printf "OK: t is %d\n" t };
set j #{ ((X:make):get-x): 9999, 4512: ((X: make): get-x) }; j := #{ ((X:make):get-x): 9999, 4512: ((X: make): get-x) };
set v (dic.get j 1234); v := (dic.get j 1234);
if (nqv? v 9999) { printf "ERROR: v is not 9999\n" } \ if (nqv? v 9999) { printf "ERROR: v is not 9999\n" } \
else { printf "OK: value is %d\n" v }; else { printf "OK: value is %d\n" v };
set v (dic.get j 4512); v := (dic.get j 4512);
if (nqv? v 1234) { printf "ERROR: v is not 1234\n" } \ if (nqv? v 1234) { printf "ERROR: v is not 1234\n" } \
else { printf "OK: value is %d\n" v }; else { printf "OK: value is %d\n" v };