mock-io icon indicating copy to clipboard operation
mock-io copied to clipboard

Panic if dropped before script is complete

Open the6p4c opened this issue 6 years ago • 2 comments

First, this crate's been really useful :) Writing a tool with a lot of serial port transactions and this has been a godsend.

However, I've been peppering calls in every test to a helper function I wrote, is_script_complete, to check that all the actions of the mock have been executed. Since the point is that the actions have to follow the script otherwise a panic is generated, I think it'd be more useful for the mock to panic if it's Dropped with actions still pending.

I'd be happy to implement this if it seems like it would be useful. I'd assume it would have to be behind some kind of configuration option, to avoid breaking existing tests which rely on it not causing a panic. LMK if this seems useful and if I should go ahead.

the6p4c avatar Jul 08 '19 04:07 the6p4c

We are moving the contents of this crate into tokio-test (https://github.com/tokio-rs/tokio/pull/1290).

Maybe we can move the discussion there? If you are using mock-io in a synchronous context, then we probably should discuss the path forward.

carllerche avatar Jul 15 '19 22:07 carllerche

Yeah - synchronous context. Running with default-features = false, features = [] so it's just the most basic functionality the crate gives that I'm using.

the6p4c avatar Jul 16 '19 01:07 the6p4c