feat: Scope golden failure artifacts to environment directories - #179
Open
RyanHolanda wants to merge 1 commit into
Open
feat: Scope golden failure artifacts to environment directories#179RyanHolanda wants to merge 1 commit into
RyanHolanda wants to merge 1 commit into
Conversation
When golden tests run with both platform and CI variants (via Alchemist's
TestVariant mechanism), both variants write failure diff images to the
same flat failures/ directory, overwriting each other.
This change:
- Adds environmentName parameter to AlchemistFileComparator
- Overrides getFailureFile() to write to failures/{env}/ instead of failures/
- Always wraps the comparator when environmentName is provided, not only
when diffThreshold > 0
- Passes variantConfig.environmentName from goldenTest through to the
runner
Now when both [macOS] and [CI] variants fail, the failure artifacts go to:
failures/macos/foo_masterImage.png
failures/ci/foo_masterImage.png
Closes: #N/A
RyanHolanda
requested review from
a team,
Kirpal,
btrautmann,
jeroen-meijer,
jolexxa and
marcossevilla
as code owners
July 8, 2026 19:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When golden tests run with both platform and CI variants (via Alchemist's
TestVariantmechanism), Flutter's defaultgetFailureFile()uses only the filename portion of the golden URI to name failure diff images. Since both variants produce the same filename (e.g.,my_widget.png), the macOS and CI failure artifacts overwrite each other in the flatfailures/directory.This change scopes failure artifact output to environment-specific subdirectories (
failures/{env}/), so each variant's diff images coexist without collision.Before: macOS and CI failures both write to the same files:
After: Each variant writes to its own directory:
Implementation
AlchemistFileComparator— accepts an optionalenvironmentNameparameter. OverridesgetFailureFile()to write tofailures/{env}/when the name is provided.FlutterGoldenTestRunner.run()— always wraps the comparator whenenvironmentNameis provided (previously only whendiffThreshold > 0).goldenTest()— passesvariantConfig.environmentName(e.g.,"macOS","CI") through to the runner.environmentNameisnull, behavior is unchanged.Type of Change