Skip to content

Commit

Permalink
Merge pull request #355 from tzemanovic/tomas/fix-sm-logs
Browse files Browse the repository at this point in the history
state-machine: fix logging by adding "std" feature
  • Loading branch information
rex-remind101 authored Aug 31, 2023
2 parents 7292965 + a6cd942 commit fc3be95
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
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

0 comments on commit fc3be95

Please sign in to comment.