-
Notifications
You must be signed in to change notification settings - Fork 81
Introduce MockVM #1049
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
Conversation
wks
left a comment
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.
wks
left a comment
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 implementsVMBindingand allows users to control the behavior of each method for testing. This PR also moves all the tests in the currentDummyVMtoMockVM, and removes the currentDummyVM.This PR closes #99. Note that the current
MockVMimplementation 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 currentDummyVMtests withMockVM.DummyVM, and remove./exampleswhich usesDummyVM.MockVM.pubvisibility for some modules. Those modules were exposed so we can test them fromDummyVM. As nowMockVMis a part of the main crate, we can test private items. We no longer needpubfor those modules.