#!/bin/sh
#This file is under the license in ../LICENSE.

export PAPERSIZE=a4
failed=""

run_test() {
param=regression/$1.param
test=regression/$1.test
./scripts/stx2any `test -f $param && cat $param` -T $2 $test | \
diff -u regression/$1.$2 - || failed="$failed $1($2)"
}

for i in regression/*.test; do
	echo Running $i ...
	base=`basename $i .test`
	for fmt in html man latex docbook-xml; do
		run_test $base $fmt
	done
done

for i in regression/*.strip_stx; do
	echo Running $i ...
	base=`basename $i .strip_stx`
	./scripts/strip_stx `cat $i` | \
	diff -u regression/$base.stripped - || failed="$failed strip_stx($base)"
done

for i in regression/*.gather_stx_titles; do
	echo Running $i ...
	base=`basename $i .gather_stx_titles`
	./scripts/gather_stx_titles `cat $i` regression/*.test | \
	diff -u regression/$base.titles - || failed="$failed gather_stx_titles($base)"
done

test -n "$failed" && echo Failed tests: $failed
test -z "$failed"

