Skip to content

Commit 3d3277f

Browse files
committed
only build tests that require thread::scope on nightly
1 parent 477c53b commit 3d3277f

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,8 @@ version = "0.1"
6262
version = ">=0.2.0,<0.4"
6363
optional = true
6464

65+
[build-dependencies]
66+
rustc_version = "0.4.0"
67+
6568
[package.metadata.docs.rs]
6669
all-features = true

build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
use std::{env, error::Error};
44

5+
use rustc_version::Channel;
6+
57
fn main() -> Result<(), Box<dyn Error>> {
68
let target = env::var("TARGET")?;
79

@@ -66,5 +68,12 @@ fn main() -> Result<(), Box<dyn Error>> {
6668
_ => {}
6769
}
6870

71+
if !matches!(
72+
rustc_version::version_meta().unwrap().channel,
73+
Channel::Stable | Channel::Beta
74+
) {
75+
println!("cargo:rustc-cfg=unstable_channel");
76+
}
77+
6978
Ok(())
7079
}

tests/tsan.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#![feature(scoped_threads)]
1+
#![cfg_attr(unstable_channel, feature(scoped_threads))]
22
#![deny(rust_2018_compatibility)]
33
#![deny(rust_2018_idioms)]
44
#![deny(warnings)]
55

6-
use std::{sync::mpsc, thread};
6+
use std::thread;
77

8-
use heapless::{mpmc::Q64, spsc};
8+
use heapless::spsc;
99

1010
#[test]
1111
fn once() {
@@ -51,6 +51,7 @@ fn twice() {
5151
}
5252

5353
#[test]
54+
#[cfg(unstable_channel)]
5455
fn scoped() {
5556
let mut rb: spsc::Queue<i32, 5> = spsc::Queue::new();
5657

@@ -75,6 +76,7 @@ fn scoped() {
7576

7677
#[test]
7778
#[cfg_attr(miri, ignore)] // too slow
79+
#[cfg(unstable_channel)]
7880
fn contention() {
7981
const N: usize = 1024;
8082

@@ -120,7 +122,12 @@ fn contention() {
120122

121123
#[test]
122124
#[cfg_attr(miri, ignore)] // too slow
125+
#[cfg(unstable_channel)]
123126
fn mpmc_contention() {
127+
use std::sync::mpsc;
128+
129+
use heapless::mpmc::Q64;
130+
124131
const N: u32 = 64;
125132

126133
static Q: Q64<u32> = Q64::new();
@@ -166,6 +173,7 @@ fn mpmc_contention() {
166173

167174
#[test]
168175
#[cfg_attr(miri, ignore)] // too slow
176+
#[cfg(unstable_channel)]
169177
fn unchecked() {
170178
const N: usize = 1024;
171179

0 commit comments

Comments
 (0)