diff --git a/test.sh b/test.sh index e64af44..492c116 100755 --- a/test.sh +++ b/test.sh @@ -11,6 +11,9 @@ OUTDIR=$(mktemp --directory) trap "rm -rf '$OUTDIR'" EXIT run_solution() { + local solution=$1 + local input=$2 + if [[ -d "$solution" ]]; then if [[ -f "$solution/Cargo.toml" ]]; then cargo run --quiet --manifest-path "$solution/Cargo.toml" < "$input" @@ -36,11 +39,11 @@ run_solution() { } do_day() { - year=$1 - day=$2 + local year=$1 + local day=$2 - input=$year/data/day$day.input - expected=$year/data/day$day.expected + local input=$year/data/day$day.input + local expected=$year/data/day$day.expected for solution in "$year/day$day"/*; do echo -n "$solution... " @@ -54,8 +57,8 @@ do_day() { ;; esac - solution_output=$OUTDIR/${year}_$day.out - run_solution "$solution" > "$solution_output" + local solution_output=$OUTDIR/${year}_$day.out + run_solution "$solution" "$input" > "$solution_output" if ! diff -u "$expected" "$solution_output"; then echo FAIL @@ -75,7 +78,7 @@ do_day() { } do_year() { - year=$1 + local year=$1 for day in $(seq 1 25); do do_day "$year" "$day"