#!/bin/sh
#
# tp-selftest.sh - Script to run TxlProp on all its own modules
#  -- (C) 2005 Jonathan Yavner
#

# Exit from loop on user interrupt
trap 'rm -f tp_output4.xml; exit 1' INT

# Directory where our files are
mydir=${0%tp-selftest.sh}

mkdir -p SelfTest

for x in parse/wacky.Txl mark/loopy.Txl assert/dopey.Txl; do
    echo ""
    echo ">>>>>>>>>>>>>>>>>>>> $x"
    base0=SelfTest/`basename $x`
    base=`echo $base0 | sed 's/.Txl//'`
    echo "==parse=="
    parse/tpp-run.sh $x >$base-parse.xml
    echo "==mark=="
    mark/tpm-run.sh -css="../tp-format.css" $base-parse.xml >$base-mark.xml
    echo "==assert=="
    assert/tpa-run.sh $base-mark.xml > tp_output4.xml
    echo "==tp-final=="
    txl -q tp_output4.xml tp-final.Txl >$base-assert.xml
    rm tp_output4.xml
done

for x in parse/tpp-*.Txl mark/tpm-*.Txl assert/tpa-*.Txl tp-final.Txl; do
    if [ "$x" = "parse/tpp-toxml.Txl" ]; then
	echo "%This file would contain pragmas of target program" >parse/tpp_parse1.tmp
	echo "%This file would contain compounds and tokens of target program" >parse/tpp_parse2.tmp
    fi
    echo ""
    echo ">>>>>>>>>>>>>>>>>>>> $x"
    ${mydir}tp-run.sh -css="../tp-format.css" $x >SelfTest/`echo $x | sed -e s'=.*/==' -e 's/Txl$/xml/'`
    if [ "$x" = "parse/tpp-toxml.Txl" ]; then
	rm parse/tpp_parse[12].tmp
    fi
done

cp parse/tpp-format.css SelfTest/
