-
Notifications
You must be signed in to change notification settings - Fork 44
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
Unable to run Rust unittests on binded library #170
Comments
Hi @ziv, thanks for opening the issue, and for the great reproduction! I think I see two things happening here:
I think this is due to the fact that #[node_bindgen]
pub fn sum(first: i32, second: i32) -> i32 {
sum_impl(first, second)
}
pub fn sum_impl(first: i32, second: i32) -> i32 {
first + second
}
// Then unit test `sum_impl` Let me know if that pattern works for you! |
Seems like this is solved problem. Closing this. Feel to re-open if this doesn't the solve |
We should add this to documentation |
Hi @nicholastmosher, while your solution is simple to use when my API is minimal, I have a library exports structs and their implementations. Using this method is practically - copy all my code just to export it. |
Test failure happens because actual rust fn
So one way is to move inner fn as peer:
|
Running Rust testing on binded library generate errors.
Reproduction:
https://github.com/ziv/node-bindgen-unitest-error-reproduction
Expected behavior:
Running tests should pass.
Actual behavior:
Error
Workaround
Removing
#[node_bindgen]
decorator works.Example for output after commented the decorator:
The text was updated successfully, but these errors were encountered: