Skip to content

Commit

Permalink
Fix rand_core 0.3 dependency; hack tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Oct 3, 2018
1 parent c89a217 commit bd225a7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,27 @@ sudo: false
# - pinned stable, latest stable, beta and nightly Rust releases
# - Linux, OS X, Android, iOS, bare metal (i.e. no_std)
# - x86_64, ARMv7, a Big-Endian arch (MIPS)
# HACK: use --tests to disable doc-tests for rand_core 0.2 (see #619)
matrix:
include:
- rust: 1.22.0
install:
script:
- cargo test --tests --no-default-features
- cargo test --package rand_core --no-default-features
- cargo test --package rand_core:0.2.2 --no-default-features --tests
- cargo test --features serde1,log
- rust: stable
os: osx
install:
script:
- cargo test --tests --no-default-features
- cargo test --package rand_core --no-default-features
- cargo test --package rand_core:0.2.2 --no-default-features --tests
- cargo test --features serde1,log
- rust: beta
install:
script:
- cargo test --tests --no-default-features
- cargo test --package rand_core --no-default-features
- cargo test --package rand_core:0.2.2 --no-default-features --tests
- cargo test --features serde1,log
- rust: nightly
install:
Expand All @@ -34,13 +35,13 @@ matrix:
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
script:
- cargo test --tests --no-default-features --features=alloc
- cargo test --package rand_core --no-default-features --features=alloc,serde1
- cargo test --package rand_core:0.2.2 --no-default-features --features=alloc,serde1 --tests
- cargo test --features serde1,log,nightly,alloc
- cargo test --all --benches
# remove cached documentation, otherwise files from previous PRs can get included
- rm -rf target/doc
- cargo doc --no-deps --all --all-features
- cargo deadlinks --dir target/doc
#- rm -rf target/doc
#- cargo doc --no-deps --all --all-features
#- cargo deadlinks --dir target/doc
after_success:
- travis-cargo --only nightly doc-upload

Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ install:
build: false

test_script:
- cargo test --all # cannot use --all and --features together
- cargo test --all --tests # cannot use --all and --features together
- cargo test --all --benches
- cargo test --features serde1,log,nightly
- cargo test --tests --no-default-features --features=alloc,serde1
- cargo test --package rand_core --no-default-features --features=alloc,serde1
- cargo test --package rand_core:0.2.2 --no-default-features --features=alloc,serde1 --tests
6 changes: 2 additions & 4 deletions rand_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ appveyor = { repository = "rust-random/rand" }
[features]
std = ["rand_core/std"] # use std library; should be default but for above bug
alloc = ["rand_core/alloc"] # enables Vec and Box support without std
serde1 = ["rand_core/serde", "rand_core/serde_derive"] # enables serde for BlockRng wrapper
serde1 = ["rand_core/serde1"] # enables serde for BlockRng wrapper

[dependencies]
rand_core = "0.3"
serde = { version = "1", optional = true }
serde_derive = { version = "^1.0.38", optional = true }
rand_core = { version = "0.3", default-features = false }
2 changes: 1 addition & 1 deletion src/distributions/other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl<T> Distribution<Wrapping<T>> for Standard where Standard: Distribution<T> {
mod tests {
use {Rng, RngCore, Standard};
use distributions::Alphanumeric;
#[cfg(all(not(feature="std"), feature="alloc"))] use alloc::String;
#[cfg(all(not(feature="std"), feature="alloc"))] use alloc::string::String;

#[test]
fn test_misc() {
Expand Down
6 changes: 3 additions & 3 deletions src/seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use super::Rng;
// This crate is only enabled when either std or alloc is available.
// BTreeMap is not as fast in tests, but better than nothing.
#[cfg(feature="std")] use std::collections::HashMap;
#[cfg(not(feature="std"))] use alloc::btree_map::BTreeMap;
#[cfg(not(feature="std"))] use alloc::collections::btree_map::BTreeMap;

#[cfg(not(feature="std"))] use alloc::Vec;
#[cfg(not(feature="std"))] use alloc::vec::Vec;

/// Randomly sample `amount` elements from a finite iterator.
///
Expand Down Expand Up @@ -227,7 +227,7 @@ mod test {
use super::*;
use {XorShiftRng, Rng, SeedableRng};
#[cfg(not(feature="std"))]
use alloc::Vec;
use alloc::vec::Vec;

#[test]
fn test_sample_iter() {
Expand Down
4 changes: 2 additions & 2 deletions utils/ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ main() {

if [ ! -z $NIGHTLY ]; then # have nightly Rust
cross test --tests --no-default-features --features alloc --target $TARGET
cross test --package rand_core --no-default-features --features alloc --target $TARGET
cross test --package rand_core:0.2.2 --no-default-features --features alloc --target $TARGET --tests
cross test --features serde1,log,nightly,alloc --target $TARGET
cross test --all --benches --target $TARGET
else # have stable Rust
cross test --tests --no-default-features --target $TARGET
cross test --package rand_core --no-default-features --target $TARGET
cross test --package rand_core:0.2.2 --no-default-features --target $TARGET --tests
cross test --features serde1,log --target $TARGET
fi
}
Expand Down

0 comments on commit bd225a7

Please sign in to comment.