#!/bin/sh
# testjml -- run MJ and JML tests
#
# This will update if the -u flag is given, and not otherwise

USAGE='testjml [-n]
       testjml [-u]'

# no arguments?
if test $# -gt 1
then
	echo "$USAGE" >&2
	exit 1
fi

UPDATE=false
if test $# -eq 1
then
    case "$1" in
    -n)
    	UPDATE=false
    	shift
    	;;
    -u)
	UPDATE=true
	shift
	;;
    *)
    	echo "$USAGE" >&2
    	exit 1
    	;;
    esac
fi

# change the following if necessary, define them as environment variables
: ${JMLDIR="$HOME/JML2"}
: ${SOURCEMEFILE="$HOME/bin/jml-sourceme.sh"}

# You can just source one of example-developers-sourceme-X.sh first,
# or you can put the right one in "$SOURCEMEFILE"
if test -f "$SOURCEMEFILE"
then
    . "$SOURCEMEFILE"
fi

cd "$JMLDIR"

# clean up both JML and MJ
nice make spotless >/dev/null

cd ..

# update both
if $UPDATE
then
    for d in MJ JML2
    do
      cd $d; cvs -q update -d -P; cd ..
    done
fi

# for local iowa state users with the PLSL module, most should ignore this
if test -d PLSL/CVS
then
    if $UPDATE
    then
	cd PLSL; cvs -q update -d -P; cd ..
    fi
fi

# build both and their tests
cd MJ
nice make build buildtests >/dev/null
cd ../JML2
nice make build-then-jar >/dev/null

# now run all the tests, generate HTML and check all JML specifications
nice make ALLTESTS=1 JUNITFORJMLFLAGS=-R --no-print-directory test-everything runjmlh
## use the following if runjmlh above doesn't work for you
# nice make test-everything+

# Copyright (C) 2003-2005 Iowa State University
#
# This file is part of JML
#
# JML is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# JML is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with JML; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
