Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failing on new darwin platforms due to warnings #441

Open
viraptor opened this issue Nov 9, 2022 · 3 comments
Open

Test failing on new darwin platforms due to warnings #441

viraptor opened this issue Nov 9, 2022 · 3 comments

Comments

@viraptor
Copy link

viraptor commented Nov 9, 2022

New macos apparently prints out warnings about xtype in unexpected places. This affects tests relying on pygraphviz not throwing warnings.

For example: https://hydra.nixos.org/build/197644084/nixlog/1

______________________ PygraphvizTest.test_binary_stream _______________________

self = <tests.test_pygraphviz.PygraphvizTest testMethod=test_binary_stream>

    def test_binary_stream(self):
        from io import BytesIO
        m = self.machine_cls(states=['A', 'B', 'C'], initial='A', auto_transitions=True,
                             title='A test', show_conditions=True, use_pygraphviz=self.use_pygraphviz)
        b1 = BytesIO()
        g = m.get_graph()
>       g.draw(b1, format='png', prog='dot')

tests/test_graphviz.py:251: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/nix/store/1k05lq8pghfp4grf3875jgf11cs19051-python3.10-pygraphviz-1.10/lib/python3.10/site-packages/pygraphviz/agraph.py:1611: in draw
    data = self._run_prog(prog, args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <AGraph <Swig Object of type 'Agraph_t *' at 0x11017b510>>, prog = 'dot'
args = ' -Tpng'

    def _run_prog(self, prog="nop", args=""):
        """Apply graphviz program to graph and return the result as a string.
    
        >>> import pygraphviz as pgv
        >>> A = pgv.AGraph()
        >>> s = A._run_prog()  # doctest: +SKIP
        >>> s = A._run_prog(prog="acyclic")  # doctest: +SKIP
    
        Use keyword args to add additional arguments to graphviz programs.
        """
        runprog = r'"%s"' % self._get_prog(prog)
        cmd = " ".join([runprog, args])
        dotargs = shlex.split(cmd)
        p = subprocess.Popen(
            dotargs,
            shell=False,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            close_fds=False,
        )
        (child_stdin, child_stdout, child_stderr) = (p.stdin, p.stdout, p.stderr)
        # Use threading to avoid blocking
        data = []
        errors = []
        threads = [PipeReader(data, child_stdout), PipeReader(errors, child_stderr)]
        for t in threads:
            t.start()
    
        self.write(child_stdin)
        child_stdin.close()
    
        for t in threads:
            t.join()
        p.wait()
    
        if not data:
            raise OSError(b"".join(errors).decode(self.encoding))
    
        if len(errors) > 0:
>           warnings.warn(b"".join(errors).decode(self.encoding), RuntimeWarning)
E           RuntimeWarning: 2022-11-04 14:36:54.541 dot[58758:62928605] XType: com.apple.fonts is not accessible.
E           2022-11-04 14:36:54.542 dot[58758:62928605] XType: XTFontStaticRegistry is enabled.

/nix/store/1k05lq8pghfp4grf3875jgf11cs19051-python3.10-pygraphviz-1.10/lib/python3.10/site-packages/pygraphviz/agraph.py:1405: RuntimeWarning
=========================== short test summary info ============================

The same issue has been worked around in graphviz regression tests by ignoring those lines: https://gitlab.com/graphviz/graphviz/-/merge_requests/2418/diffs

@rossbar
Copy link
Contributor

rossbar commented Nov 9, 2022

It looks like the warning originates from the NixOS test suite, not pygraphviz's. In this case I'd recommend adding a warnings filter to your test configuration to catch/ignore the runtime warning. Once you are able to build against the version of graphviz that has the necessary patch you should be able to remove the warnings filter.

@viraptor
Copy link
Author

viraptor commented Nov 9, 2022

The warning originates from graphviz itself when its run on macos 12, it's not nixos-specific. Please see the issue in graphviz itself: https://gitlab.com/graphviz/graphviz/-/merge_requests/2418
They fixed it by ignoring the warnings in their test suite.

@rossbar
Copy link
Contributor

rossbar commented Nov 9, 2022

The warning originates from graphviz itself when its run on macos 12, it's not nixos-specific.

Yes I understand - I'm trying to determine whether there's an action item here. We're not seeing any related errors in pygraphviz CI, likely because the macos-latest image isn't at 12 yet. If the runtime warnings are causing failures in a downstream test suite, then my recommendation from above post stands. If the proposal is to add a warnings filter to pygraphviz itself, I wouldn't necessarily be against that, but we'd have no way of testing the warnings filter until macos 12 hits the CI providers. If you're proposing that pygraphviz add a similar warning to its own test suite, I'd be +1 for that too, but again we'd likely wait until there was a way to reliably test the warnings filter.

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

No branches or pull requests

2 participants