#!/bin/sh

echo Test XML to XPaths conversion

#### Prerequisites
failed=0
type diff >/dev/null
[ $? -ne 0 ] && echo diff program must be installed\; skipping test && failed=1
[ $failed -ne 0 ] && exit
# On systems derived from Debian those programs should be available in repositories:
# diff in package diffutils (should be installed by default)

Nrun=0
Nfailed=0

#### 1: Test that XML is converted on equivalent XML
Nrun=$(($Nrun+1)); failed=0

t_python $t_datconv =xml2xpaths.yaml $t_outdir || failed=1
[ $failed -eq 0 ] && diff -qwB data_in/mondial-3.0-country30-40.xpath $t_outdir/mondial-3.0-country30-40.xpath >$t_outdir/diff_out || failed=1
[ -s $t_outdir/diff_out ] && failed=1 && cat $t_outdir/diff_out
 
[ $failed -ne 0 ] && Nfailed=$(($Nfailed+1))
[ $failed -ne 0 ] && echo Failed test $Nrun
####

#### Cleanup and Summary
# rm -fR $t_outdir/*
echo Run $Nrun tests\; failed $Nfailed
echo

