#!/bin/sh

. ../../../scripts/test-utils.sh

fpp_format=../../../bin/fpp-format

update()
{
  args=$1
  infile=$2
  if test -n "$3"
  then
    outfile=$3
  else
    outfile=$infile
  fi
  $fpp_format $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

escaped_strings()
{
  update '' escaped_strings
}

no_include()
{
  update '' syntax no_include
}

include()
{
  update '-i' syntax include
}

kwd_names()
{
  update '' kwd_names
}

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