Introduce a test for template.sh

This commit is contained in:
Pierre Pronchery 2019-09-14 04:03:14 +02:00
parent e864e312eb
commit 010dec9b0e
4 changed files with 27 additions and 6 deletions

View File

@ -25,8 +25,9 @@
#variables
CONFIGSH="${0%/template.sh}/../config.sh"
CONFIGSH="${0%/template.sh}/../../config.sh"
PREFIX="/usr/local"
DATABASEDIR="../data"
PROGNAME="template.sh"
#executables
DEBUG="_debug"
@ -52,16 +53,22 @@ _template()
target="$1"
ext="${target##*.}"
subject="${target##* - }"
subject="${target##*-}"
subject="${subject%%.*}"
database="../data/$subject.db"
database="$DATABASEDIR/$subject.db"
if [ "$subject" = "$target" -o "$subject" = "${target%%.*}" ]; then
_error "$target: No subject found for target"
return $?
fi
if [ ! -f "$database" ]; then
_error "$subject: No database found for subject"
return $?
fi
source="${target%% - *}.$ext.in"
source="${target%%-*}.$ext.in"
[ -f "$source" ] || source="${source#$OBJDIR}"
if [ ! -f "$source" ]; then
_error "$source: Could not find source"
return $?
fi
case "$ext" in
html|md|rst|txt)

View File

@ -1,5 +1,5 @@
targets=clint.log,coverage.log,fixme.log,htmllint.log,phplint.log,pylint.log,shlint.log,tests.log,xmllint.log
dist=Makefile,tests.sh,binary/project.conf,binary/Makefile.Darwin,binary/Makefile.DeforaOS,binary/Makefile.NetBSD,binary/Makefile.Windows,command/project.conf,command/Makefile.NetBSD,include/project.conf,include/Makefile.NetBSD,java/project.conf,java/Makefile.NetBSD,library/project.conf,library/Makefile.Darwin,library/Makefile.Linux,library/Makefile.NetBSD,library/Makefile.Windows,libtool/project.conf,libtool/Makefile.Darwin,libtool/Makefile.Linux,libtool/Makefile.NetBSD,libtool/Makefile.Windows,object/project.conf,object/Makefile.NetBSD,package/project.conf,package/Makefile.NetBSD,package/config.h.NetBSD,package/config.sh.NetBSD,plugin/project.conf,plugin/Makefile.Darwin,plugin/Makefile.NetBSD,script/project.conf,script/Makefile.NetBSD,verilog/project.conf,verilog/Makefile.NetBSD
targets=clint.log,coverage.log,fixme.log,htmllint.log,phplint.log,pylint.log,shlint.log,template-test.md,tests.log,xmllint.log
dist=Makefile,template.md.in,test.db,tests.sh,binary/project.conf,binary/Makefile.Darwin,binary/Makefile.DeforaOS,binary/Makefile.NetBSD,binary/Makefile.Windows,command/project.conf,command/Makefile.NetBSD,include/project.conf,include/Makefile.NetBSD,java/project.conf,java/Makefile.NetBSD,library/project.conf,library/Makefile.Darwin,library/Makefile.Linux,library/Makefile.NetBSD,library/Makefile.Windows,libtool/project.conf,libtool/Makefile.Darwin,libtool/Makefile.Linux,libtool/Makefile.NetBSD,libtool/Makefile.Windows,object/project.conf,object/Makefile.NetBSD,package/project.conf,package/Makefile.NetBSD,package/config.h.NetBSD,package/config.sh.NetBSD,plugin/project.conf,plugin/Makefile.Darwin,plugin/Makefile.NetBSD,script/project.conf,script/Makefile.NetBSD,verilog/project.conf,verilog/Makefile.NetBSD
[clint.log]
type=script
@ -37,6 +37,12 @@ type=script
script=../doc/scripts/shlint.sh
depends=../doc/scripts/appbroker.sh,../doc/scripts/clint.sh,../doc/scripts/coverage.sh,../doc/scripts/docbook.sh,../doc/scripts/fixme.sh,../doc/scripts/gettext.sh,../doc/scripts/gtkdoc.sh,../doc/scripts/htmllint.sh,../doc/scripts/markdown.sh,../doc/scripts/phplint.sh,../doc/scripts/pkgconfig.sh,../doc/scripts/platform.sh,../doc/scripts/pylint.sh,../doc/scripts/shlint.sh,../doc/scripts/subst.sh,../doc/scripts/template.sh,../doc/scripts/xmllint.sh,tests.sh
[template-test.md]
type=script
script=../doc/scripts/template.sh
flags=-O DATABASEDIR=.
depends=template.md.in,test.db,../doc/scripts/template.sh,../config.sh
[tests.log]
type=script
script=./tests.sh

7
tests/template.md.in Executable file
View File

@ -0,0 +1,7 @@
Template test
=============
Test result
-----------
This test is @@SUBST@@.

1
tests/test.db Normal file
View File

@ -0,0 +1 @@
SUBST=OK