#! /bin/csh

set dest = /p/course/cs367-hasti/handin

# change the directory below to the directory you will be grading in
set gradeDir = /p/course/cs367-hasti/private/p4gradingDir

set gradingDir = /p/course/cs367-common/public/html/assignments/p4/grading/

foreach student ( $1 )

  # removes previous student's files in preparation for this student
  cd $gradeDir
  rm -f *.java
  rm -f *.txt

  set student = $student:t
  set outFile = $student.txt

  cd $dest/$student/P4/
  echo $student

  if (-e HashTable.java) then
    cp $dest/$student/P4/HashTable.java $gradeDir
    cp $dest/$student/P4/*.txt $gradeDir
	cp $gradingDir/HashTableTester.java $gradeDir
    cd $gradeDir
    echo "Testing: " > $outFile
    echo $student >> $outFile
    javac *.java

    # run test and compare to expected output
    java HashTableTester > temp.txt
	diff -b temp.txt $gradingDir/testerOutput.txt  >> $outFile
	rm -f temp.txt
    rm -f *.class
  endif
end
