source: rtems-tools/doc/asciidoc/doc/testasciidoc.txt @ f91e023

4.104.115
Last change on this file since f91e023 was f91e023, checked in by Chris Johns <chrisj@…>, on 02/17/14 at 07:04:46

Add the documentation.

  • Property mode set to 100644
File size: 7.9 KB
Line 
1AsciiDoc Tests
2==============
3
4AsciiDoc includes 'testasciidoc', a Python script runs a set of
5AsciiDoc conformance tests. 'testasciidoc' runs through a list of
6AsciiDoc source files, generates backend outputs and then compares
7them to expected result files. The whole process is driven by a
8configuration file containing a list of user configurable test
9specifications.
10
11
12Rationale
13---------
14When modifying AsciiDoc configuration files or source code it's very
15easy to introduce regression errors. 'testasciidoc' is a tool for
16writing many and varied test cases that can be run after changes have
17been made in order to verify that existing behavior has not been
18broken.
19
20The 'testasciidoc' 'update' command automates the (re)generation of
21expected test result data.  Result data regeneration has to be
22performed after changes to test case source files or after legitimate
23changes to the AsciiDoc output formats -- doing this manually is
24prohibitively tedious.
25
26
27Running testasciidoc
28--------------------
29The `testasciidoc.py` script and the default `testasciidoc.conf`
30configuration file are located in the AsciiDoc distribution `tests`
31directory.
32
33To view the command usage run:
34
35---------------------------------------------------------------------
36$ python tests/testasciidoc.py
37Usage: testasciidoc.py [OPTIONS] COMMAND
38
39Run AsciiDoc conformance tests specified in configuration FILE.
40
41Commands:
42  list                          List tests
43  run [NUMBER] [BACKEND]        Execute tests
44  update [NUMBER] [BACKEND]     Regenerate and update test data
45
46Options:
47  -f, --conf-file=CONF_FILE
48        Use configuration file CONF_FILE (default configuration file is
49        testasciidoc.conf in testasciidoc.py directory)
50  --force
51        Update all test data overwriting existing data
52---------------------------------------------------------------------
53
54To view the list of tests in the default `testasciidoc.conf`
55configuration file run the 'list' command:
56
57---------------------------------------------------------------------
58$ python tests/testasciidoc.py list
591: Test cases
602: Tables
613: Source highlighter
624: Example article
635: Example book
646: Example multi-part book
657: !User Guide
66---------------------------------------------------------------------
67
68The '!' prefix signals that a test is currently disabled.
69
70Before running the tests you will need to regenerate the expected
71outputs by running the 'update' command:
72
73---------------------------------------------------------------------
74$ python tests/testasciidoc.py update
75WRITING: tests/data/testcases-html4.html
76WRITING: tests/data/testcases-xhtml11.html
77WRITING: tests/data/testcases-docbook.xml
78 :
79WRITING: tests/data/book-multi-docbook.xml
80---------------------------------------------------------------------
81
82Now you can run the tests:
83
84---------------------------------------------------------------------
85$ python tests/testasciidoc.py run
861: Test cases
87SOURCE: asciidoc: tests/data/testcases.txt
88PASSED: html4: tests/data/testcases-html4.html
89PASSED: xhtml11: tests/data/testcases-xhtml11.html
90PASSED: docbook: tests/data/testcases-docbook.xml
91 :
926: Example multi-part book
93SOURCE: asciidoc: doc/book-multi.txt
94PASSED: html4: tests/data/book-multi-html4.html
95PASSED: xhtml11: tests/data/book-multi-xhtml11.html
96PASSED: docbook: tests/data/book-multi-docbook.xml
97
98TOTAL PASSED:  18
99---------------------------------------------------------------------
100
101[NOTE]
102=====================================================================
103- 'testasciidoc' requires AsciiDoc is located in your environment
104  search path, if not you'll need to set the `ASCIIDOC_PY` environment
105  variable to point to `asciidoc.py`.
106- If you don't have GNU source-highlight installed you should disable
107  the 'Tables' and 'Source highlighter' tests in the
108  `tests/testasciidoc.conf` configuration file.
109=====================================================================
110
111
112testasciidoc commands
113---------------------
114'list'::
115  List test numbers and titles.  A '!' title prefix signals that a
116  test is currently disabled.
117
118'run'::
119  Read and execute tests from the test configuration file. A test
120  specifies AsciiDoc test case source file and command options.  The
121  test compares generated outputs to expected outputs and any
122  differences displayed as a diff.  You can run selected tests by
123  specifying the test number and/or backend after the `run` command.
124  Examples:
125
126  python tests/testasciidoc.py run
127  python tests/testasciidoc.py run 3
128  python tests/testasciidoc.py run html4
129  python tests/testasciidoc.py run 3 html4
130
131'update'::
132  Generates and updates missing and out of date test output data
133  files, this eliminates one of the most time consuming aspect of test
134  management.  Use the `--force` option to force updates.
135  Examples:
136
137  python tests/testasciidoc.py update
138  python tests/testasciidoc.py --force update 4
139
140NOTE: You can run or update disabled tests by explicitly specifying
141the test number.
142
143
144Test configuration file
145-----------------------
146The tests configuration file format consists of one or more test specs
147separated by a line of one or more percent characters. Each test spec
148consists of an optional test title and description followed by one or
149more optional directives (a directive starts with a percent
150character).  A 'directive' consists begins with a line containing a '%'
151character followed by a directive name followed by zero or more lines
152of directive data.
153
154Test spec format
155~~~~~~~~~~~~~~~~
156---------------------------------------------------------------------
157Optional test title
158Optional test description...
159
160% name
161Optional base output file name. Defaults to base source file name.
162
163% source
164AsciiDoc source file name.
165
166% backends
167Optional list of backends to be tested(default is all backends).
168% options
169Optional list of command-line option tuples.
170
171% attributes
172Optional dictionary of attribute values.
173
174---------------------------------------------------------------------
175
176Example test spec:
177
178---------------------------------------------------------------------
179Example book
180
181% options
182['--section-numbers',('--doctype','book')]
183
184% attributes
185# Exclude date from document footer.
186{'docdate':None}
187
188% source
189../doc/book.txt
190---------------------------------------------------------------------
191
192TIP: Take a look at the default `tests/testasciidoc.conf`
193configuration file that comes with AsciiDoc.
194
195- Tests can be disabled by prefixing the test title with an
196  exclamation '!' character.
197- All relative file names are relative to the configuration file
198  directory.
199- Multiple tests must by separated by a `%` separator line (one or
200  more percent characters).
201- Lines starting with a percent character specify a test 'directive'
202  and may be followed by zero or more lines of directive data.
203- Directive data lines cannot start with a percent character.
204- Lines starting with a `#` hash character are ignored.
205- The 'source' directive data is a single line containing the
206  AsciiDoc source file name.
207- The 'options' directive data is a Python list of `(name,value)`
208  tuples specifying AsciiDoc command-line options. A string item is
209  equivalent to a `(name,None)` tuple.
210- The 'attributes' directive data specifies a Python dictionary
211  containing AsciiDoc attributes to be passed to AsciiDoc.
212
213globals directive
214~~~~~~~~~~~~~~~~~
215An optional 'globals' directive can precede all test specs, the
216globals directive data is a Python dictionary containing global
217values.  Currently the only global is 'datadir', the directory
218containing expected output files (defaults to configuration file
219directory). For example:
220
221---------------------------------------------------------------------
222% globals
223{'datadir': 'data'}
224---------------------------------------------------------------------
225
226Expected output test data files are stored in the 'datadir' and are
227named after the corresponding AsciiDoc input source file.  For example
228if the AsciiDoc file name is `article.txt` then the corresponding
229backend output files will be `article-html4.html`,
230`article-xhtml11.html`, `article-docbook.xml` (stored in the 'datadir'
231directory).
Note: See TracBrowser for help on using the repository browser.