Skip to content

Instantly share code, notes, and snippets.

@felipecustodio
Last active May 14, 2018 18:55
Show Gist options
  • Select an option

  • Save felipecustodio/4342953977dc95124f6708c7510626b0 to your computer and use it in GitHub Desktop.

Select an option

Save felipecustodio/4342953977dc95124f6708c7510626b0 to your computer and use it in GitHub Desktop.
Run all .in test cases in tests/ folder, output to .out and compare. Useful for college assignments that provide lots of test cases with the expected outputs, like assignments on the run.codes website.
#!/bin/bash
shopt -s nullglob
for ext in .in; do
files=(tests/*"$ext")
printf 'number of %s files: %d\n' "$ext" "${#files[@]}"
for i in `seq 1 ${#files[@]}`; do
rm results$i.out;
printf "\nRunning test $i\n";
your program < tests/$i.in 2>&1 | tee tests/results$i.out;
# vimdiff tests/results$i.out tests/$i.out;
diff tests/results$i.out tests/$i.out;
printf ".....................\n";
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment