Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

"Errors should never pass silently" #27

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

florentx
Copy link
Contributor

@florentx florentx commented May 5, 2014

Errors should never pass silently - The Zen of Python

This pull request is based on the previous one #25. It improves the testasciidoc.py tool to report better the failures and the other warnings.
I recommend to review and merge #25 before considering this one.
florentx/asciidoc@with-travis...compat26

When preparing PR #25 I discovered that the test suite is a bit too indulgent:

  • if some dependency is missing, errors are printed but test is marked PASSED
  • if a filter spawns a subprocess and it crashes, test is marked PASSED
  • if the source of a test was deleted or a backend is missing, the test is SKIPPED but the exit code is 0
  • if a macro or anything else returns a warning, the warning is silenced, and result is PASSED

This PR addresses the above issues:

  • it returns exit code 1 on FAILED tests, but also on SKIPPED tests, and on warnings too
  • it prints all the unexpected messages on the screen when running the test suite
  • a new directive is created for testasciidoc.conf to declare the expected messages: % messages
  • this new directive is documented
  • test is counted as WARNED if some message is unexpected, and the exit code is set to 1

I've chosen to add all the current warnings to the expected % messages, so the Travis-CI build is still green after the merge.
However, we should challenge this in the future, and probably fix some tests.

@@ -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'):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it restores compatibility with Python 2.6

@michel-kraemer
Copy link
Contributor

Thanks for this commit. I wonder whether we should let the Travis CI build fail instead of adding the warning messages to the list of expected ones. This will give us a reminder that we need to fix these issues.

What do you think?
Michel

@florentx
Copy link
Contributor Author

IMHO if we let the build red, it will not help for reviewing future PR.
Instead, I propose to open a separate issue for the only real bug (from above):

The second warning is reported only with the docbook45 backend : when it is fixed, this line should be deleted.

@michel-kraemer
Copy link
Contributor

OK. But who is going to fix it? Unfortunately, I don't know the code base good enough to do it myself.

Michel

@florentx
Copy link
Contributor Author

It's not a new bug, it already lived in the Googlecode repository.
The bug is not in the core asciidoc engine: the test complains about the configuration of the "docbook45" backend specifically, which is missing a section [unfloat-blockmacro].
So it's probably only the ./docbook45.conf which needs a small fix.

Anyone interested can try it and propose a patch.
Currently I am more focused on the html output, and the core engine of asciidoc.

@florentx
Copy link
Contributor Author

Because github did not refresh the PR #27 diff, here is the web view:
https://github.com/florentx/asciidoc/compare/compat26

@florentx
Copy link
Contributor Author

-edited-

unrelated change moved to PR #29

@florentx
Copy link
Contributor Author

I believe that this PR is ready for final review.

@elextr
Copy link
Contributor

elextr commented May 17, 2014

At a quick look it seems ok, but I am currently unable to test it. I would prefer if someone (other than the originator) tested it before commit.

Otherwise I hope to get to it in the next week.

@florentx
Copy link
Contributor Author

I've rebased the changes on current master

@michel-kraemer
Copy link
Contributor

+1

Looks good. All tests pass fine with Python 2.6 and 2.7

@florentx
Copy link
Contributor Author

Thank you for your review.

I rebased the changes on master after PR #31 was merged, because #31 fixes the "missing barchart.py" warning.

@florentx
Copy link
Contributor Author

florentx commented Sep 2, 2014

hello, any chance to get this merged?

@elextr
Copy link
Contributor

elextr commented Sep 2, 2014

@florentx since its a reasonably large change I'd like to test it before committing, but I'm travelling with a tablet (so no git, asciidoc etc) so all I can do is press the github merge button. If anyone else (not the submitter :) can test then I can merge.

@aerostitch
Copy link
Contributor

@florentx It seems this repo will no longer accept PR as the latest release has been cut a while ago but https://github.com/asciidoc/asciidoc-py3 would.
If you still want this PR integrated in asciidoc, do you mind pushing it there please?
Once done I think you can close this one.
Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants