echo off
set P=drawphase2
if not exist %1% (
    echo # %0%: %1% should be a zip file
    exit /b
)
rmdir/s/q Test
mkdir Test
copy %1% Test
cd Test
jar xf %1%
if not exist %P%.jjt (
    echo # %0%: %P%.jjt should exist in the zip file
    cd ..
    exit /b
)
del/q *.class *.jj %P%.java
echo # %0%: JJTree called for %P%.jjt
call jjtree %P%.jjt
echo # JJTree called for %P%.jjt
if not exist %P%.jj (
    echo # %0%: expected file %P%.jj to be created
    cd ..
    exit /b
)
echo # %0%: JavaCC called for %P%.jj
call javacc %P%.jj
if not exist %P%.java (
    echo # %0%: expected file %P%.java to be created
    cd ..
    exit /b
)
echo # %0%: JavaC called for %P%.java
javac %P%.java
if not exist %P%.class (
    echo # %0%: expected file %P%.class to be created
    cd ..
    exit /b
)
echo # %0%: Java called for %P% for test cases
java %P% < ..\Ref\LineTest.svgd > LineTest.svg
java %P% < ..\Ref\JuggleBW.svgd > JuggleBW.svg
java %P% < ..\Ref\Juggle.svgd > Juggle.svg
java %P% < ..\Ref\TestBW.svgd > TestBW.svg
echo # %0%: Test cases processed : See %P%.html for results
cd ..
exit /b
