From 2cca21a9c6cd2a2a1627f91691a39a6ed99e5318 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Sun, 4 May 2014 22:14:30 +0200 Subject: [PATCH 1/6] Stricter tests: exit code 1 on warnings too --- tests/testasciidoc.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/testasciidoc.py b/tests/testasciidoc.py index 600f69e..1f60787 100755 --- a/tests/testasciidoc.py +++ b/tests/testasciidoc.py @@ -206,13 +206,14 @@ def generate_expected(self, backend): infile = self.source outfile = StringIO.StringIO() asciidoc.execute(infile, outfile, backend) - return outfile.getvalue().splitlines() + has_warnings = asciidoc.asciidoc.document.has_warnings + return outfile.getvalue().splitlines(), has_warnings def update_expected(self, backend): """ Generate and write backend data. """ - lines = self.generate_expected(backend) + lines, has_warnings = self.generate_expected(backend) if not os.path.isdir(self.datadir): print('CREATING: %s' % self.datadir) os.mkdir(self.datadir) @@ -245,7 +246,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,7 +255,7 @@ 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, has_warnings = self.generate_expected(backend) strip_end(got) lines = [] for line in difflib.unified_diff(got, expected, n=0): @@ -269,6 +270,9 @@ def run(self, backend=None): for line in lines: message(line) message() + elif has_warnings: + self.warned += 1 + print('WARNED: %s: %s' % (backend, fromfile)) else: self.passed += 1 print('PASSED: %s: %s' % (backend, fromfile)) @@ -328,17 +332,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 +441,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) From f7b9810726e3b0a3b7f8fb10f3b51ba3613bbaf9 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Sun, 4 May 2014 22:24:39 +0200 Subject: [PATCH 2/6] Fix latex-filter on Python 2.6 --- filters/latex/latex2img.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: From 2e5f8aba88a453691e820168f1d4d3c1b640a50a Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Sun, 4 May 2014 23:02:57 +0200 Subject: [PATCH 3/6] Print all warnings for the tests --- tests/testasciidoc.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/testasciidoc.py b/tests/testasciidoc.py index 1f60787..af2d553 100755 --- a/tests/testasciidoc.py +++ b/tests/testasciidoc.py @@ -207,13 +207,14 @@ def generate_expected(self, backend): outfile = StringIO.StringIO() asciidoc.execute(infile, outfile, backend) has_warnings = asciidoc.asciidoc.document.has_warnings - return outfile.getvalue().splitlines(), has_warnings + messages = asciidoc.messages + return outfile.getvalue().splitlines(), has_warnings, messages def update_expected(self, backend): """ Generate and write backend data. """ - lines, has_warnings = 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) @@ -255,8 +256,10 @@ def run(self, backend=None): if not self.is_missing(backend): expected = self.get_expected(backend) strip_end(expected) - got, has_warnings = self.generate_expected(backend) + got, has_warnings, msgs = self.generate_expected(backend) strip_end(got) + for message in msgs: + print(' %s' % message) lines = [] for line in difflib.unified_diff(got, expected, n=0): lines.append(line) From 2226a8dc89fe40fd9b940070d2d5e66f50795d08 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Thu, 15 May 2014 16:47:14 +0200 Subject: [PATCH 4/6] Declare the empty section [unfloat-blockmacro] on the docbook45 backend --- docbook45.conf | 3 +++ 1 file changed, 3 insertions(+) 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 From 36bf524ba7874361cd2491c2d8a7f380bf5ae9df Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Mon, 5 May 2014 00:12:15 +0200 Subject: [PATCH 5/6] New 'messages' directive to acknowledge and discard a specific message in the tests --- doc/testasciidoc.txt | 7 +++++++ tests/testasciidoc.py | 24 ++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) 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/tests/testasciidoc.py b/tests/testasciidoc.py index af2d553..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,15 +211,18 @@ def generate_expected(self, backend): infile = self.source outfile = StringIO.StringIO() asciidoc.execute(infile, outfile, backend) - has_warnings = asciidoc.asciidoc.document.has_warnings - messages = asciidoc.messages - return outfile.getvalue().splitlines(), has_warnings, messages + 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) @@ -256,10 +264,10 @@ def run(self, backend=None): if not self.is_missing(backend): expected = self.get_expected(backend) strip_end(expected) - got, has_warnings, msgs = self.generate_expected(backend) + got, messages = self.generate_expected(backend) strip_end(got) - for message in msgs: - print(' %s' % message) + for msg in messages: + print(' %s' % msg) lines = [] for line in difflib.unified_diff(got, expected, n=0): lines.append(line) @@ -273,7 +281,7 @@ def run(self, backend=None): for line in lines: message(line) message() - elif has_warnings: + elif messages: self.warned += 1 print('WARNED: %s: %s' % (backend, fromfile)) else: From f3967dc806298384dfbf041875ea740d2e99b1bf Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Mon, 5 May 2014 00:13:14 +0200 Subject: [PATCH 6/6] Use the '% messages' directive to discard current warnings --- tests/testasciidoc.conf | 9 +++++++++ 1 file changed, 9 insertions(+) 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