#!/bin/sh

compiler=$LOCAL_PATH_PREFIX/compiler

. $compiler/scripts/test-utils.sh

fpp_check=$compiler/bin/fpp-check

update()
{
  args=$1
  infile=$2
  if test -n "$3"
  then
    outfile=$3
  else
    outfile=$infile
  fi
  $fpp_check $args $infile.fpp 2>&1 | remove_path_prefix > $outfile.ref.txt
}

for file in `find . -name '*.ref.txt'`
do
  rm $file
done

. ./tests.sh

# Default update ref
for t in $tests
do
  echo "
$t()
{
  update '' $t
}"
done > default-update-ref.sh
. ./default-update-ref.sh

if test -f update-ref.sh
then
  . update-ref.sh
fi

for t in $tests
do
  echo "updating ref output for $t"
  $t
done
