Skip to content

Commit

Permalink
tests: Use build-context crate for robustness
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed May 1, 2023
1 parent ee3443f commit eea4a62
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ critical-section = { version = "1", optional = true }
[dev-dependencies]
test-helper = { path = "tests/helper", features = ["std"] }

build-context = "0.1"
crossbeam-utils = "0.8"
fastrand = "1"
paste = "1"
Expand Down
1 change: 1 addition & 0 deletions bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ std = []
test-helper = { path = "../tests/helper", features = ["std"] }

atomic = "0.5"
build-context = "0.1"
criterion = { default-features = false, git = "https://github.com/taiki-e/criterion.rs.git", branch = "dev" } # reduce deps
crossbeam-utils = "0.8"
fastrand = "1"
Expand Down
13 changes: 5 additions & 8 deletions src/tests/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,7 @@ fn skip_should_panic_test() -> bool {
test_helper::is_panic_abort()
|| cfg!(miri)
|| option_env!("CARGO_PROFILE_RELEASE_LTO").map_or(false, |v| v == "fat")
&& option_env!("MSAN_OPTIONS").is_some()
&& build_context::SANITIZE.contains("memory")
}

// Test the cases that should not fail if the memory ordering is implemented correctly.
Expand Down Expand Up @@ -2161,18 +2161,15 @@ macro_rules! __stress_test_seqcst {
($atomic_type:ident, $write:ident, $load_order:ident, $store_order:ident) => {{
use super::*;
use crossbeam_utils::thread;
use std::{
env,
sync::atomic::{AtomicUsize, Ordering},
};
use std::sync::atomic::{AtomicUsize, Ordering};
let n: usize = if cfg!(miri) {
8
} else if cfg!(valgrind)
|| option_env!("ASAN_OPTIONS").is_some()
|| option_env!("MSAN_OPTIONS").is_some()
|| build_context::SANITIZE.contains("address")
|| build_context::SANITIZE.contains("memory")
{
50
} else if env::var_os("GITHUB_ACTIONS").is_some() && cfg!(not(target_os = "linux")) {
} else if option_env!("GITHUB_ACTIONS").is_some() && cfg!(not(target_os = "linux")) {
// GitHub Actions' macOS and Windows runners are slow.
5_000
} else {
Expand Down

0 comments on commit eea4a62

Please sign in to comment.