test.sh: run all years
This commit is contained in:
parent
e271b0d585
commit
bb0fbc0f8f
1 changed files with 25 additions and 12 deletions
37
test.sh
37
test.sh
|
@ -4,9 +4,11 @@ set -euo pipefail
|
|||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
YEAR=2020
|
||||
COMMON_DIR="$(realpath common)"
|
||||
export COMMON_DIR
|
||||
|
||||
export COMMON_DIR="$(realpath common)"
|
||||
OUTDIR=$(mktemp --directory)
|
||||
trap "rm -rf '$OUTDIR'" EXIT
|
||||
|
||||
run_solution() {
|
||||
if [ -d "$solution" ]; then
|
||||
|
@ -33,13 +35,14 @@ run_solution() {
|
|||
fi
|
||||
}
|
||||
|
||||
shopt -s dotglob nullglob
|
||||
do_day() {
|
||||
year=$1
|
||||
day=$2
|
||||
|
||||
for n in $(seq 1 25); do
|
||||
input=$YEAR/data/day$n.input
|
||||
expected=$YEAR/data/day$n.expected
|
||||
input=$year/data/day$day.input
|
||||
expected=$year/data/day$day.expected
|
||||
|
||||
for solution in "$YEAR/day$n"/*; do
|
||||
for solution in "$year/day$day"/*; do
|
||||
echo -n "$solution... "
|
||||
|
||||
case "${solution##*/}" in
|
||||
|
@ -48,9 +51,7 @@ for n in $(seq 1 25); do
|
|||
continue
|
||||
esac
|
||||
|
||||
solution_output=$(mktemp)
|
||||
trap "rm -f '$solution_output'" EXIT
|
||||
|
||||
solution_output=$OUTDIR/${year}_$day.out
|
||||
run_solution "$solution" > "$solution_output"
|
||||
|
||||
if ! diff -u "$expected" "$solution_output"; then
|
||||
|
@ -67,7 +68,19 @@ for n in $(seq 1 25); do
|
|||
else
|
||||
echo ok
|
||||
fi
|
||||
|
||||
rm "$solution_output"
|
||||
done
|
||||
}
|
||||
|
||||
do_year() {
|
||||
year=$1
|
||||
|
||||
for day in $(seq 1 25); do
|
||||
do_day "$year" "$day"
|
||||
done
|
||||
}
|
||||
|
||||
shopt -s dotglob nullglob
|
||||
|
||||
for year in 2020 2021 2022; do
|
||||
do_year "$year"
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue