mirror of
https://github.com/xlucn/PAT.git
synced 2026-10-24 22:52:39 +08:00
26 lines
945 B
Bash
26 lines
945 B
Bash
#!/bin/sh
|
|
mkdir -p temp
|
|
trap 'rm -r temp' EXIT QUIT TERM INT
|
|
tracked_files=$(git ls-tree --name-only HEAD PAT*/)
|
|
for bin in "$@"; do
|
|
[ "$tracked_files" = "${tracked_files%$bin*}" ] && continue
|
|
dir=$(dirname "$bin")
|
|
id=$(basename "$bin")
|
|
[ "$dir" = PATAdvanced ] && cat=a
|
|
[ "$dir" = PATBasic ] && cat=b
|
|
[ "$dir" = PATTop ] && cat=t
|
|
for sample in "samples/$cat$id-"*.in; do
|
|
echo "testing $bin, sample $sample"
|
|
printf "%s" "$("$dir/$id" < "$sample" | tr -d '\0')" > temp/out
|
|
printf "%s" "$(cat "${sample%.in}.out")" > temp/ans
|
|
diff temp/out temp/ans || failed="$failed$bin $sample\n"
|
|
done
|
|
done
|
|
if [ -n "$failed" ]; then
|
|
printf "$failed" | while read -r b s; do
|
|
printf "\033[1;31m%s failed for sample %s\033[1;0m\n" "$b" "$s"
|
|
done
|
|
printf "\033[1;31mSee the previous output for differences between correct output and execute output\033[1;0m\n"
|
|
exit 1
|
|
fi
|