#! /usr/local/bin/tcsh -f

goto startScript

usage:
echo
echo  usage:  runTests.sh \[ids\*\]
echo  ""
echo  examples:                                                          
echo  runTests.sh
echo  runTests.sh ian clements greiner
echo  ""
echo  A script to run the indicated user\'s connect5 program
echo  on the test cases in Connect5/Tests/98spring/.
echo  If no users given, the default is all studnets listed in the file Connect5/roll
echo  ""
exit



#################
startScript:
################
if ($#argv >= 1) then
  if ("$argv[1]" == "help" || "$argv[1]" == "-help")    goto usage
  endif






set debug = 0

set mainDir  = /home/comp210/Assignments/Connect5
set testDir  = $mainDir/Tests/98spring
set testFiles = $testDir/*
set rollFile = $mainDir/roll
set roll     = `cat $rollFile`
set progName = "connect5"
set studentPathToProg = comp210/connect5

set mzschemeStart =  "mzscheme -l macro.ss -l functioc.ss -q -m -r"

if ($#argv == 0) then
  set names = "$roll"
else
  set names = "$argv"
  endif

foreach s ($names)
  echo ""
  echo \*\*\* $s \*\*\*
  set sProg = /home/$s/$studentPathToProg/$progName
  if (-r $sProg.ss) then
     set sProg   = $sProg.ss
     set execute = "$mzschemeStart $sProg"
  else
     set execute = $sProg
     endif
  if ($debug) echo Execute line is $execute
  
  foreach tf ($testFiles)
    if ($tf:e == out) continue
    echo -n $tf:t
    set output = `$execute < $tf`
    set desiredOutput = `cat $tf.out`
    if ("$output" != "$desiredOutput") echo -n "  "\#Output $output, but correct answer is $desiredOutput.
    echo ""
    end
  end
