2005-12-06 12:08:09 +05:30
|
|
|
#! /bin/sh
|
|
|
|
#
|
2006-05-02 02:41:26 +05:30
|
|
|
# Import/export test for GRAMPS:
|
2013-07-28 19:20:03 +05:30
|
|
|
# o Import example XML data and create internal Gramps DB
|
|
|
|
# o Open produced example Gramps DB, then
|
2006-05-02 02:41:26 +05:30
|
|
|
# * check data for integrity
|
|
|
|
# * output in all formats
|
|
|
|
# o Check resulting XML for well-formedness and validate it
|
|
|
|
# against DTD and RelaxNG schema.
|
2013-07-28 19:20:03 +05:30
|
|
|
# o Import every exported file produced if the format
|
|
|
|
# is also supported for import, and run a text summary report.
|
|
|
|
# o Diff each report with the summary of the produced example DB
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
TOP_DIR=`dirname $PWD`
|
|
|
|
TEST_DIR=$TOP_DIR/test
|
2013-07-28 19:20:03 +05:30
|
|
|
SRC_DIR=$TOP_DIR/gramps
|
|
|
|
PRG="python ../Gramps.py"
|
2005-12-06 12:08:09 +05:30
|
|
|
EXAMPLE_XML=$TOP_DIR/example/gramps/example.gramps
|
|
|
|
|
2013-07-28 19:20:03 +05:30
|
|
|
OUT_FMT="csv ged gramps gpkg wft gw vcs vcf"
|
|
|
|
IN_FMT="csv ged gramps gpkg gw vcf"
|
2005-12-06 12:08:09 +05:30
|
|
|
DATA_DIR=$TEST_DIR/data
|
|
|
|
mkdir -p $DATA_DIR
|
2013-07-28 19:20:03 +05:30
|
|
|
GRAMPSHOME=$DATA_DIR/grampshome
|
|
|
|
export GRAMPSHOME
|
|
|
|
echo ""
|
|
|
|
echo "+--------------------------------------------------------------"
|
|
|
|
echo "| GRAMPSHOME set to: $GRAMPSHOME "
|
|
|
|
echo "+--------------------------------------------------------------"
|
|
|
|
|
|
|
|
if [ -d $GRAMPSHOME/. ]; then
|
|
|
|
rm -rf $GRAMPSHOME
|
2005-12-06 12:08:09 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "+--------------------------------------------------------------"
|
2013-07-28 19:20:03 +05:30
|
|
|
echo "| Import XML, create Gramps DB 'example'"
|
2005-12-06 12:08:09 +05:30
|
|
|
echo "+--------------------------------------------------------------"
|
2013-07-28 19:20:03 +05:30
|
|
|
OPTS="-i $EXAMPLE_XML -C example"
|
2005-12-06 12:08:09 +05:30
|
|
|
(cd $SRC_DIR; $PRG $OPTS)
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "+--------------------------------------------------------------"
|
2013-07-28 19:20:03 +05:30
|
|
|
echo "| Check the example DB for errors"
|
2005-12-06 12:08:09 +05:30
|
|
|
echo "+--------------------------------------------------------------"
|
2013-07-28 19:20:03 +05:30
|
|
|
OPTS="-O example -a tool -p name=check"
|
2005-12-06 12:08:09 +05:30
|
|
|
(cd $SRC_DIR; $PRG $OPTS)
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "+--------------------------------------------------------------"
|
2013-07-28 19:20:03 +05:30
|
|
|
echo "| Open the example DB, write all other formats"
|
2005-12-06 12:08:09 +05:30
|
|
|
echo "+--------------------------------------------------------------"
|
2013-07-28 19:20:03 +05:30
|
|
|
OPTS="-O example"
|
2005-12-06 12:08:09 +05:30
|
|
|
for fmt in $OUT_FMT; do
|
2013-07-28 19:20:03 +05:30
|
|
|
OPTS="$OPTS -e $DATA_DIR/example.$fmt -f $fmt"
|
2005-12-06 12:08:09 +05:30
|
|
|
done
|
2013-07-28 19:20:03 +05:30
|
|
|
(cd $SRC_DIR; echo "$PRG $OPTS"; $PRG $OPTS)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "+--------------------------------------------------------------"
|
|
|
|
echo "| Validate produced XML"
|
|
|
|
echo "+--------------------------------------------------------------"
|
2013-07-28 19:20:03 +05:30
|
|
|
RESULT_GRAMPS=$DATA_DIR/example.gramps
|
|
|
|
if [ -f $RESULT_GRAMPS ]; then
|
|
|
|
RESULT_XML=$DATA_DIR/example.xml
|
|
|
|
gunzip < $RESULT_GRAMPS > $RESULT_XML
|
|
|
|
else
|
|
|
|
echo "+--------------------------------------------------------------"
|
|
|
|
echo "| ERROR: $RESULT_GRAMPS not found"
|
|
|
|
echo "+--------------------------------------------------------------"
|
|
|
|
exit 1
|
|
|
|
fi
|
2005-12-06 12:08:09 +05:30
|
|
|
echo "* Regular well-formedness and DTD validation"
|
2013-07-28 19:20:03 +05:30
|
|
|
xmllint --noout --valid $RESULT_XML
|
2005-12-06 12:08:09 +05:30
|
|
|
echo "* Post-parsing DTD validation"
|
2013-07-28 19:20:03 +05:30
|
|
|
xmllint --noout --postvalid $RESULT_XML
|
2005-12-06 12:08:09 +05:30
|
|
|
echo "* Validate against RelaxNG schema"
|
2013-07-28 19:20:03 +05:30
|
|
|
xmllint --noout --relaxng $TOP_DIR/data/grampsxml.rng $RESULT_XML
|
2006-05-02 02:41:26 +05:30
|
|
|
|
|
|
|
echo ""
|
2013-07-28 19:20:03 +05:30
|
|
|
echo "+----------------------------------------------------------------"
|
|
|
|
echo "| For each produced format supported for import, generate summary"
|
|
|
|
echo "+----------------------------------------------------------------"
|
2006-05-02 02:41:26 +05:30
|
|
|
for fmt in $IN_FMT; do
|
2013-07-28 19:20:03 +05:30
|
|
|
EXPORTED_DATA=$DATA_DIR/example.$fmt
|
|
|
|
REPORT_TXT=$EXPORTED_DATA.report.txt
|
|
|
|
OPTS="-i $EXPORTED_DATA -f $fmt -a report -p name=summary,off=txt,of=$REPORT_TXT"
|
2006-05-02 02:41:26 +05:30
|
|
|
(cd $SRC_DIR; $PRG $OPTS)
|
|
|
|
done
|
2013-07-28 19:20:03 +05:30
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "+--------------------------------------------------------------"
|
|
|
|
echo "| Compare to the summary of the original database"
|
|
|
|
echo "+--------------------------------------------------------------"
|
|
|
|
IMPORTED_REPORT_TXT=$DATA_DIR/example.report.txt
|
|
|
|
OPTS="-O example -a report -p name=summary,off=txt,of=$IMPORTED_REPORT_TXT"
|
|
|
|
(cd $SRC_DIR; $PRG $OPTS)
|
|
|
|
for exported_report_txt in $DATA_DIR/example.*.report.txt; do
|
|
|
|
diff -u $IMPORTED_REPORT_TXT $exported_report_txt
|
|
|
|
done
|