From dd64d20bea2d046aad897fe09533f12e60086cb3 Mon Sep 17 00:00:00 2001 From: Vinzent Steinberg Date: Mon, 19 Apr 2021 17:45:56 -0300 Subject: [PATCH] Try to fix tests on stable Rust This required introducing a new "nightly" feature. --- .travis.yml | 7 ++++++- Cargo.toml | 4 +++- src/distribution/beta.rs | 2 +- src/distribution/gamma.rs | 2 +- src/distribution/internal.rs | 1 + src/lib.rs | 4 ++-- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index c140f8c6..4483b13f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,12 @@ before_script: script: - cargo fmt --all -- --check - cargo build - - cargo test + - > + if [[ "$TRAVIS_RUST_VERSION" == "nightly" ]]; then + cargo test --features nightly + else + cargo test + fi after_success: > if [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$TRAVIS_RUST_VERSION" == "stable" ]]; then diff --git a/Cargo.toml b/Cargo.toml index bb2a22fb..83699ea7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,10 +13,12 @@ repository = "https://github.com/boxtown/statrs" edition = "2018" [lib] - name = "statrs" path = "src/lib.rs" +[features] +nightly = [] + [dependencies] rand = "0.8" nalgebra = { version = "0.26", features = ["rand"] } diff --git a/src/distribution/beta.rs b/src/distribution/beta.rs index d384bc5b..a477ff4d 100644 --- a/src/distribution/beta.rs +++ b/src/distribution/beta.rs @@ -369,7 +369,7 @@ impl Continuous for Beta { } #[rustfmt::skip] -#[cfg(test)] +#[cfg(all(test, feature = "nightly"))] mod tests { use super::*; use crate::consts::ACC; diff --git a/src/distribution/gamma.rs b/src/distribution/gamma.rs index cbdf6d92..33435ab8 100644 --- a/src/distribution/gamma.rs +++ b/src/distribution/gamma.rs @@ -322,7 +322,7 @@ pub fn sample_unchecked(rng: &mut R, shape: f64, rate: f64) -> } } -#[cfg(test)] +#[cfg(all(test, feature = "nightly"))] mod tests { use super::*; use crate::consts::ACC; diff --git a/src/distribution/internal.rs b/src/distribution/internal.rs index 016227f4..eebe53f3 100644 --- a/src/distribution/internal.rs +++ b/src/distribution/internal.rs @@ -18,6 +18,7 @@ pub mod test { use crate::consts::ACC; use crate::distribution::{Continuous, ContinuousCDF, Discrete, DiscreteCDF}; + #[cfg(feature = "nightly")] #[macro_export] macro_rules! testing_boiler { ($arg:ty, $dist:ty) => { diff --git a/src/lib.rs b/src/lib.rs index 9970aea9..b8970d61 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,8 +29,8 @@ #![allow(clippy::many_single_char_names)] #![allow(unused_imports)] #![forbid(unsafe_code)] -#![cfg_attr(test, feature(unboxed_closures))] -#![cfg_attr(test, feature(fn_traits))] +#![cfg_attr(all(test, feature = "nightly"), feature(unboxed_closures))] +#![cfg_attr(all(test, feature = "nightly"), feature(fn_traits))] #[macro_use] extern crate approx;