fix: run golden tests with test optimization enabled#388
Merged
felangel merged 7 commits intoVeryGoodOpenSource:mainfrom Jun 2, 2022
Merged
fix: run golden tests with test optimization enabled#388felangel merged 7 commits intoVeryGoodOpenSource:mainfrom
felangel merged 7 commits intoVeryGoodOpenSource:mainfrom
Conversation
Contributor
Author
|
@felangel would you mind reviewing this? Thanks! |
Contributor
|
Thank you for your contribution! Our bundles come from an internal brick repository currently, so we normally supply the change there and then do a PR here. But I will merge this as-is so we don't lose your contribution, as soon as the CI succeeds! Just for your information, I'll supply some extra changes from our internal bricks in a separate PR to keep it up to date with that repo. In case you see another PR today that changes your code ;-), it wont change any of the functionality that your provided. Once again thanks for this PR! |
7 tasks
ahsanf
pushed a commit
to Arkabyte-Teknologi/very_good_cli
that referenced
this pull request
Aug 12, 2025
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
This fixes #363.
Currently, golden tests fail when running them with
very_good testwith test optimization enabled. This is becausegoldenFileComparatorsearches for the golden files relative from the currently running test file. With optimization enabled, the golden files are searched from the.test_runner.dartfile instead of from the original test files.The solution I suggest is to use a custom implementation for
goldenFileComparatorwhich knows about the implications of the test optimization. It finds the correct absolute path of the golden file by searching for a single file ending with the given relative path from the test base directory. For further details, see my comment here: #363 (comment)This approach fails in the following situation:
test/a/foo_test.dartuses the relative pathgoldens/foo.pngto refer to the golden image attest/a/goldens/foo.pngtest/b/foo_test.dartuses the same relative pathgoldens/foo.pngto refer to the golden image attest/b/goldens/foo.pngIn that case, searching for files ending with the path
goldens/foo.pngdoes not return a single result but two possible results. An exception will be thrown in that case. I think this is ok because it is a rather theoretical edge case and this approach solves all realistic cases.Type of Change