#! /bin/sh

/bin/rm -f test.*
/bin/rm -f test-*

rc=0

for x in infiles/* ; do
  file=`basename $x`
  ../src/pmw -norc -F ../fontmetrics -H ../PSheader -MF ../psfonts \
    -incPMWfont -o test.ps infiles/$file

  # These two commands cause warnings on Linux because you are supposed to
  # use "-n +4" instead, but -n isn't supported by Solaris' "tail".  
  # tail +4 test.ps >test.ps.3
  # tail +4 outfiles/$file.ps >test.out.3
  
  # So we do it this rather contorted way instead
  (head -n 3 >/dev/null; cat >test.ps.3) <test.ps
  (head -n 3 >/dev/null; cat >test.out.3) <outfiles/$file.ps 
 
  diff -u test.ps.3 test.out.3 >test.diff 
  if [ $? != 0 ] ; then
    mv test.diff test-$file.diff 
    echo "*** $file test failed - see test-$file.diff ***"
    rc=1 
  else
    echo $file test succeeded
  fi         
done   

/bin/rm test.*
exit $rc

# End
