Deny warnings in CI tests (#82)
This commit is contained in:
parent
f94b44aa86
commit
bf54eaa557
133
.travis.yml
133
.travis.yml
@ -3,19 +3,19 @@ sudo: false
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- rust: 1.32.0
|
||||
env: DESCRIPTION="Linux, 1.32.0"
|
||||
- name: "Linux, 1.32.0"
|
||||
rust: 1.32.0
|
||||
os: linux
|
||||
|
||||
- rust: 1.32.0
|
||||
env: DESCRIPTION="OSX, 1.32.0"
|
||||
- name: "OSX, 1.32.0"
|
||||
rust: 1.32.0
|
||||
os: osx
|
||||
|
||||
- rust: stable
|
||||
env: DESCRIPTION="Linux, stable"
|
||||
- name: "Linux, stable"
|
||||
rust: stable
|
||||
|
||||
- rust: stable
|
||||
env: DESCRIPTION="OSX+iOS, stable"
|
||||
- name: "OSX+iOS, stable"
|
||||
rust: stable
|
||||
os: osx
|
||||
install:
|
||||
- rustup target add aarch64-apple-ios
|
||||
@ -24,54 +24,11 @@ matrix:
|
||||
- cargo test --examples
|
||||
- cargo build --target aarch64-apple-ios
|
||||
|
||||
- rust: beta
|
||||
env: DESCRIPTION="Linux, beta"
|
||||
- name: "Linux, beta"
|
||||
rust: beta
|
||||
|
||||
- rust: stable
|
||||
env: DESCRIPTION="Rustfmt"
|
||||
install:
|
||||
- rustup component add rustfmt
|
||||
script:
|
||||
- cargo fmt --all -- */*.rs --check
|
||||
|
||||
- rust: nightly
|
||||
os: linux
|
||||
env: DESCRIPTION="Linux, nightly, docs"
|
||||
install:
|
||||
- cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks
|
||||
- cargo deadlinks -V
|
||||
script:
|
||||
- cargo test
|
||||
- cargo test --benches
|
||||
- cargo test --examples
|
||||
# remove cached documentation, otherwise files from previous PRs can get included
|
||||
- rm -rf target/doc
|
||||
- cargo doc --no-deps --all --features=std,log
|
||||
- cargo deadlinks --dir target/doc
|
||||
# also test minimum dependency versions are usable
|
||||
- cargo generate-lockfile -Z minimal-versions
|
||||
- cargo test
|
||||
|
||||
- rust: nightly
|
||||
os: osx
|
||||
env: DESCRIPTION="OSX, nightly, docs"
|
||||
install:
|
||||
- cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks
|
||||
- cargo deadlinks -V
|
||||
script:
|
||||
- cargo test
|
||||
- cargo test --benches
|
||||
- cargo test --examples
|
||||
# remove cached documentation, otherwise files from previous PRs can get included
|
||||
- rm -rf target/doc
|
||||
- cargo doc --no-deps --all --features=std,log
|
||||
- cargo deadlinks --dir target/doc
|
||||
# also test minimum dependency versions are usable
|
||||
- cargo generate-lockfile -Z minimal-versions
|
||||
- cargo test
|
||||
|
||||
- rust: nightly
|
||||
env: DESCRIPTION="WASM via emscripten, stdweb, wasm-bindgen and WASI"
|
||||
- name: "WASM via emscripten, stdweb, wasm-bindgen and WASI"
|
||||
rust: nightly
|
||||
install:
|
||||
- rustup target add wasm32-unknown-unknown
|
||||
- rustup target add wasm32-unknown-emscripten
|
||||
@ -100,8 +57,44 @@ matrix:
|
||||
- node tests/wasm_bindgen/js/index.js
|
||||
- wasm-pack test --node tests/wasm_bindgen
|
||||
|
||||
- rust: nightly
|
||||
env: DESCRIPTION="cross-platform build only"
|
||||
- name: "Linux, nightly, docs"
|
||||
rust: nightly
|
||||
os: linux
|
||||
install:
|
||||
- cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks
|
||||
- cargo deadlinks -V
|
||||
script:
|
||||
- cargo test
|
||||
- cargo test --benches
|
||||
- cargo test --examples
|
||||
# remove cached documentation, otherwise files from previous PRs can get included
|
||||
- rm -rf target/doc
|
||||
- cargo doc --no-deps --all --features=std,log
|
||||
- cargo deadlinks --dir target/doc
|
||||
# also test minimum dependency versions are usable
|
||||
- cargo generate-lockfile -Z minimal-versions
|
||||
- cargo test
|
||||
|
||||
- name: "OSX, nightly, docs"
|
||||
rust: nightly
|
||||
os: osx
|
||||
install:
|
||||
- cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks
|
||||
- cargo deadlinks -V
|
||||
script:
|
||||
- cargo test
|
||||
- cargo test --benches
|
||||
- cargo test --examples
|
||||
# remove cached documentation, otherwise files from previous PRs can get included
|
||||
- rm -rf target/doc
|
||||
- cargo doc --no-deps --all --features=std,log
|
||||
- cargo deadlinks --dir target/doc
|
||||
# also test minimum dependency versions are usable
|
||||
- cargo generate-lockfile -Z minimal-versions
|
||||
- cargo test
|
||||
|
||||
- name: "cross-platform build only"
|
||||
rust: nightly
|
||||
# libc on Redox is broken: see https://github.com/rust-lang/libc/pull/1450
|
||||
install:
|
||||
- rustup target add x86_64-sun-solaris
|
||||
@ -140,36 +133,48 @@ matrix:
|
||||
- cargo xbuild --target=x86_64-uwp-windows-gnu
|
||||
|
||||
# Trust cross-built/emulated targets. We must repeat all non-default values.
|
||||
- rust: stable
|
||||
- name: "Linux (MIPS, big-endian)"
|
||||
env: TARGET=mips-unknown-linux-gnu
|
||||
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
|
||||
|
||||
- rust: stable
|
||||
- name: "Android (ARMv7)"
|
||||
env: TARGET=armv7-linux-androideabi
|
||||
rust: stable
|
||||
sudo: required
|
||||
dist: trusty
|
||||
services: docker
|
||||
env: DESCRIPTION="Android (ARMv7)" TARGET=armv7-linux-androideabi
|
||||
install:
|
||||
- sh utils/ci/install.sh
|
||||
- source ~/.cargo/env || true
|
||||
script:
|
||||
- bash utils/ci/script.sh
|
||||
|
||||
- name: "rustfmt"
|
||||
rust: stable
|
||||
install:
|
||||
- rustup component add rustfmt
|
||||
script:
|
||||
- cargo fmt --all -- */*.rs --check
|
||||
|
||||
allow_failures:
|
||||
# Formatting errors should appear in Travis, but not break the build.
|
||||
- env: DESCRIPTION="Rustfmt"
|
||||
- name: "rustfmt"
|
||||
|
||||
before_install:
|
||||
- set -e
|
||||
- rustup self update
|
||||
|
||||
before_script:
|
||||
- export RUSTFLAGS="-D warnings"
|
||||
|
||||
script:
|
||||
- cargo test
|
||||
- cargo test --examples
|
||||
@ -188,3 +193,7 @@ before_cache:
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
@ -43,5 +43,10 @@ install:
|
||||
build: false
|
||||
|
||||
test_script:
|
||||
- set RUSTFLAGS=-D warnings
|
||||
- cargo test
|
||||
- cargo test --examples
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
@ -21,8 +21,10 @@ pub struct Error(NonZeroU32);
|
||||
|
||||
impl Error {
|
||||
#[deprecated(since = "0.1.7")]
|
||||
/// Unknown error.
|
||||
pub const UNKNOWN: Error = UNSUPPORTED;
|
||||
#[deprecated(since = "0.1.7")]
|
||||
/// System entropy source is unavailable.
|
||||
pub const UNAVAILABLE: Error = UNSUPPORTED;
|
||||
|
||||
/// Codes below this point represent OS Errors (i.e. positive i32 values).
|
||||
@ -40,7 +42,7 @@ impl Error {
|
||||
/// that it works in `no_std` contexts. If this method returns `None`, the
|
||||
/// error value can still be formatted via the `Diplay` implementation.
|
||||
#[inline]
|
||||
pub fn raw_os_error(&self) -> Option<i32> {
|
||||
pub fn raw_os_error(self) -> Option<i32> {
|
||||
if self.0.get() < Self::INTERNAL_START {
|
||||
Some(self.0.get() as i32)
|
||||
} else {
|
||||
@ -53,7 +55,7 @@ impl Error {
|
||||
/// This code can either come from the underlying OS, or be a custom error.
|
||||
/// Use [`Error::raw_os_error()`] to disambiguate.
|
||||
#[inline]
|
||||
pub fn code(&self) -> NonZeroU32 {
|
||||
pub fn code(self) -> NonZeroU32 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
@ -66,7 +68,8 @@ fn os_err_desc(errno: i32, buf: &mut [u8]) -> Option<&str> {
|
||||
}
|
||||
|
||||
// Take up to trailing null byte
|
||||
let idx = buf.iter().position(|&b| b == 0).unwrap_or(buf.len());
|
||||
let n = buf.len();
|
||||
let idx = buf.iter().position(|&b| b == 0).unwrap_or(n);
|
||||
core::str::from_utf8(&buf[..idx]).ok()
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@
|
||||
)]
|
||||
#![no_std]
|
||||
#![cfg_attr(feature = "stdweb", recursion_limit = "128")]
|
||||
#![warn(rust_2018_idioms, unused_lifetimes)]
|
||||
#![warn(rust_2018_idioms, unused_lifetimes, missing_docs)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate cfg_if;
|
||||
|
@ -24,7 +24,7 @@ const FILE_PATH: &str = "/dev/random\0";
|
||||
|
||||
pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
|
||||
static FD: LazyFd = LazyFd::new();
|
||||
let fd = FD.init(init_file).ok_or(last_os_error())?;
|
||||
let fd = FD.init(init_file).ok_or_else(last_os_error)?;
|
||||
let read = |buf: &mut [u8]| unsafe { libc::read(fd, buf.as_mut_ptr() as *mut _, buf.len()) };
|
||||
|
||||
if cfg!(target_os = "emscripten") {
|
||||
|
@ -11,9 +11,9 @@ extern crate std;
|
||||
|
||||
use core::mem;
|
||||
|
||||
use stdweb::js;
|
||||
use stdweb::unstable::TryInto;
|
||||
use stdweb::web::error::Error as WebError;
|
||||
use stdweb::{_js_impl, js};
|
||||
|
||||
use crate::error::{STDWEB_NO_RNG, STDWEB_RNG_FAILED};
|
||||
use crate::Error;
|
||||
@ -69,8 +69,8 @@ fn getrandom_init() -> Result<RngSource, Error> {
|
||||
unreachable!()
|
||||
}
|
||||
} else {
|
||||
let err: WebError = js! { return @{ result }.error }.try_into().unwrap();
|
||||
error!("getrandom unavailable: {}", err);
|
||||
let _err: WebError = js! { return @{ result }.error }.try_into().unwrap();
|
||||
error!("getrandom unavailable: {}", _err);
|
||||
Err(STDWEB_NO_RNG)
|
||||
}
|
||||
}
|
||||
@ -105,8 +105,8 @@ fn getrandom_fill(source: RngSource, dest: &mut [u8]) -> Result<(), Error> {
|
||||
};
|
||||
|
||||
if js! { return @{ result.as_ref() }.success } != true {
|
||||
let err: WebError = js! { return @{ result }.error }.try_into().unwrap();
|
||||
error!("getrandom failed: {}", err);
|
||||
let _err: WebError = js! { return @{ result }.error }.try_into().unwrap();
|
||||
error!("getrandom failed: {}", _err);
|
||||
return Err(STDWEB_RNG_FAILED);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user