PCB visual diff with kicad-cli and lukaj
Issue
While working on the functional tests of kicad-kbplacer I found that automatic SVG file comparison is harder than it seems. That’s because different textual representations can produce same graphical result.
The current tests implementation, while not simple, works pretty well.
The PCB output file is used to render multiple SVG files (one per layer) and
these files are compared with references using xmldiff
which does most of the heavy lifting. Some of differences found, such as moved nodes
or changed textLength
attributes, are ignored (KiCad does not keep the order of nodes),
and the other are indication of failed test.1
Unfortunately this approach does not always work. I’m still getting false positives from time to time - for example after KiCad version updates.2 Another situation where this is not enough, is when I’m changing the behaviour of the plugin and need an easy way to check if produced PCB files are ok or if the references must be regenerated3 to match new implementation. This requires visual inspection.
Solution
To my surprise, I couldn’t find any a good standalone SVG visual comparison tool, so I started the lukaj project.
It is currently in the early stages, with some of rough edges, but already quite usable (if you don’t mind crashes when zooming too much).
I’m using lukaj with the kicad-cli and a simple wrapper shell script:
|
|
The diff-kicad
wrapper can be used directly or be configured
as git difftool.
To use it with git, add following sections to .gitconfig
:
|
|
Now, it is available with git diff-kicad
command:
To learn more about lukaj, visit https://github.com/adamws/lukaj.
I also developed small convenience KiCad plugin which adds
git GUI launcher to toolbar, see: https://github.com/adamws/kicad-git.
This GUI has Tools
menu entry which is user configurable.
To add diff-kicad
to it, append following settings to .gitconfig
:
|
|