improve tester

This commit is contained in:
hugogogo
2026-05-14 13:24:53 +02:00
parent 3761adcf11
commit 7b5aa97c0c

View File

@@ -30,7 +30,8 @@ RESET="\e[0m"
NAME="computor"
BINARY="./$NAME"
#SKIP_REDUCED=true
SKIP_REDUCED=true
SKIP_SOLUTION=true
if [[ ! -x "$BINARY" ]]; then
@@ -61,6 +62,19 @@ run_test() {
expected=$(echo "$expected" | grep -v "Reduced form:")
fi
# If SKIP_SOLUTION is true, remove all lines after the 2nd line following "Polynomial degree:"
if [[ "$SKIP_SOLUTION" == "true" ]]; then
# Get the line number of "Polynomial degree:"
line_num=$(echo "$out" | grep -n "Polynomial degree:" | head -1 | cut -d: -f1)
if [[ -n "$line_num" ]]; then
# Keep lines up to 1 lines after "Polynomial degree:"
out=$(echo "$out" | head -n $((line_num + 1)))
expected=$(echo "$expected" | head -n $((line_num + 1)))
fi
fi
# If check_error is true, verify if the output contains an error message or non-zero exit code
if [[ "$check_error" == "error" ]]; then
if [[ $exit_code -ne 0 || "$out" == *"Error"* ]]; then