competitive programming scripts on Linux
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
886 B

8 months ago
3 years ago
  1. #!/usr/bin/env bash
  2. PROG="Main"
  3. # compilation stage.
  4. javac $PROG.java
  5. if [ $? -ne 0 ]; then
  6. exit 1
  7. fi
  8. # diffing program output against actual output. (modified for java)
  9. for i in *.in; do
  10. name=`echo $i|sed "s/.in//"`
  11. echo -e "running test: $name \n"
  12. echo -e "INPUT:"
  13. cat $name.in
  14. echo -e "\nOUTPUT:"
  15. # clearing the .res files.
  16. if [ -f $name.res ]; then
  17. rm $name.res
  18. fi
  19. touch $name.res
  20. timeout 5s java $PROG < $name.in > $name.res
  21. if [ $? -eq 124 ]; then
  22. echo -e "time limit exceeded."
  23. rm -rf $name.res
  24. exit 1
  25. fi
  26. if [ $? -ne 0 ]; then
  27. exit 1
  28. fi
  29. cat $name.res
  30. if [ -f $name.out ]; then
  31. echo -e "ANSWER:"
  32. cat $name.out
  33. echo -e "\nDIFF:"
  34. diff $name.res $name.out
  35. fi
  36. echo "___________________________________"
  37. echo -e "\n"
  38. done
  39. exit 0