Closed Bug 625938 Opened 14 years ago Closed 13 years ago

doctest in xpi.md L47 fails: "inconsistent leading whitespace"

Categories

(Add-on SDK Graveyard :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: warner, Assigned: warner)

Details

Attachments

(1 file)

It looks like the patch from bug 618146 caused the test suite to start failing:

(jp-git)41:warner@host-4-141% cfx testcfx -b ~/Desktop/FF4\ betas/Firefox4b9.app
Traceback (most recent call last):
  File "/Users/warner/stuff/mozilla/jetpack/jp-git/bin/cfx", line 29, in <module>
    cuddlefish.run()
  File "/Users/warner/stuff/mozilla/jetpack/jp-git/python-lib/cuddlefish/__init__.py", line 430, in run
    test_cfx(env_root, options.verbose)
  File "/Users/warner/stuff/mozilla/jetpack/jp-git/python-lib/cuddlefish/__init__.py", line 289, in test_cfx
    retval = cuddlefish.tests.run(verbose)
  File "/Users/warner/stuff/mozilla/jetpack/jp-git/python-lib/cuddlefish/tests/__init__.py", line 55, in run
    tests = get_tests()
  File "/Users/warner/stuff/mozilla/jetpack/jp-git/python-lib/cuddlefish/tests/__init__.py", line 44, in get_tests
    optionflags=doctest_opts
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py", line 2330, in DocFileTest
    test = parser.get_doctest(doc, globs, name, path, 0)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py", line 597, in get_doctest
    return DocTest(self.get_examples(string, name), globs,
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py", line 611, in get_examples
    return [x for x in self.parse(string, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py", line 573, in parse
    self._parse_example(m, name, lineno)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py", line 643, in _parse_example
    lineno + len(source_lines))
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/doctest.py", line 729, in _check_prefix
    (lineno+i+1, name, line))
ValueError: line 47 of the docstring for xpi.md has inconsistent leading whitespace: '</pre>'

Ah, doctests, they're like our canary in a coal mine, and fail at the slightest hint of trouble :).
From what I can tell, having <pre> and </pre> in column 0, while putting the rest of the doctest in column 2 (or 4, or whatever), causes the doctest module to think that the closing </pre> is part of the test data (but the sudden negative whitespace change, from 2-or-4 spaces to 0, triggers the ValueError).

Putting <pre>/</pre> in column 2 (same as the doctest lines) doesn't trigger the ValueError, but does cause the tests to fail, because "</pre>" isn't in the test output.

However, putting a blank line between the end of the test data and the </pre> (regardless of what column it's in) works: the test data ends before the </pre>. I imagine that means the resulting docs will have an extra blank line at the end, but that's harmless.

Patch forthcoming..
this unbreaks tests for me
Attachment #504018 - Flags: review?(myk)
Comment on attachment 504018 [details] [diff] [review]
insert blank line to terminate doctest sections

For me as well!  r+!  I'd also be interested in hearing Will's feedback on this.
Attachment #504018 - Flags: review?(myk)
Attachment #504018 - Flags: review+
Attachment #504018 - Flags: feedback?(wbamberg)
Pushed as https://github.com/mozilla/addon-sdk/commit/a14cac1d77031ad2d14f193bf87998bf05d3f796 . I'll wait to close this until we get Will's thoughts.
My thoughts are possibly not worth the wait. I don't understand why doctest does not like the <pre></pre> tags, but I'm happy that the fix has no bad effect on the docs.

I'm not convinced that the xpi doctests are worth the pain they cause. The obvious suggestion would be to change the example so it's not the same package as that used by the cfx tests, and then it wouldn't break every time we add a test to cfx. It would also be a clearer example then as it wouldn't have all the bits and pieces required for the cfx tests.

But this isn't a priority for us. Perhaps the best thing would be for me to do that the next time I have to update the doctests anyway.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Attachment #504018 - Flags: feedback?(wbamberg)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: