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