-
Notifications
You must be signed in to change notification settings - Fork 0
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
#[inject] is not thread-safe #7
Comments
Thank you for reporting this. I am able to reproduce this error after running the command a bunch of times. Hopefully there is a way to protect this from occurring, I will look to see if there is a solution. |
Unfortunately, there seems to be no easy way around this issue. As a result, I have removed one of the conflicting tests from the file, to avoid the random crashes. However, this seems to be indicative a fatal limitation in this crate. |
Could you key |
Unfortunately, the mock and inject steps are completely independent of each other and I cannot find a way share namespace type information between them when defining the context key. One way to maybe get around it is to make them define as many keys up front as they would like to mock, such as fun1|fun2="...". At that point, it becomes pretty unergonomic unfortunately, I am not sure if it is even worth pursuing. |
Repro step:
cargo test --test test
The problem is that
test_with_silly_func_1
andtest_with_silly_func_2
will both modify the same_mock_me_test_context_instance
. Now imagine the following sequence:_mock_me_test_context_instance.set(replacement_1)
_mock_me_test_context_instance.set(replacement_2)
function_with_fun_id()
_mock_me_test_context_instance.get()
silly_func
becomesreplacement_2
replacement_2(30, 20)
assert_eq!(600, 10)
Tested with
mock_me = "0.2.2"
on crates.io.The text was updated successfully, but these errors were encountered: