summaryrefslogtreecommitdiff
path: root/doc/testasciidoc.txt
blob: af52d6e138b6dc02d0c7d557fb8b9c3a1cb54814 (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
AsciiDoc Tests
==============

WARNING: 'testasciidoc' is experimental and is alpha quality. It's in
the AsciiDoc trunk.

I very nearly made a couple of serious regression bloppers with the
last release and it's well past the point where my ad hoc checking
just doesn't cut it.

AsciiDoc requires a regression conformance test (process test input
and compare with expected output) along with an easily modified and
extensible set of test cases.

I added a rather lame doctest feature to 8.4.1 but it's just too
fiddley and inflexible. Using the Python `unittest` module would also
be tedious for large numbers of test cases so I wrote a
`testasciidoc.py` script.

- Run `python testasciidoc.py` to view the command usage.
- Run `python testasciidoc.py list` to list tests.
- Run `python testasciidoc.py update` to regenerate test data.
- Run `python testasciidoc.py run` to run tests.

Currently 'testasciidoc' has the following commands:

'run'::
  Read a and execute tests from a test configuration file. A test
  specifies AsciiDoc source and command options and expected outputs.
  When the test is run the generated output is compared to the
  expected output and any differences displayed as a diff.  You can
  run a single test by specifying the test number and/or backend after
  the `run` command. Examples:

  python testasciidoc.py run
  python testasciidoc.py run 3
  python testasciidoc.py run html4
  python testasciidoc.py run 3 html4

'list'::
  List test numbers and titles.

'update'::
  Generates and updates missing test outputs, this eliminates one of
  the most time consuming aspect of test management.  It writes a new
  configuration file after renaming the original with a `.orig` file
  name extension. Use the `--force` option to regenerate all outputs.
  Examples:

  python testasciidoc.py update
  python testasciidoc.py --force update

The tests configuration file format consists of test specs separated
by a line of one or more percent characters. Each test spec consists
of a title/description followed by one or more directives (a directive
starts with a percent character) and are formatted like:

-------------------------------------------------------
Test title
Optional test description...

% options
Optional list of command-line option tuples.

% attributes
Optional dictionary of attribute values.

% asciidoc[: filename]
AsciiDoc inline input (if no filename is specified).

% backends
Optional list of backends (default is all backends).

% <backend>
Optional expected inline output from <backend> backend.
-------------------------------------------------------

An optional 'globals' directive can precede all tests, the directive
data is a Python dictionary containing global values. Currently the
only global is 'datadir', the directory containing expected output
files (defaults to configuration file directory). For example:

-------------------------------------------------------
% globals
{'datadir': 'data'}
-------------------------------------------------------

.Notes
- All relative file names are relative to the configuration file
  directory.
- Multiple tests must by separated by a `%` separator line (one or
  more percent characters).
- Lines starting with a percent character specify a test 'directive'
  and may be followed by associated lines of data.
- Test data lines cannot start with a percent or a hash character (if
  necessary indent inline data).
- Lines starting with a `#` hash character are ignored.
- If a `filename` is specified with the 'asciidoc' directive then
  existing same-named backend files will be compared with output
  generated by the AsciiDoc file. For example if the AsciiDoc file
  name is `article.txt` then the files `article-html4.html`,
  `article-xhtml11.html`, `article-docbook.xml` (located in the
  'datadir' directory) will be compared if they exist.
- If a `filename` is not specified in the 'asciidoc' directive then it
  must be followed by one or more lines of inline AsciiDoc source. The
  generated output is compared to the data in the inline backend
  directives.
- If inline AsciiDoc is specified and there is no 'options' directive
  then the `--no-header-footer` option is implicit.
- Inline backend directives must follow all other directives.
- `options` are a list of Python `(name,value)` tuples specifying
  AsciiDoc command-line options.  A string item is equivalent to a
  `(name,None)` tuple.
- `attributes` specify a Python dictionary for AsciiDoc attributes to
  be passed to AsciiDoc.
- `backends` specifies a Python list of backend strings. If this
  directive is ommitted it defaults to all backends.

See `./tests/testasciidoc.conf` for examples.