Skip to content
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

Support running doc tests serially #30

Closed
llamicron opened this issue Feb 20, 2021 · 3 comments
Closed

Support running doc tests serially #30

llamicron opened this issue Feb 20, 2021 · 3 comments

Comments

@llamicron
Copy link

This crate is very useful for my use-case (interacting with hardware), but I have quite a few doc tests that can't be run unless serially. Does this crate support running doc tests serially? If not, could that be supported?

@palfrey
Copy link
Owner

palfrey commented Feb 20, 2021

I've just been experimenting with this, and the following seems to work ok (for values of "doesn't seem to fail"). OTOH, I've been trying a few experiments, and so far I think rustdoc tests are maybe run separately enough that the serial_test usage of a common lock structure just doesn't actually work. Not sure how to fix this barring digging into the rustdoc internals and trying to figure out how to share data between rustdoc tests.

//! ```
//! # #[macro_use] extern crate serial_test;
//! # #[serial_test::serial]
//! # fn main() {
//! assert!(true)
//! # }
//! ```

I've marked the boilerplate bits (everything other than the assert! in this minimal check) as "don't display".

@palfrey
Copy link
Owner

palfrey commented Feb 20, 2021

Yup, I've just confirmed this. Between https://quietmisdreavus.net/code/2018/02/23/how-the-doctests-get-made/ and https://github.com/rust-lang/rust/blob/c4e33b51c1a2d5e599b949fa3006467b88df253a/src/librustdoc/doctest.rs#L233 I've managed to confirm that rustdoc basically makes separate executables for each doctest, and so the standard serial_test methods of locking won't work.

OTOH, I could just use something like https://docs.rs/fslock and make a new attribute that lets you do file-based locking, but that's a notable change that would take me a bit to do and I've got a few other things on my plate at the moment. I might get around to doing this eventually, but if you felt like contributing patches for that it would be appreciated :)

@palfrey
Copy link
Owner

palfrey commented Nov 21, 2021

#43 should solve this.

@palfrey palfrey closed this as completed Nov 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants