#!/usr/bin/env bash

# This script runs twisted trial against sage.dsage, returns 
# 1 if any tests fail and 0 if all tests pass

if [ -z "$SAGE_TESTDIR" ]; then
    SAGE_TESTDIR="$SAGE_ROOT/tmp"
fi

if [ ! -d "$SAGE_TESTDIR/"  ]; then
    echo "tmp directory doesn't exist - creating ...";
    mkdir "$SAGE_TESTDIR/";
fi 

if [ ! -d "$SAGE_TESTDIR/dsage-trial"  ]; then
    echo "dsage-trial tmp directory doesn't exist - creating ...";
    mkdir "$SAGE_TESTDIR/dsage-trial";
fi 

echo "This script will run the unit tests for DSage"
trial --temp-directory="$SAGE_TESTDIR/dsage-trial"  sage.dsage

if [ $? != 0 ]; then
    echo "However, an ERROR occurred in the Distributed Sage unit tests."
fi 
