1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<meta name="generator" content="AsciiDoc 8.5.2" />
7
<link rel="stylesheet" href="./xhtml11.css" type="text/css" />
8
<link rel="stylesheet" href="./xhtml11-quirks.css" type="text/css" />
9
<link rel="stylesheet" href="./layout1.css" type="text/css" />
10
<script type="text/javascript">
12
window.onload = function(){asciidoc.footnotes(); asciidoc.toc(1);}
15
<script type="text/javascript" src="./asciidoc-xhtml11.js"></script>
16
<title>AsciiDoc Tests</title>
18
<body style="max-width:70em">
19
<div id="layout-banner">
20
<div id="layout-title">AsciiDoc</div>
21
<div id="layout-description">Text based document generation</div>
26
<div>»<a href="index.html">Home</a></div>
27
<div>»<a href="manpage.html">Man Page</a></div>
28
<div>»<a href="userguide.html">User Guide</a></div>
29
<div>»<a href="INSTALL.html">Installation</a></div>
30
<div>»<a href="faq.html">FAQ</a></div>
31
<div>»<a href="a2x.1.html">a2x</a></div>
32
<div>»<a href="asciidocapi.html">API</a></div>
33
<div>»<a href="http://powerman.name/doc/asciidoc">Cheatsheet</a></div>
34
<div>»<a href="testasciidoc.html">Tests</a></div>
35
<div>»<a href="CHANGELOG.html">ChangeLog</a></div>
36
<div>»<a href="support.html">Support</a></div>
37
<div id="page-source">»<a href="testasciidoc.txt">Page Source</a></div>
40
<div id="layout-content">
42
<h1>AsciiDoc Tests</h1>
44
<div id="toctitle">Table of Contents</div>
45
<noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
50
<div class="sectionbody">
51
<div class="paragraph"><p>AsciiDoc includes <em>testasciidoc</em>, a Python script runs a set of
52
AsciiDoc conformance tests. <em>testasciidoc</em> runs through a list of
53
AsciiDoc source files, generates backend outputs and then compares
54
them to expected result files. The whole process is driven by a
55
configuration file containing a list of user configurable test
56
specifications.</p></div>
59
<h2 id="_rationale">Rationale</h2>
60
<div class="sectionbody">
61
<div class="paragraph"><p>When modifying AsciiDoc configuration files or source code it’s very
62
easy to introduce regression errors. <em>testasciidoc</em> is a tool for
63
writing many and varied test cases that can be run after changes have
64
been made in order to verify that existing behavior has not been
66
<div class="paragraph"><p>The <em>testasciidoc</em> <em>update</em> command automates the (re)generation of
67
expected test result data. Result data regeneration has to be
68
performed after changes to test case source files or after legitimate
69
changes to the AsciiDoc output formats — doing this manually is
70
prohibitively tedious.</p></div>
72
<h2 id="_running_testasciidoc">Running testasciidoc</h2>
73
<div class="sectionbody">
74
<div class="paragraph"><p>The <tt>testasciidoc.py</tt> script and the default <tt>testasciidoc.conf</tt>
75
configuration file are located in the AsciiDoc distribution <tt>tests</tt>
77
<div class="paragraph"><p>To view the command usage run:</p></div>
78
<div class="listingblock">
80
<pre><tt>$ python tests/testasciidoc.py
81
Usage: testasciidoc.py [OPTIONS] COMMAND
83
Run AsciiDoc conformance tests specified in configuration FILE.
87
run [NUMBER] [BACKEND] Execute tests
88
update [NUMBER] [BACKEND] Regenerate and update test data
91
-f, --conf-file=CONF_FILE
92
Use configuration file CONF_FILE (default configuration file is
93
testasciidoc.conf in testasciidoc.py directory)
95
Update all test data overwriting existing data</tt></pre>
97
<div class="paragraph"><p>To view the list of tests in the default <tt>testasciidoc.conf</tt>
98
configuration file run the <em>list</em> command:</p></div>
99
<div class="listingblock">
100
<div class="content">
101
<pre><tt>$ python tests/testasciidoc.py list
104
3: Source highlighter
107
6: Example multi-part book
108
7: !User Guide</tt></pre>
110
<div class="paragraph"><p>The <em>!</em> prefix signals that a test is currently disabled.</p></div>
111
<div class="paragraph"><p>Before running the tests you will need to regenerate the expected
112
outputs by running the <em>update</em> command:</p></div>
113
<div class="listingblock">
114
<div class="content">
115
<pre><tt>$ python tests/testasciidoc.py update
116
WRITING: tests/data/testcases-html4.html
117
WRITING: tests/data/testcases-xhtml11.html
118
WRITING: tests/data/testcases-docbook.xml
120
WRITING: tests/data/book-multi-docbook.xml</tt></pre>
122
<div class="paragraph"><p>Now you can run the tests:</p></div>
123
<div class="listingblock">
124
<div class="content">
125
<pre><tt>$ python tests/testasciidoc.py run
127
SOURCE: asciidoc: tests/data/testcases.txt
128
PASSED: html4: tests/data/testcases-html4.html
129
PASSED: xhtml11: tests/data/testcases-xhtml11.html
130
PASSED: docbook: tests/data/testcases-docbook.xml
132
6: Example multi-part book
133
SOURCE: asciidoc: doc/book-multi.txt
134
PASSED: html4: tests/data/book-multi-html4.html
135
PASSED: xhtml11: tests/data/book-multi-xhtml11.html
136
PASSED: docbook: tests/data/book-multi-docbook.xml
138
TOTAL PASSED: 18</tt></pre>
140
<div class="admonitionblock">
143
<img src="./images/icons/note.png" alt="Note" />
146
<div class="ulist"><ul>
149
<em>testasciidoc</em> requires AsciiDoc is located in your environment
150
search path, if not you’ll need to set the <tt>ASCIIDOC_PY</tt> environment
151
variable to point to <tt>asciidoc.py</tt>.
156
If you don’t have GNU source-highlight installed you should disable
157
the <em>Tables</em> and <em>Source highlighter</em> tests in the
158
<tt>tests/testasciidoc.conf</tt> configuration file.
166
<h2 id="_testasciidoc_commands">testasciidoc commands</h2>
167
<div class="sectionbody">
168
<div class="dlist"><dl>
174
List test numbers and titles. A <em>!</em> title prefix signals that a
175
test is currently disabled.
183
Read and execute tests from the test configuration file. A test
184
specifies AsciiDoc test case source file and command options. The
185
test compares generated outputs to expected outputs and any
186
differences displayed as a diff. You can run selected tests by
187
specifying the test number and/or backend after the <tt>run</tt> command.
190
<div class="literalblock">
191
<div class="content">
192
<pre><tt>python tests/testasciidoc.py run
193
python tests/testasciidoc.py run 3
194
python tests/testasciidoc.py run html4
195
python tests/testasciidoc.py run 3 html4</tt></pre>
203
Generates and updates missing and out of date test output data
204
files, this eliminates one of the most time consuming aspect of test
205
management. Use the <tt>--force</tt> option to force updates.
208
<div class="literalblock">
209
<div class="content">
210
<pre><tt>python tests/testasciidoc.py update
211
python tests/testasciidoc.py --force update 4</tt></pre>
215
<div class="admonitionblock">
218
<img src="./images/icons/note.png" alt="Note" />
220
<td class="content">You can run or update disabled tests by explicitly specifying
221
the test number.</td>
225
<h2 id="_test_configuration_file">Test configuration file</h2>
226
<div class="sectionbody">
227
<div class="paragraph"><p>The tests configuration file format consists of one or more test specs
228
separated by a line of one or more percent characters. Each test spec
229
consists of an optional test title and description followed by one or
230
more optional directives (a directive starts with a percent
231
character). A <em>directive</em> consists begins with a line containing a <em>%</em>
232
character followed by a directive name followed by zero or more lines
233
of directive data.</p></div>
234
<h3 id="_test_spec_format">Test spec format</h3><div style="clear:left"></div>
235
<div class="listingblock">
236
<div class="content">
237
<pre><tt>Optional test title
238
Optional test description...
241
Optional base output file name. Defaults to base source file name.
244
AsciiDoc source file name.
247
Optional list of backends to be tested(default is all backends).
249
Optional list of command-line option tuples.
252
Optional dictionary of attribute values.</tt></pre>
254
<div class="paragraph"><p>Example test spec:</p></div>
255
<div class="listingblock">
256
<div class="content">
257
<pre><tt>Example book
260
['--section-numbers',('--doctype','book')]
263
# Exclude date from document footer.
267
../doc/book.txt</tt></pre>
269
<div class="admonitionblock">
272
<img src="./images/icons/tip.png" alt="Tip" />
274
<td class="content">Take a look at the default <tt>tests/testasciidoc.conf</tt>
275
configuration file that comes with AsciiDoc.</td>
278
<div class="ulist"><ul>
281
Tests can be disabled by prefixing the test title with an
282
exclamation <em>!</em> character.
287
All relative file names are relative to the configuration file
293
Multiple tests must by separated by a <tt>%</tt> separator line (one or
294
more percent characters).
299
Lines starting with a percent character specify a test <em>directive</em>
300
and may be followed by zero or more lines of directive data.
305
Directive data lines cannot start with a percent character.
310
Lines starting with a <tt>#</tt> hash character are ignored.
315
The <em>source</em> directive data is a single line containing the
316
AsciiDoc source file name.
321
The <em>options</em> directive data is a Python list of <tt>(name,value)</tt>
322
tuples specifying AsciiDoc command-line options. A string item is
323
equivalent to a <tt>(name,None)</tt> tuple.
328
The <em>attributes</em> directive data specifies a Python dictionary
329
containing AsciiDoc attributes to be passed to AsciiDoc.
333
<h3 id="_globals_directive">globals directive</h3><div style="clear:left"></div>
334
<div class="paragraph"><p>An optional <em>globals</em> directive can precede all test specs, the
335
globals directive data is a Python dictionary containing global
336
values. Currently the only global is <em>datadir</em>, the directory
337
containing expected output files (defaults to configuration file
338
directory). For example:</p></div>
339
<div class="listingblock">
340
<div class="content">
342
{'datadir': 'data'}</tt></pre>
344
<div class="paragraph"><p>Expected output test data files are stored in the <em>datadir</em> and are
345
named after the corresponding AsciiDoc input source file. For example
346
if the AsciiDoc file name is <tt>article.txt</tt> then the corresponding
347
backend output files will be <tt>article-html4.html</tt>,
348
<tt>article-xhtml11.html</tt>, <tt>article-docbook.xml</tt> (stored in the <em>datadir</em>
349
directory).</p></div>
352
<div id="footnotes"><hr /></div>
354
<div id="footer-text">
356
Last updated 2009-12-07 17:25:00 NZDT
358
<div id="footer-badges">
359
<a href="http://validator.w3.org/check?uri=referer">
360
<img style="border:0;width:88px;height:31px"
361
src="http://www.w3.org/Icons/valid-xhtml11-blue"
362
alt="Valid XHTML 1.1" height="31" width="88" />
364
<a href="http://jigsaw.w3.org/css-validator/">
365
<img style="border:0;width:88px;height:31px"
366
src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
369
<a href="http://www.mozilla.org/products/firefox/">
370
<img style="border:none; width:110px; height:32px;"
371
src="http://www.spreadfirefox.com/community/images/affiliates/Buttons/110x32/safer.gif"
372
alt="Get Firefox!" />