#!/bin/sh

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

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

compare()
{
  outfile=$1
  diff -u $outfile.ref.txt $outfile.out.txt > $outfile.diff.txt 2>&1
}

run_test()
{
  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.out.txt
  compare $outfile
}

. ./tests.sh

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

include()
{
  run_test '-i' syntax include && \
    $fpp_syntax include.out.txt
}

kwd_names()
{
  run_test '' kwd_names && \
    $fpp_syntax kwd_names.out.txt
}

no_include()
{
  run_test '' syntax no_include && \
    $fpp_syntax no_include.out.txt
}

run_suite $tests
