-
Notifications
You must be signed in to change notification settings - Fork 69
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
Introduce MockVM #1049
Introduce MockVM #1049
Conversation
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.
I think the MockAny may not work because the original closures are supposed to accept objects that are implemented with different type arguments. But this fact still doesn't prevent us from doing mock tests for those methods. I have given concrete examples in in-line comments. For the root-scanning methods, we simply let the closure provide the list of roots instead of making a dyn
callback objects from it to call. Similarly, for the weak reference processing methods, we just let the closure list the object references to be traced.
However, I tried to write a mock test case for testing the ScanVMSpecificRoots
work packet, but failed because I found it hard to instantiate a concrete ProcessEdgesWorkRootWorkFactory
without knowing the plan.
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.
LGTM
This PR introduces
MockVM
, a type that implementsVMBinding
and allows users to control the behavior of each method for testing. This PR also moves all the tests in the currentDummyVM
toMockVM
, and removes the currentDummyVM
.This PR closes #99. Note that the current
MockVM
implementation does not allow changing constants or associated types inVMBinding
-- I would suggest we create another issue to track this problem.Changes:
MockVM
, and write all the currentDummyVM
tests withMockVM
.DummyVM
, and remove./examples
which usesDummyVM
.MockVM
.pub
visibility for some modules. Those modules were exposed so we can test them fromDummyVM
. As nowMockVM
is a part of the main crate, we can test private items. We no longer needpub
for those modules.