Files

61 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# One-shot check for mini_serv:
# [1/3] strict compile (-Wall -Wextra -Werror)
# [2/3] behavioral tester (13 checks, offline)
# [3/3] the real exam-style Grademe diff
#
# Usage: bash tester/check.sh [path/to/mini_serv.c]
# Default source: sandbox/rendu/mini_serv/mini_serv.c
#
# Env: SKIP_GRADEME=1 -> stop after the behavioral tester
set -u
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SRC="${1:-$ROOT/sandbox/rendu/mini_serv/mini_serv.c}"
BIN="$ROOT/sandbox/mini_serv"
if [ ! -f "$SRC" ]; then
echo "No source file at: $SRC"
echo "Write your mini_serv.c there (exact filename matters), or pass a path."
exit 2
fi
echo "== [1/3] strict compile: cc -Wall -Wextra -Werror =="
mkdir -p "$ROOT/sandbox"
if ! cc -Wall -Wextra -Werror -g "$SRC" -o "$BIN"; then
echo "COMPILE FAILED."
exit 1
fi
echo "OK -> $BIN"
echo
echo "== [2/3] behavioral tester =="
if ! python3 "$ROOT/tester/mini_serv_tester.py" "$BIN"; then
echo
echo "Behavioral tests FAILED — fix and run again."
exit 1
fi
if [ "${SKIP_GRADEME:-0}" = "1" ]; then
echo
echo "SKIP_GRADEME=1 -> stopping here. All green so far."
exit 0
fi
echo
echo "== [3/3] grademe final boss (exact exam-style diff, ~25s) =="
cd "$ROOT/sandbox" || exit 1
rm -f traceback .system/grading/passed
bash .system/grading/tester.sh
if [ -f .system/grading/passed ]; then
echo "GRADEME: PASSED"
echo
echo "ALL GREEN. Now: close this, start from a blank file, and do it again."
else
echo "GRADEME: FAILED"
echo "See sandbox/traceback (expected vs your output). First lines:"
if [ -f traceback ]; then
sed -n '1,40p' traceback
fi
exit 1
fi