#!/bin/sh
#
# VNPForth - Compiled native Forth for IA32 Linux systems
# Copyright (C) 2001  Simon Baldwin (simonb@caldera.com)
#
# This program 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
# of the License, or (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

#
# Wrapper for running a set of compiler tests.  This wrapper runs each
# test, checking that the compiler returns FAIL for each.
#
REPORT="$1"
shift
TESTS="$*"

# Delete any old report file.
rm -f $REPORT

# Run each test file through the compiler.
echo "$0: Running compile tests..."
for file in $TESTS; do

	# Compile the file.  If the compilation does not fail, as we
	# expect it to, exit with code 1.
	echo "$0: compiling $file..." >>$REPORT
	echo -n "$file "
	../compiler/forthc $file >>$REPORT 2>&1
	cstatus=$?

	# Check that the compile did not succeed.
	if [ $cstatus -ne 1 ]; then
		echo "$0: Compile returned unexpected status $cstatus" >>$REPORT
		echo ""
		echo "$0: Compile returned unexpected status $cstatus" >&2
		exit 1
	fi

	echo "$0: Compile returned status $cstatus, which is expected" >>$REPORT
	echo "" >>$REPORT
done
echo "$0: Done."

# Return success.
exit 0
