#!/bin/sh

echo "Test script for WinDOH project checkpoint submission."
echo "Notify hayest@cs if this script does not work correctly."
echo "Still in testing; more functionality coming later."
echo
WHOIAM=`whoami`
echo 'You should have copied a file named '$WHOIAM'.jar into the handin directory.'
echo

echo 'Creating and moving to /tmp/'$WHOIAM'1234'
mkdir '/tmp/'$WHOIAM'1234'
cd '/tmp/'$WHOIAM'1234'
echo 'Making copy of your submission.'
cp '/stage/classes/current/cspp535/handin/'$WHOIAM'.jar' .
echo 'Listing your submitted files.  Make sure all your source code is here'
echo '$ jar -tf '$WHOIAM'.jar'
jar -tf $WHOIAM'.jar'
if [ 0=0 ] 
    then
        echo 'java -jar '$WHOIAM'.jar'
        echo 'Check to make sure your app runs from the java -jar command.' 
        echo 'Don't worry if it doesn't find all your icons and other non-class files.'
        java -jar $WHOIAM'.jar'
        echo 'jar -xvf '$WHOIAM'.jar'
        jar -xvf $WHOIAM'.jar'
        echo 'java' `gawk '/Main-Class:/{print $2}' mainClass`
	echo 'This time everything should work as you want it to.'
	java `gawk '/Main-Class:/{print $2}' mainClass`            
	echo 'Cleaning up temporary files.'
	rm -rf '/tmp/'$WHOIAM'1234'
	echo 'Submission testing finished.  Please fix any problems and resubmit if necessary.'
    else
        echo 'Not prepared to test your submission yet.  Please try again soon'
	echo 'Meanwhile, here is the listing of the .class files you created.'
	ls -l *.class
        echo 'Deleting temporary files.'
        rm -rf '/tmp/'$WHOIAM'1234'  
fi
