#! /bin/csh
#
# shell script for testing one student's program 3
# KeyWord and ArrayHeap classes
#

# location of files provided to the students (that they don't change)
set providedFiles = /p/course/cs367-hasti/public/html/assignments/p3/files

# location of test files
set testFiles = /p/course/cs367-hasti/public/html/assignments/p3/grading/testFiles

# location of solution files
set solnFiles = /p/course/cs367-hasti/public/html/assignments/p3/solution

if ($#argv == 0) then
        echo Usage: $0 directory
        exit 1
endif

if (-e $1) else
  echo "$1" does not exist
  exit
endif

# copy student's files into JAVA subdirectory
cd $argv[1]
mkdir JAVA

cp $providedFiles/Prioritizable.java JAVA/
cp $providedFiles/PriorityQueueADT.java JAVA/

if (-e *2014*KeyWord.java) then
	cp *2014*KeyWord.java JAVA/KeyWord.java
	if (-e *2014*ArrayHeap.java) then
		cp *2014*ArrayHeap.java JAVA/ArrayHeap.java
	else
		echo "ArrayHeap.java missing or misnamed"
		exit
	endif
else
	echo "KeyWord.java missing or misnamed"
	exit
endif

# copy test files
cp $testFiles/KeyWordTester.java JAVA/
cp $testFiles/HeapTester.java JAVA/
cp $testFiles/PriorityInt.java JAVA/

# compile all code
cd JAVA/
javac *.java

# test the student's KeyWord
echo "--- test KeyWord ---"
java KeyWordTester

# test the student's ArrayHeap 
echo "--- test ArrayHeap ---"
java HeapTester

# wrap up
echo "--- check source code for style and documentation ---"
echo "--- check ArrayHeap.java array sizes ---"

rm -f *.class
