gleon 0.6.2
gleon: ^0.6.2 copied to clipboard
Drop-in matchesGoldenFile for Flutter golden tests, 5-20x faster, with pixel and SSIM tolerance, ignore regions and real fonts, powered by a Rust engine.
0.6.2 #
- Bytes that are no complete PNG (no PNG at all, a PNG cut short, or one without image data)
never pass as identical to a golden of the same bytes: such a golden could never be compared,
so the test fails with
gleon could not compare.--update-goldensnever writes such bytes as a golden, and says why:the candidate is not a complete PNG. Before, a truncated PNG was written as it was. - A case report or a failure image never writes through a symbolic link at its path in
.gleon/runs/: the link is replaced, the file it names stays as it was. - Clearer texts without
.gleon/gleon.yaml: a failure ends with "Tip: a tolerance for this golden goes into .gleon/gleon.yaml (see the package README)", and theGLEON_METRICSwarning no longer points at the gleon CLI. A text tolerance that cannot apply says that the candidate came without text regions. - A checkout of the package (a git dependency) refuses a release that does not name the gleon
commit of its libraries. Every release since 0.5.0 names it. A cached checksum list of a
release_urlmirror that does not name it is loaded again once first, as for a missing library, so a mirror that addsgleon_ref.txtlater needs no cleared cache. - The pub.dev screenshot is readable as a small thumbnail in search results: one headline and the time of one passing golden. The tables of "Performance" in the README are measured again (Flutter 3.50.0, gleon 0.6.2): 12-22x faster from the captured frame, 4.7-22x for PNG bytes.
- Contributors: a failed
cargobuild of agleon_repocheckout reports its output once (gleon: failed to build the native library …), without a secondgleon:and the name of a Dart exception.bin/consumer_check.dartandbin/prepare_publish.darttake the files of the package from the archive pub packs (dart pub publish --to-archive, thentar), not from a copy of the.pubignorerules. The example app has no desktop runners: it is a test project.
0.6.1 #
- Published by CI: the release workflow publishes each version to pub.dev from its tag, after the libraries of all four hosts are built, tested and verified. Like the official Dart publish workflow, it packs the archive without network, and the job that uploads it runs no code of the repository. pub.dev trusts that job by its GitHub OIDC token (automated publishing), so no pub.dev secret is stored anywhere.
- A screenshot on pub.dev: the time per golden of
flutter_testand gleon, and the line coverage of the package. - Tests now cover every line of the package (100% line coverage, up from 97.9%).
0.6.0 #
- First release on pub.dev:
flutter pub add dev:gleon. The package contains the native libraries of the four hosts, soflutter testdownloads nothing. A git dependency still downloads its library from the GitHub Release, and its errors name the pub.dev version too. - Requires Flutter 3.50 (Dart 3.14) or newer. Earlier versions of Flutter keep gleon 0.5.0.
- The gleon CLI reads your workspace as it is.
gleon initof the CLI writesbaselines: goldensinto.gleon/gleon.yaml: the goldens next to the tests are the baselines, so the CLI sums up and reports the runs ofgleon test -- flutter testand commits approved candidates over the goldens, but never scans them as screenshots. This version accepts the key (older ones reject it as unknown); it changes nothing in how goldens compare. - README: an optional section on what the CLI adds (run summary, HTML report, PR comment,
/gleon approvefrom CI) and how to start. Without the CLI the package works as before. - The native library knows the
baselineskey and thessimsize check below;NATIVE_LICENSES.mdfollows its dependency updates. Adiffkey of another mode in.gleon/gleon.yamlis named in backticks in the error (`diff.threshold` applies to `mode: pixel` only). ssimgoldens larger than 4096x4096 pixels:--update-goldensdoes not record them (the failure says so, and the old golden stays), and a match against one is reported as not comparable, also when the images are identical. Before, such a golden was written and then failed on every run where the bytes differed. Useexactorpixelfor larger images.- A
channelToleranceoredgeThresholdout of range fails with the range wording ofgleon.yaml:must be between 0 and 254. - Text regions: lines of a paragraph are told apart by their full height, so dense lines
(a
heightbelow 1 with mixed sizes) keep a region each instead of merging; a clip that a perspective sends to infinity no longer breaks finding the text. A line of rotated or skewed text is covered by pieces about as long as it is high (at most 64), not by one box around the whole line, which was mostly no text; a line turned by a quarter or half turn keeps one box. loadAppFontsis cheaper per test file: a font file listed under several weights is loaded once, and the font checksum is updated from the changed bytes instead of reading the whole font.- README: goldens compared through
GleonFileComparatorsee no text, so with real fonts they fail on other operating systems and--update-goldensthere writes them over. doc/alchemist.md: alchemist 0.14.1 gives a golden only the localizations of the SDK's Material library, which Flutter 3.50 deprecates; widgets ofmaterial_uineed their own. The example app usesmaterial_uiand shows how.- Contributors: a
gleon_repocheckout reached through a symbolic link keeps tracking its sources. - Contributors: a
gleon_repobuild in the hook seesCARGO_*andRUSTUP_*, so a toolchain under a customCARGO_HOMEorRUSTUP_HOMEworks there.RUSTFLAGSandRUSTC_WRAPPERstill do not reach it; a failed build names the alternatives.
0.5.0 #
- Real text works without a config.
--update-goldensstamps every golden it writes with the platform (gleon:platform), with or without.gleon/gleon.yamland whether or not a rule matches it (only a golden the workspaceexcludes is written and compared as Flutter does, its text as pixels like the rest); an unstamped golden of the same image is written once more to stamp it. The stamp alone decides where text is compared: strictly (0.05 of a tile) on that platform, ignored elsewhere. A pass that ignored differing text because the golden names no platform (recorded by Flutter, or before this version, without afallback_platform) says so once per test process. --update-goldensalways wins without afallback_platform. In a workspace with afallback_platform(the platform that records it again), a golden recorded on another platform is kept while just its text differs; kept goldens print one line naming it. Without one, nothing could record the golden again, so it is written over.- Breaking:
modeis required in.gleon/gleon.yamlrules, andmode: exactexists. A rule without a mode used to tolerate 1% of the pixels silently (pixel's default);exactcompares every pixel and refusesdiffkeys. Adiffkey of another mode is an error even at its default (the fulldiffblocks of oldergleon initconfigs keep the keys of their mode only).required_versionandscreenshotsare optional: a workspace may name only itsfallback_platform.fallback_platformapplies to every golden of the workspace, matched by a rule or not. - Breaking: a
pixeltolerance names its threshold.GoldenTolerance.pixelrequiresmaxDiffRatio, and amode: pixelrule requiresdiff.threshold(0 for none): neither tolerates 1% of the pixels silently any more (writemaxDiffRatio: 0.01/threshold: 0.01for the old behavior). The constructors ofExactTolerance,PixelToleranceandSsimToleranceare private: the factories ofGoldenToleranceare the one way to create a tolerance, while the variants stay public for their fields andswitch. - Failures say what to open and what to run. A failure names its diff image
(
<name>_gleonDiff.png) next to the failures directory, a missing golden addsflutter test --update-goldens, and the box of anssimfailure is its "failing area" (the neighborhoods below the thresholds, as in the HTML report), no longer "changed area". - Platform names:
macos-arm64,linux-x64,amd64anddarwin(the names of the release assets and of Dart'sAbi) are read asmacos-aarch64,linux-x86_64andmacoswherever a platform is parsed (the config, the CLI's--platform,--os/--archand variables); a custom key such ascustom-arm64keeps its spelling. - The workspace search stops at the repository root (the first directory with
.git,.hg,.jjor.sl) and never takes the home directory or a directory above it unless that is a repository root itself: a~/.gleon/gleon.yamlno longer applies to projects without one. The gleon CLI searches the same way (its.envincluded). - Failures of a golden covered by a rule name their case report (its absolute path: the test
may run in a package below the workspace root) and
gleon report html; the tip about.gleon/gleon.yamlis shown only without a rule. - A library the host cannot load (an older glibc, musl) is reported as such, with the floor of the released Linux libraries (Ubuntu 26.04) and the ways out, instead of the advice for device builds.
gleon initof the CLI writes a Flutter template next to apubspec.yaml(**/test/**/*.pngfor the packages of a pub workspace too,mode: exact,exclude: "**/failures/**",fallback_platform= the OS and architecture of the run);--genericand--flutterchoose explicitly, and an existing config is kept. Likegit initit initializes the directory it runs in (a package of a monorepo gets a nested workspace, named as such). A rule withoutmodenames the modes in its error.- Package metadata:
test_apiaccepts every 0.x the SDK pins (a caret would breakpub geton the next minor), pub.dev topicstestingandflutter-test.GleonFileComparator.withSession(a test seam) is gone from the public API. - Only painted text is text. Text laid out but not painted (the hidden pages of an
IndexedStack,Visibility.maintain,SliverOffstage, a zeroSliverOpacity, a route under an opaque one) no longer gets a text region, which hid the changes painted under it (text is ignored on other platforms by default). The painted text is found by replaying the paint of the capture without drawing or touching its layers, after the image is captured. - The build hook runs only when an input changes. It declared files that may not exist (the
bundled library, the pins), which the hooks runner takes for files modified during the build:
every
flutter testof an app that depends on the package ran the hook again and printed "File modified during build. Build must be rerun.". - Hook failures are reported as hook errors (the message, not an unhandled
Bad statewith its stack trace; network failures as infrastructure failures); HTTP 408 and 429 are retried; the user and password of any URL never appear in messages; arelease_urlon this machine (any loopback address) bypasses proxies; anffi_pathto the library of another OS is refused at once, whatever the case of its extension. - Downloads give up on silence, not on slowness. A download fails (and is retried) after a minute without data instead of three minutes in all, so a slow connection finishes; a body larger than any library (64 MiB) is refused.
- A git dependency between releases gets the engine it pins or a clear failure. Releases
name the gleon commit their libraries were built from (
gleon_ref.txt, in the checksum list); a checkout pinning another commit (ref: mainafter an engine change) fails the build and names the tag to depend on, instead of loading an engine it was not made for. Releases without the file are not checked; the pub.dev archive has no pin. - A
gleon_repobuild runs again only when a file it compiled (cargo's dep-info) or a manifest orCargo.lockchanges, not any file of the checkout (every input without a dep-info of absolute paths). - A library file removed after the build is reported as missing, not as one this host cannot load; a library that is there but lacks a library it needs is reported as one this host cannot load.
loadAppFonts()awaited in a test body (where it cannot finish) no longer breaks later calls;await tester.runAsync(loadAppFonts)is the way there. Concurrent calls share one load, and a failed load is started again by the next call.- The alchemist integration moved to
doc/alchemist.md; maintainer notes toCONTRIBUTING.md.
0.4.0 #
Never tagged: these changes first shipped in 0.5.0.
- Breaking: no per-platform golden folders. The package no longer reads or writes
goldens/<os>-<arch>/: every platform compares the goldens next to the tests, as in Flutter. Folders written by 0.3.0 are ignored; delete them. - Goldens name the platform they were recorded on.
--update-goldensstamps each golden with its platform in a PNG text chunk (gleon:platform, ignored by decoders). Its text is compared there (0.05 of a tile) and ignored elsewhere, with or withoutfallback_platform; a golden without the stamp counts as recorded onfallback_platform. A failure names the platform the golden was recorded on. --update-goldensworks on every platform. A golden recorded on another platform stays while only its text differs (no flip-flop between operating systems over their glyphs) and is written, stamped, when anything else changes; alchemist's forced updates behave the same.fallback_platformis the canonical platform. It warns about goldens recorded elsewhere,--update-goldensthere records them again, andGLEON_REQUIRE_CANONICAL=1makes it compare them as its own (for its CI job).gleon approvestamps the goldens it writes with the platform of their case and prefers thefallback_platform's candidate when several platforms offer one.- Breaking: case reports v5.
golden.platformnames the stamp;golden.fallbackis gone. Libraries of older versions (ffi_path,release_url,gleon_repo) are refused (native ABI 13). bin/check_cases.darttakes--fallback-platformonly (--ownis gone) and fails on goldens recorded on another platform.
0.3.0 #
GleonFileComparatorfor golden harnesses: installed once intest/flutter_test_config.dart, it compares the goldens of every test that callsflutter_test's ownmatchesGoldenFile(alchemist, golden_toolkit, …) with the gleon engine and the rules of.gleon/gleon.yaml. A best-effort path (PNG bytes, text compared like every other pixel): gleon's matcher with a widget stays the fastest and the only one that compares real text right.fromExistingkeeps the golden names of aLocalFileComparatorsubclass (itsgetTestUri) and returns an installedGleonFileComparatoras is. gleon's matcher accepts anyLocalFileComparatorsubclass (it only takes its golden directory; the subclass's threshold does not apply).- alchemist adapter:
package:gleon/alchemist.dart'sgleonAlchemistExpectation(), assigned to alchemist'sgoldenFileExpectationFn, compares every alchemist golden with gleon's matcher: the widget with the boxes of its text, no PNG encoded to compare, no dependency on alchemist. Failures of obscured text (alchemist's CI default) say how to compare real text, failures under a comparator's own threshold (alchemist'sdiffThreshold) that it does not apply. The example app runs it (one set of real-text goldens beside the others, alchemist's runner for the edge cases), with a benchmark: 4.46 → 0.86 ms per passing golden against alchemist's default assertion. - Half the native library: release libraries of about 1 MB instead of 2 MB (macOS arm64
1.88 → 0.98 MB, Linux x64 2.21 → 1.13 MB, Linux arm64 1.97 → 1.00 MB). Globs of
.gleon/gleon.yamlmatch with the smallglobcrate instead of the regex engine ofglobset, and the engine runs on the calling thread instead of a thread pool per test process. - Faster comparisons: the engine reads widget and image captures in place instead of copying
them, equal rows and frames take one
memcmp, the golden is decoded without a copy, and a passing golden without a console line or warning is one native call. Native time per golden: passes 12-42% less, failures 9-26% (gleon-model/tests/perf.rsof the gleon repository); byte inputs influtter test8-11% faster for re-encoded passes and 11-24% for failures, identical bytes unchanged (bench_press diffagainst 0.2.0 on one machine). - Pixel options:
.pixel(channelTolerance:, antiAlias:, edgeThreshold:)(yamlchannel_tolerance,anti_alias,edge_threshold, formode: pixelrules only), all off by default and never applied to text, let small channel deltas, anti-aliased pixels and pixels on the golden's edges count as equal (see the README's "Pixel options" for what each one hides). Values are 0–254. Case reports count them astolerated_pixelsandedge_pixels. A rule's diff keys of the other mode (thresholdunderssim,min_similarity/color_toleranceunderpixel) are config errors instead of being ignored. - Text under
ssim:textTolerance(and a rule'stext_tolerance) works with.ssim()too: text is judged by its tiles and left out of both SSIM gates, so another OS's glyphs no longer fail an SSIM comparison of a widget. Text and masks are left out by taking the golden's pixels, so the pixels around them are compared as strictly as any other (they were painted black before, which hid color changes right next to a mask). - Diffs of every failure: images of different sizes keep a diff image of both sizes (masked
pixels unmarked); SSIM case reports list the
changedandfailingregions with their own metrics, which the gleon CLI's HTML report shows. - Text tiles: a text region thinner than a 16x16 tile, or clipped at the image edge, is judged as a whole tile (the rest of the square counts as equal): one differing pixel of a 4x1 strip is no longer a quarter of a tile.
- Breaking: libraries of 0.2.0 from
ffi_path,release_urlmirrors orgleon_repocheckouts are refused (native ABI 12). Case reports are schema 4 withpolicy_version4 (text tiles and text under SSIM). A yamlmode: pixelrule withoutthresholdallows 0.01 of the pixels (was 0.1), like.pixel(). Globs that would match differently than written, differently on Windows, or never, are config errors naming the pattern:{a,b}alternatives,[^...](use[!...]), a class only/fits ([/]),\,**inside a segment (a**,***), a leading/, a.,..or empty segment (./a,../a,a//b), a trailing/, the empty pattern.
0.2.0 #
The first release, as a git tag.
- Drop-in
matchesGoldenFile: replace theflutter_testimport withpackage:gleon/gleon.dart; without extra parameters goldens behave like Flutter's (exact, resolved relative to the test file, rewritten byflutter test --update-goldens). Widgets,ui.Images and PNG bytes are accepted, as in Flutter. - Tolerance:
tolerance: GoldenTolerancewith.exact(),.pixel(maxDiffRatio:)or.ssim(minSimilarity:, colorTolerance:), an SSIM comparison that tolerates rendering noise but still catches changed content, color changes and blur. - Ignore regions:
ignoreRegionsexcludes rectangles (clocks, animations) from any comparison. - Real text:
loadAppFonts()loads the app's fonts instead of Flutter's box font, andtextTolerancebounds the share of differing pixels in any 16x16 square of text. - Platform-aware goldens:
fallback_platformnames where the goldens are recorded; there text is compared, other platforms compare everything else and ignore text until they record their own goldens ingoldens/<os>-<arch>/. - Suite rules in
.gleon/gleon.yaml: per-path tolerances and masks in the same workspace file as the gleon CLI. - Metrics and case reports: opt-in (
GLEON_METRICS=1) JSON case reports with the headroom to each threshold and a console line per golden, in the gleon CLI's result format; failing goldens keep their golden, candidate and diff images, infailures/next to the test and in.gleon/runs/latest/artifacts/<platform>/; platforms sharing a workspace keep their reports apart (.gleon/runs/latest/cases/<platform>/). - Fast: 5-20x faster than Flutter's own comparator inside
flutter test(see the README's "Performance"). - No Rust needed:
flutter teston macOS arm64, Linux x64/arm64 (Ubuntu 26.04+) and Windows x64 with a prebuilt, checksum-verified native library; therelease_urlandffi_pathuser-defines serve mirrors and offline machines. - Breaking since the git-only 0.0.1:
mode/threshold/minSimilarity/colorToleranceare replaced bytolerance: GoldenTolerance.
0.0.1 #
matchesGoldenFiledrop-in withexact,pixelandssimmodes and ignore regions.- Native library delivered through GitHub Releases (macOS arm64, Linux x64/arm64, Windows x64), verified by SHA-256 and cached by the build hook.
