summaryrefslogtreecommitdiffstats
path: root/thml2osis/xslt/tests/README
blob: 7308f3d4fe6667ec33d8bbf7a21c4a0489a64faa (plain) (blame)
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
Running the test suite:
-----------------------
 - cd to/the/test/directory/
 - ./runtests.sh

Zero output means everything passed.
Otherwise you get a diff of everything that failed.
If any output is invliad OSIS, you will also get validation error messages.

Requirements
------------
The test suite requires:
- Bash, or shell
- 'xml2' suite -- this turns XML into a line oriented format that is much
  more convenient for TDD.
- 'xsltproc' for running the XSLT
- For validating the OSIS produced: validator.pl from the Perl-Xerces
  package, (Debian package libxml-xerces-perl) or alternatively 'xmlstarlet' 
  (the former is preferred, see below).

All of these could probably be replaced with alternatives for different
platforms.


Strategy
--------
The essential test strategy performed by runtests.sh is this:
 - for each foo.thml, use the xslt file to generate the OSIS file
 - save the OSIS file as foo.osis
 - Flatten this file using xml2, saving in a temporary file tmp.flat
 - compare tmp.flat with the reference foo.osis.flat
 - Validate the foo.osis file

TDD routine:
------------
1) update one of the test.osis.flat files to reflect the new functionality
   that is to be added
2) Run runtests.sh to ensure that you have added what you think you've added
3) Implement functionality in XSLT
4) Run runtests.sh to check results
5) Repeat 3 and 4 until it works correctly

Sometimes hand editing the .osis.flat files will be tedious, either when a
single change affects lots of tests files, or when the change or addition is
very simple and easy to confirm as correct.  In this case, update_test.sh
can be used to recreate the .osis.flat files *once you are sure that the
XSLT file is producing correct output*.

After each feature is added, tests and the XSLT file should be committed to
source control.


BUGS
----
xmlstarlet does not print correct line numbers for errors on lines greater
than 65535 (it just prints 65535). See:

http://sourceforge.net/tracker/index.php?func=detail&aid=1219072&group_id=66612&atid=515106
http://bugzilla.gnome.org/show_bug.cgi?id=409707

For this reasons, the Xerces validator is preferred (it also has much more
compact and readable error messages).