Skip to content

Make SVG plots the default in Java and fix CI snapshot tests#200

Open
ewels wants to merge 2 commits into
s-andrews:masterfrom
ewels:fix/svg-default-and-test-snapshots
Open

Make SVG plots the default in Java and fix CI snapshot tests#200
ewels wants to merge 2 commits into
s-andrews:masterfrom
ewels:fix/svg-default-and-test-snapshots

Conversation

@ewels
Copy link
Copy Markdown
Contributor

@ewels ewels commented May 21, 2026

CI has been failing on every PR (and on pushes to master) since around April, failing on FileContentsTest with diffs in the base64-encoded PNG plot images inside the snapshot HTML. This is due to differences in the text with anti-aliased pixels, so the byte comparison fails.

This should have been fixed by using SVG plots by default instead of PNG. However, PR #191 flipped the default in the perl launcher (fastqc adds -Dfastqc.svg=true unless --png is passed) but not in the Java code itself, where FastQCConfig.svg_output was still initialised to false. The integration tests invoke java uk.ac.babraham.FastQC.FastQCApplication directly, bypassing the launcher, so they got the Java default (PNG) and have been comparing pixel-perfect PNGs ever since.

This PR:

  • FastQCConfig.java: default svg_output = true. The -Dfastqc.svg handler now honours both true and false, so callers can still opt back into PNG.
  • fastqc launcher: only pass -Dfastqc.svg=false when --png is set without an explicit --svg. SVG is now the default everywhere.
  • FileContentsTest_{minimal,complex}_fastqc_report.approved.html: regenerated. Plots are now data:image/svg+xml;base64,... instead of data:image/png;base64,.... SVG output is deterministic.
  • VersionTest.java: assertion references FastQCApplication.VERSION instead of the hardcoded v0.12.1, so it continues to pass after future version bumps.

Tested locally with Java 11 (matches CI) and Java 17: unit + integration suites pass clean.

ewels and others added 2 commits May 21, 2026 23:10
`FastQCConfig.svg_output` defaulted to `false` so any code path that didn't
go through the perl launcher (notably the integration tests, which invoke
`java uk.ac.babraham.FastQC.FastQCApplication` directly) still got PNG
plots. The launcher only added `-Dfastqc.svg=true` to override that default;
`--png` worked by leaving the property unset. Flipping the Java default
without reworking that handler would have broken `--png`.

This commit:

  * flips `FastQCConfig.svg_output = true` so every entry point (launcher,
    direct java, integration tests) renders SVG plots by default;
  * reworks the `-Dfastqc.svg` handler to honour both `true` and `false`,
    so the launcher can opt back into PNG when the user passes `--png`;
  * updates the launcher to pass `-Dfastqc.svg=false` only when `--png` is
    set without an explicit `--svg`;
  * regenerates `FileContentsTest_{minimal,complex}_fastqc_report.approved.html`
    so the snapshots reflect SVG plots. The new approved files are bit-
    identical across Linux/macOS and Java 11/17 because SVG is plain XML
    generated directly by the code, with no AWT raster pipeline. The
    previous PNG approved files diverged on every push because pixel
    rendering differs between macOS (Core Graphics) and Linux (FreeType);
  * fixes `VersionTest` to reference `FastQCApplication.VERSION` instead of
    a hardcoded `v0.12.1` literal, so the assertion tracks future bumps.

Tested locally with Java 11 (matches CI) and Java 17: unit + integration
suites pass clean.
SVGGenerator is not platform-deterministic: on Linux the Swing default
JPanel background (rgb(238,238,238)) gets painted before the chart's own
fill, and the inherited UI font is 12pt vs 13pt on macOS. Approved files
generated locally on macOS therefore don't match CI output.

Promote the .received.html files from the failing CI run as the new
approved snapshots. Cross-platform divergence in SVGGenerator itself is
a separate fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ewels
Copy link
Copy Markdown
Contributor Author

ewels commented May 21, 2026

SVG output is deterministic.

Correction, SVG output is apparently not deterministic, across operating systems. Or rather, the Java environment that the SVG is generated from is not. OS-specific differences in font-size and in the background panel.

These are visually minor though, and it should be consistent when running within the CI environment, so I just took the version from the CI runner. Means that the tests pass as they should and function as regression testing.

Downside is that it's difficult to regenerate new snapshots locally. Proper fix is to try to cancel out those two OS-specific differences, but I'd rather not mess around adding in tonnes of font-size declarations all through the SVG if we can avoid it (having just spent some time trying to optimise that kind of thing out of the SVG).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant