diff --git a/.travis.yml b/.travis.yml index f3790dc0804..bb4ce0fb9fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,160 +1,42 @@ language: rust sudo: false -# We support too many combinations of Rust releases, crate features, operating -# systems, and architectures to even remotely test all combinations. -# Yet it turns out we can test most of these independent of each other, because -# they serve different goals or test different pieces of code. -# -# RUST RELEASES -# Goal: make sure we don't use language features unavailable on a certain -# version, and build without warnings. -# We have different builders use 4 Rust releases, a pinned stable release, -# the latest stable, beta and nightly. -# -# ARCHITECTURES -# Goal: test against issues caused by differences in endianness, pointer sizes, -# etc. -# We run tests on 4 different architectures. -# - x64_84, default on Travis (Linux) and AppVeyor (Windows) -# - i686, second AppVeyor (Windows) configuration -# - MIPS, big-endian Linux emulated with QEMU (thanks to Trust) -# - ARMv7, Android emulated with QEMU (thanks to Trust) -# -# OPERATING SYSTEMS -# Goal: test on many operating systems, to verify the OsRng code, which is -# mostly architecture-independent. -# We run tests on Linux, OS X, Windows, Android (emulated), and Node.js (using -# cargo-web). -# One builder cross-compiles for many of the remaining OSes, which ensures we -# keep building, but doesn't run tests. -# OSes supported by Rand but which we can't cross-compile because there -# is no pre-built standard library available: Dragonfly BSD, Haiku, OpenBSD. -# -# CRATE FEATURES, TESTS, AND SUB-CRATES -# Goal: Run unit tests, doctests, examples, and test benchmarks for all crates, -# in configurations that cover all interesting combinations of features. -# Tests run on rand: -# - test no_std support, but only the unit tests: -# `cargo test --tests --no-default-features` -# - test no_std support, including the alloc feature: -# cargo test --tests --no-default-features --features=alloc -# - run unit tests and doctests with all features which are available on stable: -# `cargo test --features=serde1,log` -# - test examples: -# `cargo test --examples` -# Additional tests on nightly: -# - run unit tests and doctests with all features which are available on nightly: -# `cargo test --all-features` -# - run benchmarks as tests: -# `cargo test --benches --features=nightly` -# Tests on subcrates: -# - select crates via --manifest-path (more reliable than --package) -# - test appropriate feature matrix -# -# TODO: SIMD support on stable releases -# NOTE: SIMD support is unreliable on nightly; we track the latest release -# NOTE: Test for alloc feature in no_std is not included here because it depends -# on the alloc crate stabilized in Rust 1.36. +# Since most OS-specific code has moved to the getrandom crate, we require +# few target-specific tests here. + matrix: include: - rust: 1.32.0 - env: DESCRIPTION="Linux, 1.32.0" + name: "Linux, 1.32.0" + env: ALLOC=0 os: linux - script: - # Differs from standard script: rand_pcg features - - cargo test --tests --no-default-features - # TODO: add simd_support feature: - - cargo test --features=serde1,log - - cargo test --examples - - cargo test --manifest-path rand_core/Cargo.toml - - cargo test --manifest-path rand_core/Cargo.toml --no-default-features - - cargo test --manifest-path rand_distr/Cargo.toml - - cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1 - # TODO: cannot test rand_pcg due to explicit dependency on i128 - - cargo test --manifest-path rand_xorshift/Cargo.toml --features=serde1 - - cargo test --manifest-path rand_xoshiro/Cargo.toml - - cargo test --manifest-path rand_chacha/Cargo.toml - - cargo test --manifest-path rand_hc/Cargo.toml - - cargo test --manifest-path rand_jitter/Cargo.toml - - cargo test --manifest-path rand_os/Cargo.toml - - - rust: 1.32.0 - env: DESCRIPTION="OSX, 1.32.0" - os: osx - script: - # Differs from standard script: rand_pcg features - - cargo test --tests --no-default-features - # TODO: add simd_support feature: - - cargo test --features=serde1,log - - cargo test --examples - - cargo test --manifest-path rand_core/Cargo.toml - - cargo test --manifest-path rand_core/Cargo.toml --no-default-features - - cargo test --manifest-path rand_distr/Cargo.toml - - cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1 - # TODO: cannot test rand_pcg due to explicit dependency on i128 - - cargo test --manifest-path rand_xorshift/Cargo.toml --features=serde1 - - cargo test --manifest-path rand_xoshiro/Cargo.toml - - cargo test --manifest-path rand_chacha/Cargo.toml - - cargo test --manifest-path rand_hc/Cargo.toml - - cargo test --manifest-path rand_jitter/Cargo.toml - - cargo test --manifest-path rand_os/Cargo.toml - rust: stable - env: DESCRIPTION="Linux, stable" + name: "Linux, stable" - rust: stable - env: DESCRIPTION="OSX+iOS, stable" + name: "OSX+iOS, stable" os: osx install: - rustup target add aarch64-apple-ios script: - # Differs from standard script: includes aarch64-apple-ios cross-build - - cargo test --tests --no-default-features - # TODO: add simd_support feature: - - cargo test --features=serde1,log - - cargo test --examples - - cargo test --manifest-path rand_core/Cargo.toml - - cargo test --manifest-path rand_core/Cargo.toml --no-default-features - - cargo test --manifest-path rand_distr/Cargo.toml - - cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1 - - cargo test --manifest-path rand_pcg/Cargo.toml --features=serde1 - - cargo test --manifest-path rand_xorshift/Cargo.toml --features=serde1 - - cargo test --manifest-path rand_xoshiro/Cargo.toml - - cargo test --manifest-path rand_chacha/Cargo.toml - - cargo test --manifest-path rand_hc/Cargo.toml - - cargo test --manifest-path rand_jitter/Cargo.toml - - cargo test --manifest-path rand_os/Cargo.toml + - bash utils/ci/script.sh - cargo build --target=aarch64-apple-ios - rust: beta - env: DESCRIPTION="Linux, beta" + name: "Linux, beta" - rust: nightly os: linux - env: DESCRIPTION="Linux, nightly, docs" + name: "Linux, nightly, docs" + env: NIGHTLY=1 install: - cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks - cargo deadlinks -V before_script: - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH script: - # Differs from standard script: all features, doc build - - cargo test --tests --no-default-features --features=alloc - - cargo test --all-features - - cargo test --benches --features=nightly - - cargo test --examples - - cargo test --manifest-path rand_core/Cargo.toml - - cargo test --manifest-path rand_core/Cargo.toml --no-default-features --features=alloc - - cargo test --manifest-path rand_distr/Cargo.toml - - cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1 - - cargo test --manifest-path rand_pcg/Cargo.toml --features=serde1 - - cargo test --manifest-path rand_xorshift/Cargo.toml --features=serde1 - - cargo test --manifest-path rand_xoshiro/Cargo.toml - - cargo test --manifest-path rand_chacha/Cargo.toml - - cargo test --manifest-path rand_hc/Cargo.toml - - cargo test --manifest-path rand_jitter/Cargo.toml - - cargo test --manifest-path rand_os/Cargo.toml + - bash utils/ci/script.sh # remove cached documentation, otherwise files from previous PRs can get included - rm -rf target/doc - cargo doc --no-deps --all --all-features @@ -162,103 +44,20 @@ matrix: after_success: - travis-cargo --only nightly doc-upload - - rust: nightly - os: osx - env: DESCRIPTION="OSX, nightly, docs" - install: - - cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks - - cargo deadlinks -V - script: - # Differs from standard script: all features, doc build - - cargo test --tests --no-default-features --features=alloc - - cargo test --all-features - - cargo test --benches --features=nightly - - cargo test --examples - - cargo test --manifest-path rand_core/Cargo.toml - - cargo test --manifest-path rand_core/Cargo.toml --no-default-features --features=alloc - - cargo test --manifest-path rand_distr/Cargo.toml - - cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1 - - cargo test --manifest-path rand_pcg/Cargo.toml --features=serde1 - - cargo test --manifest-path rand_xorshift/Cargo.toml --features=serde1 - - cargo test --manifest-path rand_xoshiro/Cargo.toml - - cargo test --manifest-path rand_chacha/Cargo.toml - - cargo test --manifest-path rand_hc/Cargo.toml - - cargo test --manifest-path rand_jitter/Cargo.toml - - cargo test --manifest-path rand_os/Cargo.toml - # 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 - - - rust: nightly - env: DESCRIPTION="WASM via emscripten, stdweb and wasm-bindgen" - install: - - rustup target add wasm32-unknown-unknown - - rustup target add wasm32-unknown-emscripten - - nvm install 9 - - ./utils/ci/install_cargo_web.sh - - cargo web prepare-emscripten - - cargo web -V - - cargo list | grep install-update || cargo install -f cargo-update - - cargo install-update -i cargo-update wasm-bindgen-cli wasm-pack - addons: - chrome: stable - script: - # Testing wasm32-unknown-emscripten fails because of rust-lang/rust#49877 - # However, we can still build and link all tests to make sure that works. - # This is actually useful as it finds stuff such as rust-random/rand#669 - - EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0" cargo web test --target wasm32-unknown-emscripten --no-run - #- cargo web test --target wasm32-unknown-emscripten - #- cargo web test --nodejs --target wasm32-unknown-emscripten - #- cargo build --target wasm32-unknown-unknown # without any features - - cargo build --target wasm32-unknown-unknown --features=wasm-bindgen - - cargo web test --target wasm32-unknown-unknown --features=stdweb - - cargo build --manifest-path tests/wasm_bindgen/Cargo.toml --target wasm32-unknown-unknown - - wasm-bindgen --nodejs target/wasm32-unknown-unknown/debug/rand_wasm_bindgen_test.wasm --out-dir tests/wasm_bindgen/js - - node tests/wasm_bindgen/js/index.js - - wasm-pack test --node tests/wasm_bindgen - - - rust: nightly - env: DESCRIPTION="cross-platform builder (doesn't run tests)" - install: - - rustup target add x86_64-sun-solaris - - rustup target add x86_64-unknown-cloudabi - - rustup target add x86_64-unknown-freebsd - #- rustup target add x86_64-unknown-fuchsia - - rustup target add x86_64-unknown-netbsd - - rustup target add x86_64-unknown-redox - script: - # Test the top-level crate with all features: - - cargo build --target=x86_64-sun-solaris --all-features - - cargo build --target=x86_64-unknown-cloudabi --all-features - - cargo build --target=x86_64-unknown-freebsd --all-features - #- cargo build --target=x86_64-unknown-fuchsia --all-features - - cargo build --target=x86_64-unknown-netbsd --all-features - - cargo build --target=x86_64-unknown-redox --all-features - - # Trust cross-built/emulated targets. We must repeat all non-default values. - - rust: stable - sudo: required - dist: trusty - services: docker - env: DESCRIPTION="Linux (MIPS, big-endian)" TARGET=mips-unknown-linux-gnu - install: - - sh utils/ci/install.sh - - source ~/.cargo/env || true - script: - - bash utils/ci/script.sh + # This target catches endianness issues - rust: stable sudo: required dist: trusty services: docker - env: DESCRIPTION="Android (ARMv7)" TARGET=armv7-linux-androideabi + name: "Linux (MIPS, big-endian)" + env: TARGET=mips-unknown-linux-gnu install: - sh utils/ci/install.sh - source ~/.cargo/env || true - script: - - bash utils/ci/script.sh + + # This target checks we really can build no_std binaries - rust: nightly - env: DESCRIPTION="no_std platform test" + name: "no_std platform test" install: - rustup target add thumbv6m-none-eabi script: @@ -267,44 +66,35 @@ matrix: - rust: nightly os: linux - env: DESCRIPTION="Miri, nightly" + name: "Miri, nightly" script: - sh utils/ci/miri.sh + + - rust: nightly + os: linux + name: "Minimal dep versions" + script: + - cargo generate-lockfile -Z minimal-versions + - bash utils/ci/script.sh before_install: - set -e - rustup self update script: - - cargo test --tests --no-default-features - - cargo test --tests --no-default-features --features getrandom - - cargo test --tests --no-default-features --features=alloc - # TODO: add simd_support feature: - - cargo test --features=serde1,log - - cargo test --examples - - cargo test --manifest-path rand_core/Cargo.toml - - cargo test --manifest-path rand_core/Cargo.toml --no-default-features - - cargo test --manifest-path rand_core/Cargo.toml --no-default-features --features=alloc - - cargo test --manifest-path rand_distr/Cargo.toml - - cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1 - - cargo test --manifest-path rand_pcg/Cargo.toml --features=serde1 - - cargo test --manifest-path rand_xorshift/Cargo.toml --features=serde1 - - cargo test --manifest-path rand_xoshiro/Cargo.toml - - cargo test --manifest-path rand_chacha/Cargo.toml - - cargo test --manifest-path rand_hc/Cargo.toml - - cargo test --manifest-path rand_jitter/Cargo.toml - - cargo test --manifest-path rand_os/Cargo.toml + - bash utils/ci/script.sh after_script: set +e -cache: - cargo: true - directories: - - .local/share/cargo-web +# Cache: this seems to do more harm than good +#cache: + #cargo: true + #directories: + #- .local/share/cargo-web -before_cache: - # Travis can't cache files that are not readable by "others" - - chmod -R a+r $HOME/.cargo +#before_cache: + ## Travis can't cache files that are not readable by "others" + #- chmod -R a+r $HOME/.cargo env: global: diff --git a/Cargo.toml b/Cargo.toml index b87559abdfe..2cc2d9181d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,7 +60,7 @@ rand_pcg = { path = "rand_pcg", version = "0.2", optional = true } # This is a dependency because: we forward wasm feature flags # This is renamed because: we need getrandom to depend on rand_core/getrandom getrandom_package = { version = "0.1.1", package = "getrandom", optional = true } -log = { version = "0.4", optional = true } +log = { version = "0.4.4", optional = true } [dependencies.packed_simd] # NOTE: so far no version works reliably due to dependence on unstable features diff --git a/appveyor.yml b/appveyor.yml index ef0b4bff66b..a4cfbeed61d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -32,12 +32,14 @@ install: build: false test_script: - - cargo test --tests --no-default-features --features alloc - # TODO: use --all-features once simd_support is sufficiently stable: + - cargo test --tests --no-default-features + - cargo test --tests --no-default-features --features=alloc,getrandom + # all stable features: - cargo test --features=serde1,log - cargo test --benches --features=nightly - cargo test --examples - cargo test --manifest-path rand_core/Cargo.toml + - cargo test --manifest-path rand_core/Cargo.toml --no-default-features - cargo test --manifest-path rand_core/Cargo.toml --no-default-features --features=alloc - cargo test --manifest-path rand_distr/Cargo.toml - cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1 @@ -46,4 +48,5 @@ test_script: - cargo test --manifest-path rand_xoshiro/Cargo.toml - cargo test --manifest-path rand_chacha/Cargo.toml - cargo test --manifest-path rand_hc/Cargo.toml + - cargo test --manifest-path rand_jitter/Cargo.toml - cargo test --manifest-path rand_os/Cargo.toml diff --git a/rand_distr/Cargo.toml b/rand_distr/Cargo.toml index 315a5b06095..3eab050ef9c 100644 --- a/rand_distr/Cargo.toml +++ b/rand_distr/Cargo.toml @@ -24,4 +24,6 @@ rand = { path = "..", version = "0.7" } [dev-dependencies] rand_pcg = { version = "0.2", path = "../rand_pcg" } # Histogram implementation for testing uniformity -average = "0.9.2" +average = "0.10.0" +# Not a direct dependency but required to boost the minimum version: +conv = "0.3.2" diff --git a/rand_isaac/Cargo.toml b/rand_isaac/Cargo.toml index c11c305ab17..a63ab18147e 100644 --- a/rand_isaac/Cargo.toml +++ b/rand_isaac/Cargo.toml @@ -23,9 +23,11 @@ serde1 = ["serde", "rand_core/serde1"] [dependencies] rand_core = { path = "../rand_core", version = "0.5" } -serde = { version = "1", features = ["derive"], optional = true } +serde = { version = "1.0.63", features = ["derive"], optional = true } +# Not a direct dependency but required to boost the minimum version: +serde_derive = { version = "1.0.63", optional = true } [dev-dependencies] # This is for testing serde, unfortunately we can't specify feature-gated dev # deps yet, see: https://github.com/rust-lang/cargo/issues/1596 -bincode = "1" +bincode = "1.1.4" diff --git a/utils/ci/script.sh b/utils/ci/script.sh index 852a850bd3c..bd011d57d58 100644 --- a/utils/ci/script.sh +++ b/utils/ci/script.sh @@ -2,23 +2,56 @@ set -ex +# ----- Options ----- + +# TARGET enables cross-building +if [ -z $TARGET ]; then + CARGO=cargo +else + CARGO=cross + TARGET="--target $TARGET" +fi + +# ALLOC defaults on; is disabled for rustc < 1.36 +if [ -z $ALLOC ]; then + ALLOC=1 +fi + +# NIGHTLY defaults off + + +# ----- Script ----- + main() { - cross test --target $TARGET --tests --no-default-features - # TODO: add simd_support feature: - cross test --target $TARGET --features=log - cross test --target $TARGET --examples - cross test --target $TARGET --manifest-path rand_core/Cargo.toml - cross test --target $TARGET --manifest-path rand_core/Cargo.toml --features=serde1 - cross test --target $TARGET --manifest-path rand_core/Cargo.toml --no-default-features - cross test --target $TARGET --manifest-path rand_distr/Cargo.toml - cross test --target $TARGET --manifest-path rand_isaac/Cargo.toml --features=serde1 - cross test --target $TARGET --manifest-path rand_pcg/Cargo.toml --features=serde1 - cross test --target $TARGET --manifest-path rand_xorshift/Cargo.toml --features=serde1 - cross test --target $TARGET --manifest-path rand_xoshiro/Cargo.toml --features=serde1 - cross test --target $TARGET --manifest-path rand_chacha/Cargo.toml - cross test --target $TARGET --manifest-path rand_hc/Cargo.toml - cross test --target $TARGET --manifest-path rand_os/Cargo.toml - cross test --target $TARGET --manifest-path rand_jitter/Cargo.toml + if [ "0$NIGHTLY" -ge 1 ]; then + $CARGO test $TARGET --all-features + $CARGO test $TARGET --benches --features=nightly + else + # all stable features: + $CARGO test $TARGET --features=serde1,log,small_rng + fi + + if [ "$ALLOC" -ge 1 ]; then + $CARGO test $TARGET --tests --no-default-features --features=alloc,getrandom,small_rng + $CARGO test $TARGET --manifest-path rand_core/Cargo.toml --no-default-features --features=alloc + fi + + $CARGO test $TARGET --tests --no-default-features + $CARGO test $TARGET --examples + + $CARGO test $TARGET --manifest-path rand_core/Cargo.toml + $CARGO test $TARGET --manifest-path rand_core/Cargo.toml --no-default-features + $CARGO test $TARGET --manifest-path rand_core/Cargo.toml --no-default-features --features=getrandom + + $CARGO test $TARGET --manifest-path rand_distr/Cargo.toml + $CARGO test $TARGET --manifest-path rand_isaac/Cargo.toml --features=serde1 + $CARGO test $TARGET --manifest-path rand_pcg/Cargo.toml --features=serde1 + $CARGO test $TARGET --manifest-path rand_xorshift/Cargo.toml --features=serde1 + $CARGO test $TARGET --manifest-path rand_xoshiro/Cargo.toml + $CARGO test $TARGET --manifest-path rand_chacha/Cargo.toml + $CARGO test $TARGET --manifest-path rand_hc/Cargo.toml + $CARGO test $TARGET --manifest-path rand_jitter/Cargo.toml + $CARGO test $TARGET --manifest-path rand_os/Cargo.toml } # we don't run the "test phase" when doing deploys