Move structs and enums in test into separate crate

I'd like to propose moving the definitions of structs such as TestDesc, TestDescAndFn etc. in libtest into a separate crate.


I'm interested in using the #[test] annotation in a no_std environment, together with custom_test_frameworks. I'm aware of #[test_case], however I would like to be able to also use #[should_panic]. The rust compiler already parses this attribute and makes it available in the TestDesc struct. When using no_std using libtest is currently not possible, since it requires panic_abort or panic_unwind and std. The panic part is problematic, since this clashes with the custom panic_handler in no_std applications.


Moving the definitions of the structs and enums into a seperate (internal) crate would allow #[test] to work with custom_test_frameworks and no_std. The parsing of should_panic and other attributes is done at compile time and requires no special runtime support. The #[test] attribute should then work without libtest and only require the new internal crate containing the struct definitions, when used together with a custom_test_framework.

Alternative repr(C)

I could also make do with manually copying the definitions, as long as they have a defined layout via #[repr(C)]. Since libtest may change at any time, this is obviously not a preferred solution.

I hope this is the right place to ask about this. Are there any reasons I missed, why this is not feasible?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.