diff --git a/doc/testasciidoc.txt b/doc/testasciidoc.txt index 1d9a1ea..56a7ac7 100644 --- a/doc/testasciidoc.txt +++ b/doc/testasciidoc.txt @@ -171,6 +171,9 @@ Optional list of command-line option tuples. % attributes Optional dictionary of attribute values. +% messages +Optional list of expected messages + --------------------------------------------------------------------- Example test spec: @@ -209,6 +212,10 @@ configuration file that comes with AsciiDoc. equivalent to a `(name,None)` tuple. - The 'attributes' directive data specifies a Python dictionary containing AsciiDoc attributes to be passed to AsciiDoc. +- The 'messages' directive is a list of messages expected on the + screen. The format is `WARNING: something goes wrong` where + filename and line number are omitted. Unexpected messages will + be reported as warnings in the test report. globals directive ~~~~~~~~~~~~~~~~~ diff --git a/docbook45.conf b/docbook45.conf index 76cbd0f..7d0d63f 100644 --- a/docbook45.conf +++ b/docbook45.conf @@ -92,6 +92,9 @@ latexmath-style=template="latexmathblock",subs=() {title#} {title%} +[unfloat-blockmacro] +# nothing to see here + [indexterm-inlinemacro] # Index term. # Generate separate index entries for primary, secondary and tertiary diff --git a/filters/latex/latex2img.py b/filters/latex/latex2img.py index 238b019..9c2b7cf 100755 --- a/filters/latex/latex2img.py +++ b/filters/latex/latex2img.py @@ -224,7 +224,7 @@ def main(): if dpi and not dpi.isdigit(): usage('invalid DPI') sys.exit(1) - if not imgfmt in {'png', 'svg'}: + if imgfmt not in ('png', 'svg'): usage('Invalid image format. Valid values are "png" or "svg".') sys.exit(1) if outfile is None: diff --git a/tests/testasciidoc.conf b/tests/testasciidoc.conf index 8a52f95..6c6c5b1 100644 --- a/tests/testasciidoc.conf +++ b/tests/testasciidoc.conf @@ -9,6 +9,9 @@ Test cases % source data/testcases.txt +% messages +WARNING: nested inline passthrough + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Filters @@ -27,6 +30,9 @@ Old tables % source data/oldtables.txt +% messages +DEPRECATED: old tables syntax + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Source highlighter @@ -776,6 +782,9 @@ UTF-8 BOM test % source data/utf8-bom-test.txt +% messages +WARNING: maximum include depth exceeded + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Deprecated quote attributes diff --git a/tests/testasciidoc.py b/tests/testasciidoc.py index 600f69e..635e736 100755 --- a/tests/testasciidoc.py +++ b/tests/testasciidoc.py @@ -109,6 +109,7 @@ def __init__(self): self.options = [] self.attributes = {'asciidoc-version': 'test'} self.backends = BACKENDS + self.messages = [] self.datadir = None # Where output files are stored. self.disabled = False @@ -161,6 +162,10 @@ def parse(self, lines, confdir, datadir): self.backends = eval(' '.join(data)) elif directive == 'name': self.name = data[0].strip() + elif directive == 'messages': + for msg in data: + (level, sep, text) = msg.partition(':') + self.messages.append((level, text)) else: raise (ValueError, 'illegal directive: %s' % l[0]) if not self.title: @@ -206,13 +211,18 @@ def generate_expected(self, backend): infile = self.source outfile = StringIO.StringIO() asciidoc.execute(infile, outfile, backend) - return outfile.getvalue().splitlines() + messages = [] + for msg in asciidoc.messages: + (level, fname, line, text) = msg.split(':', 3) + if (level, text) not in self.messages: + messages.append(msg) + return outfile.getvalue().splitlines(), messages def update_expected(self, backend): """ Generate and write backend data. """ - lines = self.generate_expected(backend) + lines, __ = self.generate_expected(backend) if not os.path.isdir(self.datadir): print('CREATING: %s' % self.datadir) os.mkdir(self.datadir) @@ -245,7 +255,7 @@ def run(self, backend=None): else: backends = [backend] result = True # Assume success. - self.passed = self.failed = self.skipped = 0 + self.passed = self.failed = self.warned = self.skipped = 0 print('%d: %s' % (self.number, self.title)) if self.source and os.path.isfile(self.source): print('SOURCE: asciidoc: %s' % self.source) @@ -254,8 +264,10 @@ def run(self, backend=None): if not self.is_missing(backend): expected = self.get_expected(backend) strip_end(expected) - got = self.generate_expected(backend) + got, messages = self.generate_expected(backend) strip_end(got) + for msg in messages: + print(' %s' % msg) lines = [] for line in difflib.unified_diff(got, expected, n=0): lines.append(line) @@ -269,6 +281,9 @@ def run(self, backend=None): for line in lines: message(line) message() + elif messages: + self.warned += 1 + print('WARNED: %s: %s' % (backend, fromfile)) else: self.passed += 1 print('PASSED: %s: %s' % (backend, fromfile)) @@ -328,17 +343,20 @@ def run(self, number=None, backend=None): Run all tests. If number is specified run test number (1..). """ - self.passed = self.failed = self.skipped = 0 + self.passed = self.failed = self.warned = self.skipped = 0 for test in self.tests: if (not test.disabled or number) and (not number or number == test.number) and (not backend or backend in test.backends): test.run(backend) self.passed += test.passed self.failed += test.failed + self.warned += test.warned self.skipped += test.skipped if self.passed > 0: print('TOTAL PASSED: %s' % self.passed) if self.failed > 0: print('TOTAL FAILED: %s' % self.failed) + if self.warned > 0: + print('TOTAL WARNED: %s' % self.warned) if self.skipped > 0: print('TOTAL SKIPPED: %s' % self.skipped) @@ -434,7 +452,7 @@ def usage(msg=None): sys.exit(1) if cmd == 'run': tests.run(number, backend) - if tests.failed: + if tests.failed or tests.warned or tests.skipped: sys.exit(1) elif cmd == 'update': tests.update(number, backend, force=force)