How to manually invoke main test function

Hi all, This is a somewhat complex question that requires a bit of background, so please bear with me a little bit. I've bolded the question itself to make it easier to find.


I'm working on a project that runs on an ESP32, and it is created using multiple crates in a single cargo workspace.

For somewhat unclear reasons (that appear to be related to the fact that the ESP32 uses a RTOS with a non-standard main function for user code), running cargo test will properly execute all unit tests in the main binary crate (i.e. the one with a file in it), but the library crates (which solely contain a file) will not run any tests, nor will it even display the basic test that occurs before and after execution of the tests

After disassembling some compiled binaries (which shows that the RTOS user-code main function was empty) and conversing with some people involved int the development of the ESP32 support crates, I was able to figure out how to add a function that will be called by the user-code main function.

The question

What do I need to now place within this function that will then in turn execute all of my unit tests? Is there some sort of run_all_tests function that I need to call from the standard library or something?

Additional Info

This is the project that I am currently working on:

The main binary crate is environment-monitor, while the crate that I am currently attempting to get the tests to run in is the veml7700 crate.

The function that need to have the logic in it to run all of my tests is in veml7700/src/ and is called app_main. Currently it has a print statement in it that will output "What do I need to put here to execute all of my unit tests?"

Minor Edit: Linking to a specific commit in the repo, so if files change, the question still links to the correct version.

Ok. I did not find a solution to the actual question, but I did find the solution to my specific situation.

I don't need to be defining a custom app_main function. I use need to have the line use esp_idf_sys in my test module (i.e. mod tests).

This will make the library crate run the tests properly.

Since I did not actually answer my core question, I'm not going to mark this reply as a solution.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.