#!/usr/bin/env bash

# Assumes $testdir has a directory "in" containing a sub-directory
# for each test case. Each subdirectory has files:
#    .desc  - description of test case 
#    .value - value of test case
#    in.txt - input file
# Also assumes $testdir contains a plain-text file called mark-scheme which
# contains a marking scheme for TAs.
#
# Assumes students have submitted a number of files ending in .java.
# The provided files include a Main.java for a testing harness that
# reads input and takes appropriate action(s).
#
# Authors/modifiers: 
#   Brandon Grasley, Margareta Ackerman, Cressa Adamson, Dave Chodos, Chris Almost, Jenny Kim, Terry Vaskor


# Link in student submission.
# Make sure we don't match a literal file '*.java' unless it exists.
for file in "$submitdir"/*.java; do
   ln -fs "$file" "$tmpdir"
done

# Then link in provided java files.
# This assumes that provided files should overwrite submitted files unconditionally.
for file in "$testdir"/provided/*.java; do
   ln -fs "$file" "$tmpdir"
done


# If student submission compiles, try testing it
# If it doesn't compile, compile errors are captured in javac.out
if javac *.java > javac.out 2>&1; then
   rm javac.out

   for tstpath in "$testdir"/in/*; do

      # link in test inputs 
      ln -fs "$tstpath"/in.txt . 

      tst="$(basename "$tstpath")"

      # execute test driver - capture output:
      echo "Running test $tst"
      timeout -t 20 -- java Main < in.txt >"$tst".result 2>"$tst".err

      if [ -s "$tst".err ]; then
         echo '  error output generated'
      fi
   done
else
   echo "Compilation errors; aborting test run for $student"
fi

echo 'Done runTests'
Topic revision: r1 - 2016-01-11 - YiLee
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback