#!/bin/bash
# Copyright 1999-2002 Carnegie Mellon University.  
# Portions Copyright 2002 Sun Microsystems, Inc.  
# Portions Copyright 2002 Mitsubishi ElectricResearch Laboratories.
# All Rights Reserved.  Use is subject to license terms.
# 
# See the file "license.terms" for information on usage and
# redistribution of this file, and for a DISCLAIMER OF ALL 
# WARRANTIES.
#
#
# This is the main regressionTest script. This script can be run from
# a crontab entry.  The regression test performs the following
# functions:
#
# 	Retreives the S4 source from sourceforge
#	Build S4
#	Executes the tests
#	Generates a summary report and emails it to parties of interest
#	puts the log result back into the sourceforge repository
#
#
# usage: regressionTest [testName]
#


# S4 code will be checked out here. WARNING: This directory will be 
# completely removed when done 

testDir=./regressionTestDirectory$$

originalDir=`pwd`

mkdir -p $testDir

cd $testDir

# start loop to download code
success=0;
count=0;

while ((!$success)); do
# checkout the source
if ssvn sphinx4
then
success=1;
else
let count++;
if (($count>50)); then
# not successful, and we attempted it too many times. Clean up and leave.
cd $originalDir
rmdir $testDir
exit $count;
fi
fi
done

cd sphinx4/tests/regression

# make sure that the main test script is executable

chmod +x executeRegressionTest 

# run the tests

./executeRegressionTest $*

# clean up 

cd $originalDir

# remove the workspace when done
rm -rf $testDir
