mypaint / mypaint

MyPaint is a simple drawing and painting program that works well with Wacom-style graphics tablets.
https://mypaint.app
GNU General Public License v2.0
2.68k stars 387 forks source link

Many doctest errors with recent 2.0.x rebuild #1078

Closed hosiet closed 4 years ago

hosiet commented 4 years ago

315 ## Description of the problem

I rebuilt mypaint v2.0.x branch on my Debian Unstable/Sid system but many doctest errors happened.

Basic system details

MyPaint version: git 2.0.x branch (2020-05-05, dc5deca611b285f1fdcc1165249bc0fc5e7ac339) Libmypaint version: 1.6.0 Operating system: Debian Unstable/Testing Desktop environment: N/A (build doctest error)

Backtraces or error messages

Please find the full buildlog in the following attached file:

mypaint_2.0.0+git20200502-1_amd64-2020-05-12T22:24:55Z.build.txt

Can you provide any hints about where should I start when debugging?

jplloyd commented 4 years ago

log.txt (appveyor build for fdcee9c64c6e184afc327626834943c6d5a513a6)

Thanks, some of those test failures are pretty strange. Above is a log from the msys2 build ten days ago for the same branch, which has fairly up-to-date dependencies. Checking the version discrepancy for dependencies, between the sid/unstable environment and msys2, might be helpful.

If these failures are all caused by a sngle issue, I would start by looking at the failure of the interpolate functions in the classes in lib/color.py, which should be pretty isolated.

I'll set up a vm with sid to check this out, later.

jplloyd commented 4 years ago

Lunch break test results:

Error is caused by from __future__ import division. I don't know the root cause of the problem, but I'm pretty sure it's not something on our end.

The doc tests all pass after commenting out the imports (which are not needed for Py3). Can be tested by running this from the source root:

find . -name "*.py" -exec sed -i -E 's/(from __future)/# \1/' {} +

You could also just remove the division's from the imports to verify that the other imports from __future__ are not a problem. Neither print_function nor absolute_imports cause any issues.

Edit: forgot to mention what actually breaks.

It seems the failed import breaks subsequent handling of generators, which is why tests that don't use generator expressions (and list/set/dict comprehensions) still pass.

In the log you linked to, the relevant errors/warnings are on lines 2523 and 2668.

hosiet commented 4 years ago

Thanks. After filtering out all the from __future__ import lines, the number of errors was reduced but not completely eliminated:

======================================================================
FAIL: Doctest: lib.helpers.freedesktop_thumbnail
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.8/doctest.py", line 2204, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for lib.helpers.freedesktop_thumbnail
  File "/<<PKGBUILDDIR>>/lib/helpers.py", line 258, in freedesktop_thumbnail

----------------------------------------------------------------------
File "/<<PKGBUILDDIR>>/lib/helpers.py", line 278, in lib.helpers.freedesktop_thumbnail
Failed example:
    isinstance(p1, GdkPixbuf.Pixbuf)
Expected:
    True
Got:
    False
----------------------------------------------------------------------
File "/<<PKGBUILDDIR>>/lib/helpers.py", line 281, in lib.helpers.freedesktop_thumbnail
Failed example:
    isinstance(p2, GdkPixbuf.Pixbuf)
Expected:
    True
Got:
    False
----------------------------------------------------------------------
File "/<<PKGBUILDDIR>>/lib/helpers.py", line 283, in lib.helpers.freedesktop_thumbnail
Failed example:
    p2.to_string() == p1.to_string()
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python3.8/doctest.py", line 1336, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest lib.helpers.freedesktop_thumbnail[5]>", line 1, in <module>
        p2.to_string() == p1.to_string()
    AttributeError: 'NoneType' object has no attribute 'to_string'
----------------------------------------------------------------------
File "/<<PKGBUILDDIR>>/lib/helpers.py", line 285, in lib.helpers.freedesktop_thumbnail
Failed example:
    p2.get_width() == p2.get_height() == 256
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python3.8/doctest.py", line 1336, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest lib.helpers.freedesktop_thumbnail[6]>", line 1, in <module>
        p2.get_width() == p2.get_height() == 256
    AttributeError: 'NoneType' object has no attribute 'get_width'

-------------------- >> begin captured logging << --------------------
lib.helpers: DEBUG: thumb: uri='file:///<<PKGBUILDDIR>>/svg/thumbnail-test-input.svg'
lib.helpers: ERROR: Failed to load thumbnail pixbuf from 'svg/thumbnail-test-input.svg'
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/lib/helpers.py", line 430, in get_pixbuf
    return lib.pixbuf.load_from_file(filename)
  File "/<<PKGBUILDDIR>>/lib/pixbuf.py", line 113, in load_from_file
    pixbuf = load_from_stream(fp, progress=progress)
  File "/<<PKGBUILDDIR>>/lib/pixbuf.py", line 146, in load_from_stream
    loader.write(buf)
gi.repository.GLib.GError: gdk-pixbuf-error-quark: Unrecognized image file format (3)
lib.helpers: DEBUG: thumb: uri='file:///<<PKGBUILDDIR>>/svg/thumbnail-test-input.svg'
lib.helpers: ERROR: Failed to load thumbnail pixbuf from 'svg/thumbnail-test-input.svg'
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/lib/helpers.py", line 430, in get_pixbuf
    return lib.pixbuf.load_from_file(filename)
  File "/<<PKGBUILDDIR>>/lib/pixbuf.py", line 113, in load_from_file
    pixbuf = load_from_stream(fp, progress=progress)
  File "/<<PKGBUILDDIR>>/lib/pixbuf.py", line 146, in load_from_stream
    loader.write(buf)
gi.repository.GLib.GError: gdk-pixbuf-error-quark: Unrecognized image file format (3)
--------------------- >> end captured logging << ---------------------
jplloyd commented 4 years ago

It looks like the rest of the errors are caused by there not being a pixbuf loader for svg available. In the log it looks like librsvg is not installed, though it should be required (at least some svg loader for pixbuf is required).

You may also have to run gdk-pixbuf-query-loaders --update-cache (maybe with an optional path, depending on how the dependencies are set up) before running the tests.

hosiet commented 4 years ago

Thanks! It looks like I missed the {test,runtime}-dependency on librsvg. The errors disappeared after installing librsvg library.

If the library is indeed necessary, I guess we need to list the library in BUILDING.md for both Windows and Linux builds.

I will keep this issue open for now; please feel free to close it if you find it necessary.

jplloyd commented 4 years ago

The librsvg + pixbuf loader requirement is now added to BUILDING.md (ac5e6d2522d79ac45c92ef7662b5c05e58b867bf).

As for the from __future__ import division error, I'm not sure if it's an upstream issue with Python or nose. If it's the latter it will never be fixed upstream, meaning we'll have to change the test runner.

jplloyd commented 4 years ago

Issue was reported for Python 3.8.3rc1 three days ago, seems to be an issue with the doctest module: https://bugs.python.org/issue40604

Edit: as of 2020-05-14, this is fixed in (at least) the debian package for Python 3.8.3, probably from an earlier upstream fix.