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

state-machine: fix logging by adding "std" feature #355

Merged
merged 2 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions proptest-state-machine/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
## Unreleased

### Bug Fixes

- Fixed logging of state machine transitions to be enabled when verbose config is >= 1. The "std" feature is added to proptest-state-machine as a default feature that allows to switch the logging off in non-std env.
12 changes: 11 additions & 1 deletion proptest-state-machine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@ description = """
State machine based testing support for proptest.
"""

[features]
default = ["std"]

# Enables the use of standard-library dependent features
std = ["proptest/std"]

[dependencies]
proptest = { version = "1.2.0", path = "../proptest" }
proptest = { version = "1.2.0", path = "../proptest", default-features = true, features = [
"fork",
"timeout",
"bit-set",
] }

[dev-dependencies]
message-io = "0.17.0"
7 changes: 5 additions & 2 deletions proptest-state-machine/src/test_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ pub trait StateMachineTest {
<Self::Reference as ReferenceStateMachine>::Transition,
>,
) {
#[cfg(feature = "std")]
use proptest::test_runner::INFO_LOG;

let trans_len = transitions.len();
#[cfg(feature = "std")]
if config.verbose >= super::INFO_LOG {
if config.verbose >= INFO_LOG {
eprintln!();
eprintln!("Running a test case with {} transitions.", trans_len);
}
Expand All @@ -89,7 +92,7 @@ pub trait StateMachineTest {

for (ix, transition) in transitions.into_iter().enumerate() {
#[cfg(feature = "std")]
if config.verbose >= super::INFO_LOG {
if config.verbose >= INFO_LOG {
eprintln!();
eprintln!(
"Applying transition {}/{}: {:?}",
Expand Down