Entertainment at it's peak. The news is by your side.

Librsvg’s test suite is now in Rust


Some necessary modifications are afoot in librsvg.

Changes to continuous integration

Some days ago, Dunja Lalic rewrote the continuous integration
to be worthy sooner. A total pipeline historical to capture
about 90 minutes to slip, now it takes about 15 minutes on common.

Graph with pipeline timings, which shrink drastically

The description of modifications is attention-grabbing. The root is to make tests fail as mercurial as potential, conclude to the origin of the pipeline. To fade up the total pipeline, Dunja did the next:

  • Pass the cargo test stage to the origin. This test means,
    “does this even comprise an opportunity of compiling?”.

  • Beget the code kind and formatting tests, cargo clippy and cargo
    , slip in parallel with the unit tests. These lints can fail,
    nonetheless they’re straightforward to repair after one is done bettering the predominant

  • Bustle the unit tests and the smoke tests in debug mode, so that they bring together
    like a flash.

  • Bustle the total integration test suite in liberate mode. This takes
    longer to bring together, nonetheless there are some slack tests that lend a hand so a lot
    from sooner execution.

  • Pass the liberate tests except the high, and handiest slip them once per week
    — or at any time when, by hand. These capture a decent length of time to slip,
    on memoir of they devise out a fleshy make distcheck and autotools is slack. Even
    then, now these tests capture 30-40 minutes, in plan of the 90 from
    earlier than.

  • Between every stage of the pipeline, fabricate no longer cache what doesn’t abet
    decrease compilation time. It seems retaining around a huge cache,
    with the total produce target, between every pipeline stage will also be
    worse than no longer having one at all.

Complete pipeline with all the stages

Take a look at suite in Rust

Beteen Sven Neumann, Dunja Lalic, and myself we comprise now got lastly ported
the test suite to Rust
: all of librsvg’s tests are
now in Rust, excluding for the C API tests. We had to raise out a pair of things:

  • Review the extinct tests and take care of some dilapidated ones.

  • Port every of the test modules to Rust. They’re runt, nonetheless every body
    has particular little things — test for crashes in the XML loading
    code, test for crashes all the device thru rendering, test the library’s security

  • Repair the runt tests that advance as phase of the documentation.

  • Untangle the reference tests and port them to Rust.

  • Pass little chunks of code around so the unit tests and integration
    tests can fragment utilities to compare photos, compute file paths for
    test fixtures, etc.

Essentially the most complicated ingredient to port used to be the reference tests. These are
the ultimate ones; every test hundreds an SVG file, renders it,
and compares the end result to a reference PNG image. There are some
problems in the tests; they want to form an even
configuration for Fontconfig and Pango, so as to comprise reproducible
font rendering. The pango-rs bindings elevate out no longer camouflage this phase of
Pango, so we had to raise out some things by hand.

Anyway, the tests are now in Rust. One advantageous ingredient is that
now the tests slip mechanically in parallel, across all CPU cores, so
we put on total making an are trying out time.

What’s next: cargo-c and submit to

We need so as to submit librsvg in as a
customary crate; this implies having the flexibility to bring together, test, and submit
completely from Cargo. The compilation and making an are trying out phase is completed.

Now, we comprise now got to reorganize the code so it is going to even be revealed to Librsvg is available in three elements, rsvg_internals with the
implementation of the library, librsvg with the used C API,
and librsvg_crate with the Rust API. Nevertheless, to submit the Rust
API to, it would be extra convenient to comprise a single crate
in plan of 1 with the internals and one with the API.

The following step is thus to reorganize the code:

  • Operate it potential to implement the C API as a bring together-time option on
    high of the customary Rust code. We want to exercise cargo-c to
    bring together the used shared library, in plan of
    reckoning on C tools for compiling and linking.

  • Combine rsvg_internals and librsvg_crate in a single crate, to
    submit them together. has a 10 MB limit per crate; now
    that the test suite lives in a separate tests crate, this
    have to not be a location.

  • I could well need to polish the public error forms earlier than
    publishing the Rust API; factual now they recount some implementation
    necessary aspects which may perhaps well be of no interest to callers of the library.

What remains to be ported to Rust?

Only two things, which amount to less than 900 lines of C code:

  • rsvg-convert – the notify-line program that all americans uses to
    convert SVG to PNG and different formats. Fortunately, Sven Neumann
    wrote some fabulous tests for rsvg-convert,
    as it is treasure an API that we comprise now got to take care of right: if we alternate the
    notify-line ideas or this system’s habits, we could well destroy
    all americans’s scripts.

  • The gdk-pixbuf module for loading SVG. Alberto Ruiz has started
    porting it to Rust
    . The generic phase of this code
    could well perhaps later back to wrap different Rust image codecs and plug them to

Read More

Leave A Reply

Your email address will not be published.