-
Notifications
You must be signed in to change notification settings - Fork 134
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
Override Test ID to ensure trait dependencies are cached #293
base: main
Are you sure you want to change the base?
Override Test ID to ensure trait dependencies are cached #293
Conversation
It seems like this could also be solved with a Is there a plan for how to be backwards compatible with different versions of |
@jflan-dd Thanks for looking into this and putting together a PR! We'll try to review it soon. |
@stephencelis I created a separate PR in |
@jflan-dd This hasn't fallen off our radar but we haven't had time to fully review and grok things yet. Hopefully soon! |
@stephencelis no problem. We're working around this issue by explicitly setting the mock dependency inside of the update block so that the For additional context my understanding of the issue is that because This results in caching the updated dependency with an invalid cache key, which causes a cache miss when the dependency is accessed during the test. This image shows a breakpoint while accessing the dependency within the body of a test. The cache contains a dependency with the same |
I ran into an issue where reference typed dependencies weren't correctly cached if they were updated in-place rather than being fully overridden.
The root cause of this seems to be that
Test.current
isn't set duringprepare(for test: Test)
and as a result theCacheKey.testIdentifier
wasnil
during dependency setup.This PR creates an internalTestID
struct that can be explicitly overridden during dependency prep, but perhaps there's a more elegant solution that could be implemented inxctest-dymaic-overlay
directly.This PR is dependent on pointfreeco/swift-issue-reporting#137