[cairo] cairo-script for unit testing [feedback]
chris at chris-wilson.co.uk
Wed May 27 06:52:55 PDT 2009
On Wed, 2009-05-27 at 10:21 -0300, Ian Britten wrote:
> Hi all,
> Continuing on my investigation of how I might write unit tests for
> my Cairo code, I've been looking into the new cairo-script tool
> that is under development on the trunk.
> Architecturally, cairo-script seems like it might be a successor
> for cairowrap, as it works uses similar techniques. As such, most
> of my feedback about cairowrap is probably still applicable for
True, it did indeed evolve from libcairowrap.
> One question I couldn't resolve is: What is the intended usage of
> the cairo-script trace file? A lot of effort has obviously gone
> into making it PostScript-like, but it isn't true PS that GS/etc
> can view. Is there something that can be done with it, or is it
> just an extensive text/log file?
Within the source tree is a CairoScript interpreter [util/cairo-script]
and a few example utilities that replay traces to various targets. This
is very useful for performance profiling. In another branch I have some
code that mutates traces (and invents random traces) to seek out new
bugs. The plan is to couple that with branch-coverage and generate
minimal tests that maximise coverage.
Another wip is a tool called Sphinx, "a post-mortem Cairo debugger".
This is intended to be a tool to inspect traces and Cairo state at any
time. It is also intended to be able to produce minimal bug reports.
A longer term goal is reinventing DisplayPostScript, with the hope that
a trace is both more bandwidth friendly and that Cairo is a more
flexible acceleration architecture than X.
Last, but not least, the traces are intended to be readable.
> As with cairowrap, I don't think that cairo-script will currently
> be suitable for writing cross-platform unit tests, due to the
> issues described earlier. Again, this isn't meant as a criticism
> of cairo-script, since I was trying to use it for something it
> wasn't intended for. Please just take my comments as possible
> suggestions/considerations for future cairo-script work!
>From your perspective you do need a logging backend. Ideally you want a
decorator style surface:
but the closest we have at the moment is the CairoScript backend,
i.e. ./configure --enable-script. Hmm, I've not even tried to compile
this recently - as I recall everything but user-fonts (plus one or two
other font failures) works. It is cross-platform and since it is a
backend should be convenient to plug into your test code without
cross-contamination from GTK+. Take a look and see if that is closer to
More information about the cairo