1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2026-01-26 21:41:34 +03:00

tests: Move tests for executables to separate script

Move tests for xmllint shell and xmlcatalog to separate scripts and
enabled them in Autotools.
This commit is contained in:
Nick Wellnhofer
2024-06-22 03:28:27 +02:00
parent 2d96adb27b
commit f06fc933cd
3 changed files with 127 additions and 64 deletions

70
test/catalogs/test.sh Executable file
View File

@@ -0,0 +1,70 @@
#!/bin/sh
set -e
echo "## Catalog regression tests"
if [ -n "$1" ]; then
xmlcatalog=$1
else
xmlcatalog=./xmlcatalog
fi
exitcode=0
for i in test/catalogs/*.script ; do
name=$(basename $i .script)
xml="./test/catalogs/$name.xml"
if [ -f $xml ] ; then
if [ ! -f result/catalogs/$name ] ; then
echo New test file $name
$xmlcatalog --shell $xml < $i 2>&1 > result/catalogs/$name
else
$xmlcatalog --shell $xml < $i 2>&1 > catalog.out
log=$(diff result/catalogs/$name catalog.out)
if [ -n "$log" ] ; then
echo $name result
echo "$log"
exitcode=1
fi
rm catalog.out
fi
fi
done
for i in test/catalogs/*.script ; do
name=$(basename $i .script)
sgml="./test/catalogs/$name.sgml"
if [ -f $sgml ] ; then
if [ ! -f result/catalogs/$name ] ; then
echo New test file $name
$xmlcatalog --shell $sgml < $i > result/catalogs/$name
else
$xmlcatalog --shell $sgml < $i > catalog.out
log=$(diff result/catalogs/$name catalog.out)
if [ -n "$log" ] ; then
echo $name result
echo "$log"
exitcode=1
fi
rm catalog.out
fi
fi
done
# Add and del operations on XML Catalogs
$xmlcatalog --create --noout mycatalog
$xmlcatalog --noout --add public Pubid sysid mycatalog
$xmlcatalog --noout --add public Pubid2 sysid2 mycatalog
$xmlcatalog --noout --add public Pubid3 sysid3 mycatalog
diff result/catalogs/mycatalog.full mycatalog
$xmlcatalog --noout --del sysid mycatalog
$xmlcatalog --noout --del sysid3 mycatalog
$xmlcatalog --noout --del sysid2 mycatalog
diff result/catalogs/mycatalog.empty mycatalog
rm -f mycatalog
exit $exitcode

51
test/scripts/test.sh Executable file
View File

@@ -0,0 +1,51 @@
#!/bin/sh
set -e
echo "## Scripts regression tests"
if [ -n "$1" ]; then
xmllint=$1
else
xmllint=./xmllint
fi
exitcode=0
for i in test/scripts/*.script ; do
name=$(basename $i .script)
xml="./test/scripts/$name.xml"
if [ -f $xml ] ; then
if [ ! -f result/scripts/$name ] ; then
echo "New test file $name"
$xmllint --shell $xml < $i \
> result/scripts/$name \
2> result/scripts/$name.err
else
$xmllint --shell $xml < $i > shell.out 2> shell.err || true
if [ -f result/scripts/$name.err ]; then
resulterr="result/scripts/$name.err"
else
resulterr=/dev/null
fi
log=$(
diff -u result/scripts/$name shell.out || true;
diff -u $resulterr shell.err || true
)
if [ -n "$log" ] ; then
echo $name result
echo "$log"
exitcode=1
fi
rm shell.out shell.err
fi
fi
done
exit $exitcode