only build tests that require thread::scope on nightly

This commit is contained in:
Jorge Aparicio 2022-04-29 15:19:23 +02:00
parent 477c53b25d
commit 3d3277f6d3
3 changed files with 23 additions and 3 deletions

View File

@ -62,5 +62,8 @@ version = "0.1"
version = ">=0.2.0,<0.4"
optional = true
[build-dependencies]
rustc_version = "0.4.0"
[package.metadata.docs.rs]
all-features = true

View File

@ -2,6 +2,8 @@
use std::{env, error::Error};
use rustc_version::Channel;
fn main() -> Result<(), Box<dyn Error>> {
let target = env::var("TARGET")?;
@ -66,5 +68,12 @@ fn main() -> Result<(), Box<dyn Error>> {
_ => {}
}
if !matches!(
rustc_version::version_meta().unwrap().channel,
Channel::Stable | Channel::Beta
) {
println!("cargo:rustc-cfg=unstable_channel");
}
Ok(())
}

View File

@ -1,11 +1,11 @@
#![feature(scoped_threads)]
#![cfg_attr(unstable_channel, feature(scoped_threads))]
#![deny(rust_2018_compatibility)]
#![deny(rust_2018_idioms)]
#![deny(warnings)]
use std::{sync::mpsc, thread};
use std::thread;
use heapless::{mpmc::Q64, spsc};
use heapless::spsc;
#[test]
fn once() {
@ -51,6 +51,7 @@ fn twice() {
}
#[test]
#[cfg(unstable_channel)]
fn scoped() {
let mut rb: spsc::Queue<i32, 5> = spsc::Queue::new();
@ -75,6 +76,7 @@ fn scoped() {
#[test]
#[cfg_attr(miri, ignore)] // too slow
#[cfg(unstable_channel)]
fn contention() {
const N: usize = 1024;
@ -120,7 +122,12 @@ fn contention() {
#[test]
#[cfg_attr(miri, ignore)] // too slow
#[cfg(unstable_channel)]
fn mpmc_contention() {
use std::sync::mpsc;
use heapless::mpmc::Q64;
const N: u32 = 64;
static Q: Q64<u32> = Q64::new();
@ -166,6 +173,7 @@ fn mpmc_contention() {
#[test]
#[cfg_attr(miri, ignore)] // too slow
#[cfg(unstable_channel)]
fn unchecked() {
const N: usize = 1024;