-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
maint(testutils/golden): Add GoldenTracker to track the used golden files and use it #601
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #601 +/- ##
==========================================
+ Coverage 82.84% 82.88% +0.04%
==========================================
Files 80 80
Lines 8514 8514
Branches 75 75
==========================================
+ Hits 7053 7057 +4
+ Misses 1130 1127 -3
+ Partials 331 330 -1 ☔ View full report in Codecov by Sentry. |
It allows to fetch the list of tests that are requested to run from arguments
If a test using a golden file gets renamed or removed we don't have any strategy to check if the related golden file(s) got updated as well. To make this possible, add a new struct that allows tests to track their test cases and check if the related golden files are being used, or fail otherwise
8a11d6b
to
69b42f1
Compare
69b42f1
to
5689351
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I have some reservations regarding these changes:
-
If the golden tracker is being used in every test that relies on golden files, then it should become a required argument of the
LoadWithUpdateGolden
functions instead of an optional one. -
If we are using it on every single test instance, maybe we can figure out a way of not having to "manually" instantiate the tracker and hook it to the test? I didn't investigate more into this yet, so I'm not sure if it's possible, but maybe it's worth a look?
Also, some food for thoughts: Is this even necessary?
I know it could be useful not having to worry about cleaning golden files, but, IMHO, remembering to delete/rename the files should be akin to renaming a variable/function in the code, i.e. when we rename/remove a test, we must remember to look at what this renaming/removing will trigger and adjust it, no? Manually dealing with golden files can be a pain, but it also helps us figure out what went wrong or what behavior is not covered/is not required anymore. Particularly, when I need to update a test or a test case, I remove every single golden file related to that test and then run the update command, then I look at the git diff to see if that's what I expected to happen (if the changes make sense, what file is missing, what file is new and so on).
I wouldn't define it necessary, but it's an useful helper to avoid leaving around leftovers... We normally remove them, but as proved in various previous PRs we're not great at that since it happened already various times of having leftovers... |
I'm very much in favor of automating the cleanup of obsolete golden files. I've seen multiple cases already where we forgot to remove a golden file and didn't notice it before merging.
The git diff will still tell us what's happening, and if it's ensured that obsolete golden files are removed, the diff better reflects the impact of the change (it will show you what is not being tested anymore). |
+1. However, keep in mind the cases where we only have some subtests running (with a In adsys, we didn’t really get the case due to file tree projectionning, but here, the approach is slightly different. |
Yah, this is already considered and handled: So, for the same reason we may do this as a form of a test, but running as last isn't possible. |
If a test using a golden file gets renamed or removed we don't have any
strategy to check if the related golden file(s) got updated as well.
To make this possible, add a new struct that allows tests to track their
test cases and check if the related golden files are being used, or fail
otherwise
/cc @adombeck as per comments in #598 (comment)