Skip to content

Commit

Permalink
Make the test delay a RUSTFLAGS instead of exposed feature
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Apr 26, 2020
1 parent c233601 commit 9bc3201
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ script:
- cargo build
- cargo test
# Adding an extra delay in some places in the code. Makes the tests hit other edge cases.
- cargo test --features test-delay
- RUSTFLAGS="--cfg oneshot_test_delay" cargo test
- LOOM_MAX_BRANCHES=100000 LOOM_LOG=1 RUSTFLAGS="--cfg loom" cargo test
- if [[ $(uname -s) == "Linux" ]]; then
cargo install cargo-valgrind;
./check_mem_leaks.sh;
RUSTFLAGS="--cfg oneshot_test_delay" ./check_mem_leaks.sh;
fi
- if [[ "${TRAVIS_RUST_VERSION}" = "stable" && $(uname -s) == "Linux" ]]; then
rustup component add rustfmt-preview;
Expand Down
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ edition = "2018"
loom = "0.3.2"
criterion = "0.3"

[features]
test-delay = []

[[bench]]
name = "benches"
harness = false
1 change: 0 additions & 1 deletion check_mem_leaks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ for example_path in examples/*.rs; do
example=${example_filename%.*}
echo $example
cargo valgrind --example "$example"
cargo valgrind --features test-delay --example "$example"
done
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl<T> Receiver<T> {
// Conditionally add a delay here to help the tests trigger the edge cases where
// the sender manages to be dropped or send something before we are able to store our
// `Thread` object in the state.
#[cfg(feature = "test-delay")]
#[cfg(oneshot_test_delay)]
std::thread::sleep(std::time::Duration::from_millis(10));

// Allocate and put our thread instance on the heap and then store it in the state.
Expand Down Expand Up @@ -195,7 +195,7 @@ impl<T> Receiver<T> {
// Conditionally add a delay here to help the tests trigger the edge cases where
// the sender manages to be dropped or send something before we are able to store our
// `Thread` object in the state.
#[cfg(feature = "test-delay")]
#[cfg(oneshot_test_delay)]
std::thread::sleep(std::time::Duration::from_millis(10));

// Allocate and put our thread instance on the heap and then store it in the state.
Expand Down Expand Up @@ -291,7 +291,7 @@ impl<T> Receiver<T> {
// Conditionally add a delay here to help the tests trigger the edge cases where
// the sender manages to be dropped or send something before we are able to store our
// `Thread` object in the state.
#[cfg(feature = "test-delay")]
#[cfg(oneshot_test_delay)]
std::thread::sleep(std::time::Duration::from_millis(10));

// Allocate and put our thread instance on the heap and then store it in the state.
Expand Down

0 comments on commit 9bc3201

Please sign in to comment.