Skip to content

Graphviz: Add tests, refactor and fix bug(s)

Corentin Plouët requested to merge corentin-plouet/cmake:graphviz into master

While trying to analyze a (fairly complex) CMake project using the --graphviz option, I noticed some issues with the output; in particular, some nodes are unconnected when they should be. So I want to fix that.

I still need to isolate that issue down to something that can be replicated and tested, but in the meantime I've added a basic test suite for the Graphviz writer code, with unit tests for the various options, on a sample project covering most target types and links. It should improve the test coverage a bit; there is already some decent coverage for that feature, but I think it's indirect and because the --graphviz option is used as part of other tests in CPack.

There are a few open issues related to that feature, which I will try to also address. The Graphviz writer code is a bit hard to follow, and it does its own graph traversal. I suspect this can be simplified by letting cmComputeTargetDepends do the job, which in fact it already does to output something similar on stderr, in Debug mode. So I've refactored that code a bit to implement a (simplified) visitor pattern. Ideally I will be able to implement the Graphviz writer as a GraphVisitor, which will hopefully prevent it from deviating in the future.

This is my first merge request to CMake; I tried to follow the existing style and practice but I might have missed a few things.

Edited by Corentin Plouët

Merge request reports