summaryrefslogtreecommitdiff
path: root/xml2ag/test/convert.test
blob: 4eadafc2a773678d8ed959b1e1a825425106d9ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#! /bin/sh
#  -*- Mode: Shell-script -*-
# ----------------------------------------------------------------------
# convert.test --- test XML -> AutoGen conversion
#
## Time-stamp:      "2010-07-16 15:29:12 bkorb"
## Author:          Bruce Korb <bkorb@gnu.org>
##
##  This file is part of AutoGen.
##  AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
##
##  AutoGen 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 3 of the License, or
##  (at your option) any later version.
##
##  AutoGen 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, see <http://www.gnu.org/licenses/>.

case "X${VERBOSE}" in
X | X[nNfF]* ) VERBOSE=false ;;
* ) set -x ;   VERBOSE=true ;;
esac

# A standard failure function
failure()
{
  cd ${testsubdir}
  test -d ../FAILURES || mkdir ../FAILURES
  l=`echo *`
  ( \cd ../FAILURES ; rm -f $l )
  mv -f * ../FAILURES
  echo "$*"
  exit 1
}

srcdir=`pwd`
testname=convert
[ -d testdir ] || mkdir testdir
cd testdir
testsubdir=`pwd`

${X2Aexe} -O ${testname}.out <<'_EndOfXML_'
<?xml version="1.0"?>
<ag_example template="sample.tpl">
  <mumble attr="foo">
    <grumble>
      &lt;stumble around the 'XML'.&gt;
    </grumble>
    mumble-1
    <!-- This is just a
         /* multi-line comment */ -->
    mumble-2
    <grumble>
      grumble &amp; "grumble" &amp; grumble.
    </grumble>
    mumble, mumble
  </mumble>
  <stumble upon="rough going"/>
</ag_example>
_EndOfXML_

cat > ${testname}.samp <<'_EndOfSample_'
/* Parsed from stdin */
AutoGen Definitions sample.tpl;
XML-version = '1.0';
XML-standalone = true;
template = 'sample.tpl';
mumble = {
  content = '';
  attr = 'foo';
  grumble = {
    content = '';
    text = '<stumble around the \'XML\'.>';
  };
  text = 'mumble-1';
  /* This is just a
         /* multi-line comment * / */
  text = 'mumble-2';
  grumble = {
    content = '';
    text = 'grumble & "grumble" & grumble.';
  };
  text = 'mumble, mumble';
};
stumble = {
  content = '';
  upon = 'rough going';
};
_EndOfSample_

cmp -s ${testname}.samp ${testname}.out || \
	failure "`diff ${testname}.samp ${testname}.out`"

${VERBOSE} || { cd ${srcdir} ; rm -rf ${testsubdir} ; }