How to debug? #238
-
I want to debug the rust code, how should I do it? Currently, I am calling it through But, this method is very inefficient and it is not easy to find problems. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Beta Was this translation helpful? Give feedback.
-
It depends on the granularity of what you're trying to test, but you might want to try writing rust unit tests within the module you're trying to debug. To run a specific test you can specify the name of the function you defined: cargo test name_of_my_test_case And if you want to make sure that any logging you do actually gets displayed in the console, include the cargo test name_of_my_test_case -- --nocapture For things that can't be simulated entirely on the rust side I typically do as you describe: |
Beta Was this translation helpful? Give feedback.
It depends on the granularity of what you're trying to test, but you might want to try writing rust unit tests within the module you're trying to debug. To run a specific test you can specify the name of the function you defined:
cargo test name_of_my_test_case
And if you want to make sure that any logging you do actually gets displayed in the console, include the
--nocapture
flag:cargo test name_of_my_test_case -- --nocapture
For things that can't be simulated entirely on the rust side I typically do as you describe:
dbg!
andprintln!
to peek at values)make
rule to do an un-optimized buildnode my-test-script.js