#!/bin/sh
# This script is a helper script for testing the molphy components
# It was written for the Debian GNU/Linux distribution by
# Andreas Tille <tille@debian.org>

echo Testing $1 ...
COMPARE=/usr/share/doc/molphy/examples/tests/compare

if [ _$1 = _ ] ; then
  echo Usage: $0 "<test-result-to-compare>"
  exit -1
fi

if [ ! -d $COMPARE ] ; then
   echo Broken installation.
   echo Directory $COMPARE with test results is missing.
   exit -1
fi

if [ ! -f $1 ] ; then
  echo $1 not found.
  exit -1
fi
  
if [ ! -f ${COMPARE}/$1 -a ! -f ${COMPARE}/$1.gz ] ; then
  echo Broken installation.
  echo File ${COMPARE}/$1 with test results is missing.
  exit -1
fi

## The first line contains the date the test was done so we have
## to delete it for comparison ...

if [ -f ${COMPARE}/$1 ] ; then
  sed "1d" ${COMPARE}/$1 > $1.comp
else
  zcat ${COMPARE}/$1 | sed "1d"  > $1.comp
fi

sed "1d" $1 > $1.test

diff $1.comp $1.test

if [ -f ${COMPARE}/$1-2.2 ] ; then
  echo Note: There where explictite differences to molphy version 2.2
  echo Please read ${COMPARE}/README.compare
fi
