#!/bin/sh

TESTFILES="Makefile.am scanner.l parser.y .cvsignore test.input"

if [ ! $# -eq 1 ] ; then
   echo 1>&2 Usage: $0 test-name
   exit 1
fi

if test -e "$1" ; then
    echo 1>&2 "$1 exists already"
    exit 1
fi

mkdir $1 
if test "$?" -ne 0 ; then
    echo 1>&2 "mkdir $1 failed"
    exit 1
fi

for i in $TESTFILES ; do
    cp TEMPLATE/$i $1/$i
done

echo "$1" >> "$1"/.cvsignore

sed -i '/--new-test-here--/i\
tests/'"$1"'/Makefile' ../configure.in

sed -i '/^\(DIST_\)\?SUBDIRS/a\
	'"$1"' \\' Makefile.am

sed -i "s:TEMPLATE:$1:g" "$1"/Makefile.am
