Skip to content

Commit

Permalink
Try to fix tests on stable Rust
Browse files Browse the repository at this point in the history
This required introducing a new "nightly" feature.
  • Loading branch information
vks committed Apr 19, 2021
1 parent 4538ff7 commit dd64d20
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Expand Up @@ -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"] }
Expand Down
2 changes: 1 addition & 1 deletion src/distribution/beta.rs
Expand Up @@ -369,7 +369,7 @@ impl Continuous<f64, f64> for Beta {
}

#[rustfmt::skip]
#[cfg(test)]
#[cfg(all(test, feature = "nightly"))]
mod tests {
use super::*;
use crate::consts::ACC;
Expand Down
2 changes: 1 addition & 1 deletion src/distribution/gamma.rs
Expand Up @@ -322,7 +322,7 @@ pub fn sample_unchecked<R: Rng + ?Sized>(rng: &mut R, shape: f64, rate: f64) ->
}
}

#[cfg(test)]
#[cfg(all(test, feature = "nightly"))]
mod tests {
use super::*;
use crate::consts::ACC;
Expand Down
1 change: 1 addition & 0 deletions src/distribution/internal.rs
Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Expand Up @@ -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;
Expand Down

0 comments on commit dd64d20

Please sign in to comment.