Merge pull request #1073 from rust-random/work2
Migrate to GitHub Actions
This commit is contained in:
commit
6682db1d4d
29
.github/workflows/gh-pages.yml
vendored
Normal file
29
.github/workflows/gh-pages.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
name: gh-pages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: GH-pages documentation
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
override: true
|
||||
- name: doc (rand)
|
||||
env:
|
||||
RUSTDOCFLAGS: --cfg doc_cfg
|
||||
# --all builds all crates, but with default features for other crates (okay in this case)
|
||||
run: cargo doc --all --features nightly,serde1,getrandom,small_rng
|
||||
- name: Deploy
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./target/doc
|
185
.github/workflows/test.yml
vendored
Normal file
185
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,185 @@
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master, '0.[0-9]+' ]
|
||||
pull_request:
|
||||
branches: [ master, '0.[0-9]+' ]
|
||||
|
||||
jobs:
|
||||
check-doc:
|
||||
name: Check doc
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
override: true
|
||||
- run: cargo install cargo-deadlinks
|
||||
- name: doc (rand)
|
||||
env:
|
||||
RUSTDOCFLAGS: --cfg doc_cfg
|
||||
# --all builds all crates, but with default features for other crates (okay in this case)
|
||||
run: cargo deadlinks --ignore-fragments -- --all --features nightly,serde1,getrandom,small_rng
|
||||
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
toolchain: stable
|
||||
- os: macos-latest
|
||||
target: x86_64-apple-darwin
|
||||
toolchain: stable
|
||||
# TODO: also aarch64 / M1
|
||||
- os: windows-latest
|
||||
target: x86_64-pc-windows-gnu
|
||||
toolchain: stable
|
||||
- os: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
toolchain: beta
|
||||
# Test both windows-gnu and windows-msvc; use beta rust on one
|
||||
- os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
toolchain: 1.36.0 # MSRV
|
||||
- os: ubuntu-latest
|
||||
deps: sudo apt install gcc-multilib
|
||||
target: i686-unknown-linux-gnu
|
||||
toolchain: nightly
|
||||
- os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
toolchain: nightly
|
||||
variant: minimal
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
target: ${{ matrix.target }}
|
||||
toolchain: ${{ matrix.toolchain }}
|
||||
override: true
|
||||
- run: ${{ matrix.deps }}
|
||||
- name: Maybe minimal
|
||||
if: ${{ matrix.variant == 'minimal' }}
|
||||
run: cargo generate-lockfile -Z minimal-versions
|
||||
- name: Maybe nightly
|
||||
if: ${{ matrix.toolchain == 'nightly' }}
|
||||
run: |
|
||||
cargo test --target ${{ matrix.target }} --tests --features=nightly
|
||||
cargo test --target ${{ matrix.target }} --all-features
|
||||
cargo test --target ${{ matrix.target }} --benches --features=nightly
|
||||
cargo test --target ${{ matrix.target }} --manifest-path rand_distr/Cargo.toml --benches
|
||||
- name: Test rand
|
||||
run: |
|
||||
cargo test --target ${{ matrix.target }} --tests --no-default-features
|
||||
cargo test --target ${{ matrix.target }} --tests --no-default-features --features=alloc,getrandom,small_rng
|
||||
# all stable features:
|
||||
cargo test --target ${{ matrix.target }} --features=serde1,log,small_rng
|
||||
cargo test --target ${{ matrix.target }} --examples
|
||||
- name: Test rand_core
|
||||
run: |
|
||||
cargo test --target ${{ matrix.target }} --manifest-path rand_core/Cargo.toml
|
||||
cargo test --target ${{ matrix.target }} --manifest-path rand_core/Cargo.toml --no-default-features
|
||||
cargo test --target ${{ matrix.target }} --manifest-path rand_core/Cargo.toml --no-default-features --features=alloc,getrandom
|
||||
- name: Test rand_distr
|
||||
run: cargo test --target ${{ matrix.target }} --manifest-path rand_distr/Cargo.toml
|
||||
- name: Test rand_pcg
|
||||
run: cargo test --target ${{ matrix.target }} --manifest-path rand_pcg/Cargo.toml --features=serde1
|
||||
- name: Test rand_chacha
|
||||
run: cargo test --target ${{ matrix.target }} --manifest-path rand_chacha/Cargo.toml
|
||||
- name: Test rand_hc
|
||||
run: cargo test --target ${{ matrix.target }} --manifest-path rand_hc/Cargo.toml
|
||||
|
||||
test-cross:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
target: mips-unknown-linux-gnu
|
||||
toolchain: stable
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
target: ${{ matrix.target }}
|
||||
toolchain: ${{ matrix.toolchain }}
|
||||
override: true
|
||||
- name: Cache cargo plugins
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cargo/bin/
|
||||
key: ${{ runner.os }}-cargo-plugins
|
||||
- name: Install cross
|
||||
run: cargo install cross || true
|
||||
- name: Test
|
||||
run: |
|
||||
# all stable features:
|
||||
cross test --no-fail-fast --target ${{ matrix.target }} --features=serde1,log,small_rng
|
||||
cross test --no-fail-fast --target ${{ matrix.target }} --examples
|
||||
cross test --no-fail-fast --target ${{ matrix.target }} --manifest-path rand_core/Cargo.toml
|
||||
cross test --no-fail-fast --target ${{ matrix.target }} --manifest-path rand_distr/Cargo.toml
|
||||
cross test --no-fail-fast --target ${{ matrix.target }} --manifest-path rand_pcg/Cargo.toml --features=serde1
|
||||
cross test --no-fail-fast --target ${{ matrix.target }} --manifest-path rand_chacha/Cargo.toml
|
||||
cross test --no-fail-fast --target ${{ matrix.target }} --manifest-path rand_hc/Cargo.toml
|
||||
|
||||
test-miri:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install toolchain
|
||||
run: |
|
||||
MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)
|
||||
rustup default "$MIRI_NIGHTLY"
|
||||
rustup component add miri
|
||||
- name: Test rand
|
||||
run: |
|
||||
cargo miri test --no-default-features
|
||||
cargo miri test --features=log,small_rng
|
||||
cargo miri test --manifest-path rand_core/Cargo.toml
|
||||
cargo miri test --manifest-path rand_core/Cargo.toml --features=serde1
|
||||
cargo miri test --manifest-path rand_core/Cargo.toml --no-default-features
|
||||
#cargo miri test --manifest-path rand_distr/Cargo.toml # no unsafe and lots of slow tests
|
||||
cargo miri test --manifest-path rand_pcg/Cargo.toml --features=serde1
|
||||
cargo miri test --manifest-path rand_chacha/Cargo.toml --no-default-features
|
||||
cargo miri test --manifest-path rand_hc/Cargo.toml
|
||||
|
||||
test-no-std:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
target: thumbv6m-none-eabi
|
||||
override: true
|
||||
- name: Build top-level only
|
||||
run: cargo build --target=thumbv6m-none-eabi --no-default-features
|
||||
|
||||
test-ios:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
target: aarch64-apple-ios
|
||||
override: true
|
||||
- name: Build top-level only
|
||||
run: cargo build --target=aarch64-apple-ios
|
115
.travis.yml
115
.travis.yml
@ -1,115 +0,0 @@
|
||||
language: rust
|
||||
sudo: false
|
||||
|
||||
# Since most OS-specific code has moved to the getrandom crate, we require
|
||||
# few target-specific tests here.
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- rust: 1.36.0
|
||||
name: "Linux, 1.36.0"
|
||||
os: linux
|
||||
|
||||
- rust: stable
|
||||
name: "Linux, stable"
|
||||
|
||||
- rust: stable
|
||||
name: "OSX+iOS, stable"
|
||||
os: osx
|
||||
install:
|
||||
- rustup target add aarch64-apple-ios
|
||||
script:
|
||||
- bash utils/ci/script.sh
|
||||
- cargo build --target=aarch64-apple-ios
|
||||
|
||||
- rust: beta
|
||||
name: "Linux, beta"
|
||||
|
||||
- rust: nightly
|
||||
os: linux
|
||||
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:
|
||||
- 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
|
||||
- cargo deadlinks --dir target/doc
|
||||
deploy:
|
||||
local_dir: target/doc
|
||||
provider: pages
|
||||
skip_cleanup: true
|
||||
github_token: $GITHUB_TOKEN
|
||||
on:
|
||||
branch: master
|
||||
|
||||
# This target catches endianness issues
|
||||
- rust: stable
|
||||
sudo: required
|
||||
dist: trusty
|
||||
services: docker
|
||||
name: "Linux (MIPS, big-endian)"
|
||||
env: TARGET=mips-unknown-linux-gnu
|
||||
install:
|
||||
- sh utils/ci/install.sh
|
||||
- source ~/.cargo/env || true
|
||||
|
||||
# This target checks we really can build no_std binaries
|
||||
- rust: nightly
|
||||
name: "no_std platform test"
|
||||
install:
|
||||
- rustup target add thumbv6m-none-eabi
|
||||
script:
|
||||
# Test the top-level crate with all features:
|
||||
- cargo build --target=thumbv6m-none-eabi --no-default-features
|
||||
|
||||
- rust: nightly
|
||||
name: "Linux, nightly (32-bit test)"
|
||||
env: TARGET=i686-unknown-linux-musl
|
||||
install:
|
||||
- rustup target add $TARGET
|
||||
|
||||
- rust: nightly
|
||||
os: linux
|
||||
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:
|
||||
- bash utils/ci/script.sh
|
||||
|
||||
after_script: set +e
|
||||
|
||||
# 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
|
||||
|
||||
env:
|
||||
global:
|
||||
secure: "BdDntVHSompN+Qxz5Rz45VI4ZqhD72r6aPl166FADlnkIwS6N6FLWdqs51O7G5CpoMXEDvyYrjmRMZe/GYLIG9cmqmn/wUrWPO+PauGiIuG/D2dmfuUNvSTRcIe7UQLXrfP3yyfZPgqsH6pSnNEVopquQKy3KjzqepgriOJtbyY="
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
@ -16,10 +16,6 @@ autobenches = true
|
||||
edition = "2018"
|
||||
include = ["src/", "LICENSE-*", "README.md", "CHANGELOG.md", "COPYRIGHT"]
|
||||
|
||||
[badges]
|
||||
travis-ci = { repository = "rust-random/rand" }
|
||||
appveyor = { repository = "rust-random/rand" }
|
||||
|
||||
[features]
|
||||
# Meta-features:
|
||||
default = ["std", "std_rng"]
|
||||
|
@ -1,7 +1,6 @@
|
||||
# Rand
|
||||
|
||||
[](https://travis-ci.org/rust-random/rand)
|
||||
[](https://ci.appveyor.com/project/rust-random/rand)
|
||||
[](https://github.com/rust-random/rand/actions)
|
||||
[](https://crates.io/crates/rand)
|
||||
[](https://rust-random.github.io/book/)
|
||||
[](https://rust-random.github.io/rand)
|
||||
@ -104,8 +103,8 @@ greater, and 0.4 and 0.3 (since approx. June 2017) require Rustc version 1.15 or
|
||||
greater. Subsets of the Rand code may work with older Rust versions, but this is
|
||||
not supported.
|
||||
|
||||
Travis CI always has a build with a pinned version of Rustc matching the oldest
|
||||
supported Rust release. The current policy is that this can be updated in any
|
||||
Continuous Integration (CI) will always test the minimum supported Rustc version
|
||||
(the MSRV). The current policy is that this can be updated in any
|
||||
Rand release if required, but the change must be noted in the changelog.
|
||||
|
||||
## Crate Features
|
||||
|
48
appveyor.yml
48
appveyor.yml
@ -1,48 +0,0 @@
|
||||
environment:
|
||||
|
||||
# At the time this was added AppVeyor was having troubles with checking
|
||||
# revocation of SSL certificates of sites like static.rust-lang.org and what
|
||||
# we think is crates.io. The libcurl HTTP client by default checks for
|
||||
# revocation on Windows and according to a mailing list [1] this can be
|
||||
# disabled.
|
||||
#
|
||||
# The `CARGO_HTTP_CHECK_REVOKE` env var here tells cargo to disable SSL
|
||||
# revocation checking on Windows in libcurl. Note, though, that rustup, which
|
||||
# we're using to download Rust here, also uses libcurl as the default backend.
|
||||
# Unlike Cargo, however, rustup doesn't have a mechanism to disable revocation
|
||||
# checking. To get rustup working we set `RUSTUP_USE_HYPER` which forces it to
|
||||
# use the Hyper instead of libcurl backend. Both Hyper and libcurl use
|
||||
# schannel on Windows but it appears that Hyper configures it slightly
|
||||
# differently such that revocation checking isn't turned on by default.
|
||||
#
|
||||
# [1]: https://curl.haxx.se/mail/lib-2016-03/0202.html
|
||||
RUSTUP_USE_HYPER: 1
|
||||
CARGO_HTTP_CHECK_REVOKE: false
|
||||
|
||||
matrix:
|
||||
- TARGET: x86_64-pc-windows-msvc
|
||||
- TARGET: i686-pc-windows-msvc
|
||||
install:
|
||||
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
|
||||
- rustup-init.exe -y --default-host %TARGET% --default-toolchain nightly
|
||||
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
|
||||
- rustc -V
|
||||
- cargo -V
|
||||
|
||||
build: false
|
||||
|
||||
test_script:
|
||||
- cargo test --tests --no-default-features
|
||||
- cargo test --tests --no-default-features --features=alloc,getrandom
|
||||
- cargo test --features simd_support
|
||||
# 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_pcg/Cargo.toml --features=serde1
|
||||
- cargo test --manifest-path rand_chacha/Cargo.toml
|
||||
- cargo test --manifest-path rand_hc/Cargo.toml
|
@ -14,10 +14,6 @@ keywords = ["random", "rng", "chacha"]
|
||||
categories = ["algorithms", "no-std"]
|
||||
edition = "2018"
|
||||
|
||||
[badges]
|
||||
travis-ci = { repository = "rust-random/rand" }
|
||||
appveyor = { repository = "rust-random/rand" }
|
||||
|
||||
[dependencies]
|
||||
rand_core = { path = "../rand_core", version = "0.5" }
|
||||
ppv-lite86 = { version = "0.2.8", default-features = false, features = ["simd"] }
|
||||
|
@ -1,7 +1,6 @@
|
||||
# rand_chacha
|
||||
|
||||
[](https://travis-ci.org/rust-random/rand)
|
||||
[](https://ci.appveyor.com/project/rust-random/rand)
|
||||
[](https://github.com/rust-random/rand/actions)
|
||||
[](https://crates.io/crates/rand_chacha)
|
||||
[](https://rust-random.github.io/book/)
|
||||
[](https://rust-random.github.io/rand/rand_chacha)
|
||||
|
@ -14,10 +14,6 @@ keywords = ["random", "rng"]
|
||||
categories = ["algorithms", "no-std"]
|
||||
edition = "2018"
|
||||
|
||||
[badges]
|
||||
travis-ci = { repository = "rust-random/rand" }
|
||||
appveyor = { repository = "rust-random/rand" }
|
||||
|
||||
[features]
|
||||
std = ["alloc", "getrandom", "getrandom/std"] # use std library; should be default but for above bug
|
||||
alloc = [] # enables Vec and Box support without std
|
||||
|
@ -1,7 +1,6 @@
|
||||
# rand_core
|
||||
|
||||
[](https://travis-ci.org/rust-random/rand)
|
||||
[](https://ci.appveyor.com/project/rust-random/rand)
|
||||
[](https://github.com/rust-random/rand/actions)
|
||||
[](https://crates.io/crates/rand_core)
|
||||
[](https://rust-random.github.io/book/)
|
||||
[](https://rust-random.github.io/rand/rand_core)
|
||||
|
@ -15,10 +15,6 @@ categories = ["algorithms"]
|
||||
edition = "2018"
|
||||
include = ["src/", "LICENSE-*", "README.md", "CHANGELOG.md", "COPYRIGHT"]
|
||||
|
||||
[badges]
|
||||
travis-ci = { repository = "rust-random/rand" }
|
||||
appveyor = { repository = "rust-random/rand" }
|
||||
|
||||
[dependencies]
|
||||
rand = { path = "..", version = "0.7", default-features = false }
|
||||
num-traits = { version = "0.2", default-features = false, features = ["libm"] }
|
||||
|
@ -1,7 +1,6 @@
|
||||
# rand_distr
|
||||
|
||||
[](https://travis-ci.org/rust-random/rand)
|
||||
[](https://ci.appveyor.com/project/rust-random/rand)
|
||||
[](https://github.com/rust-random/rand/actions)
|
||||
[](https://crates.io/crates/rand_distr)
|
||||
[[](https://rust-random.github.io/book/)
|
||||
[](https://rust-random.github.io/rand/rand_distr)
|
||||
|
@ -159,8 +159,7 @@ mod test {
|
||||
gen_samples(10f32, 7.0, &mut buf);
|
||||
let expected = [15.023088, -5.446413, 3.7092876, 3.112482];
|
||||
for (a, b) in buf.iter().zip(expected.iter()) {
|
||||
let (a, b) = (*a, *b);
|
||||
assert!((a - b).abs() < 1e-6, "expected: {} = {}", a, b);
|
||||
assert_almost_eq!(*a, *b, 1e-5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -345,7 +345,8 @@ mod tests {
|
||||
assert_almost_eq!(lnorm.norm.std_dev, 1.0, 2e-16);
|
||||
|
||||
let lnorm = LogNormal::from_mean_cv(e.powf(1.5), (e - 1.0).sqrt()).unwrap();
|
||||
assert_eq!((lnorm.norm.mean, lnorm.norm.std_dev), (1.0, 1.0));
|
||||
assert_almost_eq!(lnorm.norm.mean, 1.0, 1e-15);
|
||||
assert_eq!(lnorm.norm.std_dev, 1.0);
|
||||
}
|
||||
#[test]
|
||||
fn test_log_normal_invalid_sd() {
|
||||
|
@ -87,6 +87,7 @@ where F: Float, OpenClosed01: Distribution<F>
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use core::fmt::{Debug, Display, LowerExp};
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
@ -108,21 +109,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn value_stability() {
|
||||
fn test_samples<F: Float + core::fmt::Debug, D: Distribution<F>>(
|
||||
distr: D, zero: F, expected: &[F],
|
||||
fn test_samples<F: Float + Debug + Display + LowerExp, D: Distribution<F>>(
|
||||
distr: D, thresh: F, expected: &[F],
|
||||
) {
|
||||
let mut rng = crate::test::rng(213);
|
||||
let mut buf = [zero; 4];
|
||||
for x in &mut buf {
|
||||
*x = rng.sample(&distr);
|
||||
for v in expected {
|
||||
let x = rng.sample(&distr);
|
||||
assert_almost_eq!(x, *v, thresh);
|
||||
}
|
||||
assert_eq!(buf, expected);
|
||||
}
|
||||
|
||||
test_samples(Pareto::new(1.0, 1.0).unwrap(), 0f32, &[
|
||||
test_samples(Pareto::new(1f32, 1.0).unwrap(), 1e-6, &[
|
||||
1.0423688, 2.1235929, 4.132709, 1.4679428,
|
||||
]);
|
||||
test_samples(Pareto::new(2.0, 0.5).unwrap(), 0f64, &[
|
||||
test_samples(Pareto::new(2.0, 0.5).unwrap(), 1e-14, &[
|
||||
9.019295276219136,
|
||||
4.3097126018270595,
|
||||
6.837815045397157,
|
||||
|
@ -6,7 +6,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use core::{fmt::Debug, cmp::PartialEq};
|
||||
use average::assert_almost_eq;
|
||||
use core::fmt::Debug;
|
||||
use rand::Rng;
|
||||
use rand_distr::*;
|
||||
|
||||
@ -17,12 +18,48 @@ fn get_rng(seed: u64) -> impl rand::Rng {
|
||||
rand_pcg::Pcg32::new(seed, INC)
|
||||
}
|
||||
|
||||
fn test_samples<F: Debug + Copy + PartialEq, D: Distribution<F>>(
|
||||
/// We only assert approximate equality since some platforms do not perform
|
||||
/// identically (i686-unknown-linux-gnu and most notably x86_64-pc-windows-gnu).
|
||||
trait ApproxEq {
|
||||
fn assert_almost_eq(&self, rhs: &Self);
|
||||
}
|
||||
|
||||
impl ApproxEq for f32 {
|
||||
fn assert_almost_eq(&self, rhs: &Self) {
|
||||
assert_almost_eq!(self, rhs, 1e-6);
|
||||
}
|
||||
}
|
||||
impl ApproxEq for f64 {
|
||||
fn assert_almost_eq(&self, rhs: &Self) {
|
||||
assert_almost_eq!(self, rhs, 1e-14);
|
||||
}
|
||||
}
|
||||
impl ApproxEq for u64 {
|
||||
fn assert_almost_eq(&self, rhs: &Self) {
|
||||
assert_eq!(self, rhs);
|
||||
}
|
||||
}
|
||||
impl<T: ApproxEq> ApproxEq for [T; 2] {
|
||||
fn assert_almost_eq(&self, rhs: &Self) {
|
||||
self[0].assert_almost_eq(&rhs[0]);
|
||||
self[1].assert_almost_eq(&rhs[1]);
|
||||
}
|
||||
}
|
||||
impl<T: ApproxEq> ApproxEq for [T; 3] {
|
||||
fn assert_almost_eq(&self, rhs: &Self) {
|
||||
self[0].assert_almost_eq(&rhs[0]);
|
||||
self[1].assert_almost_eq(&rhs[1]);
|
||||
self[2].assert_almost_eq(&rhs[2]);
|
||||
}
|
||||
}
|
||||
|
||||
fn test_samples<F: Debug + ApproxEq, D: Distribution<F>>(
|
||||
seed: u64, distr: D, expected: &[F],
|
||||
) {
|
||||
let mut rng = get_rng(seed);
|
||||
for &val in expected {
|
||||
assert_eq!(val, rng.sample(&distr));
|
||||
for val in expected {
|
||||
let x = rng.sample(&distr);
|
||||
x.assert_almost_eq(val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -334,11 +371,12 @@ fn cauchy_stability() {
|
||||
|
||||
// Unfortunately this test is not fully portable due to reliance on the
|
||||
// system's implementation of tanf (see doc on Cauchy struct).
|
||||
// We use a lower threshold of 1e-5 here.
|
||||
let distr = Cauchy::new(10f32, 7.0).unwrap();
|
||||
let mut rng = get_rng(353);
|
||||
let expected = [15.023088, -5.446413, 3.7092876, 3.112482];
|
||||
for &a in expected.iter() {
|
||||
let b = rng.sample(&distr);
|
||||
assert!((a - b).abs() < 1e-6, "expected: {} = {}", a, b);
|
||||
assert_almost_eq!(a, b, 1e-5);
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,5 @@ keywords = ["random", "rng", "hc128"]
|
||||
categories = ["algorithms", "no-std"]
|
||||
edition = "2018"
|
||||
|
||||
[badges]
|
||||
travis-ci = { repository = "rust-random/rand" }
|
||||
appveyor = { repository = "rust-random/rand" }
|
||||
|
||||
[dependencies]
|
||||
rand_core = { path = "../rand_core", version = "0.5" }
|
||||
|
@ -1,7 +1,6 @@
|
||||
# rand_hc
|
||||
|
||||
[](https://travis-ci.org/rust-random/rand)
|
||||
[](https://ci.appveyor.com/project/rust-random/rand)
|
||||
[](https://github.com/rust-random/rand/actions)
|
||||
[](https://crates.io/crates/rand_hc)
|
||||
[[](https://rust-random.github.io/book/)
|
||||
[](https://rust-random.github.io/rand/rand_hc)
|
||||
|
@ -14,10 +14,6 @@ keywords = ["random", "rng", "pcg"]
|
||||
categories = ["algorithms", "no-std"]
|
||||
edition = "2018"
|
||||
|
||||
[badges]
|
||||
travis-ci = { repository = "rust-random/rand" }
|
||||
appveyor = { repository = "rust-random/rand" }
|
||||
|
||||
[features]
|
||||
serde1 = ["serde"]
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
# rand_pcg
|
||||
|
||||
[](https://travis-ci.org/rust-random/rand)
|
||||
[](https://ci.appveyor.com/project/rust-random/rand)
|
||||
[](https://github.com/rust-random/rand/actions)
|
||||
[](https://crates.io/crates/rand_pcg)
|
||||
[](https://rust-random.github.io/book/)
|
||||
[](https://rust-random.github.io/rand/rand_pcg)
|
||||
|
@ -1,49 +0,0 @@
|
||||
# From https://github.com/japaric/trust
|
||||
|
||||
set -ex
|
||||
|
||||
main() {
|
||||
local target=
|
||||
if [ $TRAVIS_OS_NAME = linux ]; then
|
||||
target=x86_64-unknown-linux-musl
|
||||
sort=sort
|
||||
else
|
||||
target=x86_64-apple-darwin
|
||||
sort=gsort # for `sort --sort-version`, from brew's coreutils.
|
||||
fi
|
||||
|
||||
# Builds for iOS are done on OSX, but require the specific target to be
|
||||
# installed.
|
||||
case $TARGET in
|
||||
aarch64-apple-ios)
|
||||
rustup target install aarch64-apple-ios
|
||||
;;
|
||||
armv7-apple-ios)
|
||||
rustup target install armv7-apple-ios
|
||||
;;
|
||||
armv7s-apple-ios)
|
||||
rustup target install armv7s-apple-ios
|
||||
;;
|
||||
i386-apple-ios)
|
||||
rustup target install i386-apple-ios
|
||||
;;
|
||||
x86_64-apple-ios)
|
||||
rustup target install x86_64-apple-ios
|
||||
;;
|
||||
esac
|
||||
|
||||
# This fetches latest stable release
|
||||
local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \
|
||||
| cut -d/ -f3 \
|
||||
| grep -E '^v[0.1.0-9.]+$' \
|
||||
| $sort --version-sort \
|
||||
| tail -n1)
|
||||
curl -LSfs https://japaric.github.io/trust/install.sh | \
|
||||
sh -s -- \
|
||||
--force \
|
||||
--git japaric/cross \
|
||||
--tag $tag \
|
||||
--target $target
|
||||
}
|
||||
|
||||
main
|
@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
CARGO_WEB_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/koute/cargo-web/releases/latest)
|
||||
CARGO_WEB_VERSION=$(echo $CARGO_WEB_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
|
||||
CARGO_WEB_URL="https://github.com/koute/cargo-web/releases/download/$CARGO_WEB_VERSION/cargo-web-x86_64-unknown-linux-gnu.gz"
|
||||
|
||||
echo "Downloading cargo-web from: $CARGO_WEB_URL"
|
||||
curl -L $CARGO_WEB_URL | gzip -d > cargo-web
|
||||
chmod +x cargo-web
|
||||
|
||||
mkdir -p ~/.cargo/bin
|
||||
mv cargo-web ~/.cargo/bin
|
@ -1,18 +0,0 @@
|
||||
set -ex
|
||||
|
||||
MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)
|
||||
echo "Installing latest nightly with Miri: $MIRI_NIGHTLY"
|
||||
rustup default "$MIRI_NIGHTLY"
|
||||
|
||||
rustup component add miri
|
||||
cargo miri setup
|
||||
|
||||
cargo miri test --no-default-features
|
||||
cargo miri test --features=log
|
||||
cargo miri test --manifest-path rand_core/Cargo.toml
|
||||
cargo miri test --manifest-path rand_core/Cargo.toml --features=serde1
|
||||
cargo miri test --manifest-path rand_core/Cargo.toml --no-default-features
|
||||
#cargo miri test --manifest-path rand_distr/Cargo.toml # no unsafe and lots of slow tests
|
||||
cargo miri test --manifest-path rand_pcg/Cargo.toml --features=serde1
|
||||
cargo miri test --manifest-path rand_chacha/Cargo.toml --no-default-features
|
||||
cargo miri test --manifest-path rand_hc/Cargo.toml
|
@ -1,59 +0,0 @@
|
||||
# Derived from https://github.com/japaric/trust
|
||||
|
||||
set -ex
|
||||
|
||||
# ----- Options -----
|
||||
|
||||
# TARGET enables cross-building
|
||||
if [ -z $TARGET ]; then
|
||||
CARGO=cargo
|
||||
elif [ "$TARGET" = "i686-unknown-linux-musl" ]; then
|
||||
CARGO=cargo
|
||||
TARGET="--target $TARGET"
|
||||
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() {
|
||||
if [ "0$NIGHTLY" -ge 1 ]; then
|
||||
$CARGO test $TARGET --all-features
|
||||
$CARGO test $TARGET --benches --features=nightly
|
||||
$CARGO test $TARGET --manifest-path rand_distr/Cargo.toml --benches
|
||||
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_pcg/Cargo.toml --features=serde1
|
||||
$CARGO test $TARGET --manifest-path rand_chacha/Cargo.toml
|
||||
$CARGO test $TARGET --manifest-path rand_hc/Cargo.toml
|
||||
}
|
||||
|
||||
# we don't run the "test phase" when doing deploys
|
||||
if [ -z $TRAVIS_TAG ]; then
|
||||
main
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user