makeTest.bash
#!/bin/bash

#***************************************************************************************************
#                                                                                                  *
# makeTest.bash: highest level test driver of siliconBrain                                         *
#                                                                                                  *
#***************************************************************************************************

#***************************************************************************************************
#                                                                                                  *
#     Copyright (C) 2003, 2004 Joerg Kunze                                                         *
#                                                                                                  *
#     This file is part of siliconBrain.                                                           *
#                                                                                                  *
#     siliconBrain is free software; you can redistribute it and/or modify                         *
#     it under the terms of the GNU General Public License as published by                         *
#     the Free Software Foundation; either version 2 of the License, or                            *
#     (at your option) any later version.                                                          *
#                                                                                                  *
#     siliconBrain is distributed in the hope that it will be useful,                              *
#     but WITHOUT ANY WARRANTY; without even the implied warranty of                               *
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                *
#     GNU General Public License for more details.                                                 *
#                                                                                                  *
#     You should have received a copy of the GNU General Public License                            *
#     along with this program; if not, write to the Free Software                                  *
#     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                    *
#                                                                                                  *
#***************************************************************************************************
siliconBrainRelease='$siliconBrainRelease: 0.2.3 $'
siliconBrainRcsIdentifier='$Id: makeTest.bash,v 1.57 2004/12/14 23:31:26 joerg Exp $'
siliconBrainSaveStamp='$siliconBrainSaveStamp: 2004/12/14 22:26:05, Joerg Kunze$'

web=$PWD/distribution/documentation/web
sourceRoot=$PWD/
targetRoot=$web/sourceTree/

#--------------------------------------------------------------------------------------------------#
echo "makeTest: setting up new project \`myProject' ..."
#--------------------------------------------------------------------------------------------------#

packageName=myProject

export siliconBrainPath=$PWD/distribution
. $siliconBrainPath/setEnvironment

cd /tmp

#--------------------------------------------------------------------#
# Normally the `/tmp' dir is deleted time and again. So the complete #
# test is performed a number of times. But to save time during the   #
# compilation after each change, we delte just a few files. Thus not #
# all the things have to be remade each time `make' is called.       #
#--------------------------------------------------------------------#
rm --force myProject/*.c
rm --force myProject/temporary/commands.texinfo
rm --force myProject/temporary/*.c
rm --force myProject/temporary/authors.snippet.texinfo.d
rm --force myProject/temporary/myProject.specification
rm --force myProject/distribution/programs/*
mkdir --parents myProject
cd myProject

echo "export siliconBrainPath=$siliconBrainPath" >  makefile
echo "include $siliconBrainPath/makefile"        >> makefile

newTest

returnCode=$?

if [ $returnCode -ne 0 ]; then
   echo "makeTest: error in \`newTest'!"
   exit $returnCode
fi

#--------------------------------------------------------------------------------------------------#
echo "makeTest: checking for generated directory structure ..."
#--------------------------------------------------------------------------------------------------#
for directory in temporary documentation distribution distribution/documentation/web/sourceTree; do
   if [ ! -d "$directory" ]; then
      echo "makeTest: directory \"$directory\" does not exist or is not a directory." >&2
      exit 42
   fi
done

#--------------------------------------------------------------------------------------------------#
echo "makeTest: checking for generated files ..."
#--------------------------------------------------------------------------------------------------#
function checkStandardFile {
   echo "makeTest:   check: \"$*\""
   for standardFile in $*; do
      if [ ! -f "$standardFile" ]; then
         echo "makeTest: file \"$standardFile\" dos not exist or is not a file." >&2
         exit 42
      fi
   done
}

checkStandardFile AUTHORS COPYING COPYING.DOC ChangeLog INSTALL INTRODUCTION NEWS README RELEASE TODO
checkStandardFile documentation/install.snippet.texinfo
checkStandardFile documentation/myProject.main.texinfo
checkStandardFile distribution/data/introduction.snippet.text distribution/documentation/myProject.info
checkStandardFile distribution/documentation/myProject.dvi  distribution/documentation/web/gnuGpl.include.texinfo

#--------------------------------------------------------------------------------------------------#
echo "makeTest: try rebuild of *.dvi after deletion ..."
#--------------------------------------------------------------------------------------------------#
rm --force distribution/documentation/myProject.dvi
make all > /dev/null 2> /dev/null
checkStandardFile distribution/documentation/myProject.dvi

#--------------------------------------------------------------------------------------------------#
echo "makeTest: template based file should *not* be remade after update of isInitialized ..."
#--------------------------------------------------------------------------------------------------#
touch temporary/isInitialized
if make 2> /dev/null | grep --count template > /dev/null  ;then
   echo "makeTest: templates are to be remade after touch to isInitialized!" >&2
   exit 42
fi

#--------------------------------------------------------------------------------------------------#
echo "makeTest: test whether change in snippet changes capital file ..."
#--------------------------------------------------------------------------------------------------#
{
   echo
   echo "aStrangeText12345"
   echo
} >> documentation/shortDescription.snippet.texinfo

make all > /dev/null 2> /dev/null

if ! grep --quiet "aStrangeText12345" distribution/data/readme.snippet.text; then
   echo "makeTest: \`readme.snippet.text' has not been updated!" >&2
   exit 42
fi

if ! grep --quiet "aStrangeText12345" README; then
   echo "makeTest: \`README' has not been updated!" >&2
   exit 42
fi

if ! grep --quiet "aStrangeText12345" distribution/data/readme.snippet.html; then
   echo "makeTest: \`readme.snippet.html' has not been updated!" >&2
   exit 42
fi

#--------------------------------------------------------------------------------------------------#
echo "makeTest: check usage environement ..."
#--------------------------------------------------------------------------------------------------#
formatHeader "#"                        \
   "$siliconBrainRelease"               \
   "siliconBrainInstall"                \
   "$siliconBrainSaveStamp"             \
   "temporary script to test output of the siliconBrainInstall program" \
   "$siliconBrainRelease"               \
   "$siliconBrainRcsIdentifier"         \
   "$siliconBrainSaveStamp" > temporary/profileExtension

./siliconBrainInstall >> temporary/profileExtension 2> /dev/null

source temporary/profileExtension

testUsageEnvironment

returnCode=$?

if [ $returnCode -ne 0 ]; then
   echo "makeTest: error in \`testUsageEnvironment'!"
   exit $returnCode
fi

#--------------------------------------------------------------------------------------------------#
echo "makeTest: removing all generated file ..."
#--------------------------------------------------------------------------------------------------#
cd ..
# rm --force --recursive myProject

exit 0

# $Log: makeTest.bash,v $
# Revision 1.57  2004/12/14 23:31:26  joerg
# published for new release 0.2.3
#
# Revision 1.56  2004/12/14 23:17:05  joerg
# published for new release 0.2.2
#
# Revision 1.55  2004/12/14 22:42:23  joerg
# allFiles: all sources have a Log CVS keyword at the end now.
#