Skip to content

Commit

Permalink
Improve build times and test coverage.
Browse files Browse the repository at this point in the history
Change CI build configurations to run a single minimal `cargo test ...`
for all environment permutations with a exhaustive test run in the
TravisCI stable build. Code coverage, formatting, and linting are all
separated into distinct jobs. Code coverage is changed from `kcov` and
`cargo coveralls` to `cargo tarpaulin`. Resolves #92.
  • Loading branch information
iliekturtles committed Aug 4, 2018
1 parent c3b7d39 commit f177d59
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 82 deletions.
102 changes: 52 additions & 50 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,65 @@
# Appveyor configuration template for Rust using rustup for Rust installation
# https://github.com/starkat99/appveyor-rust

## Operating System (VM environment) ##
os: Visual Studio 2017

## Build Matrix ##
build: false
skip_tags: true
cache:
- C:\Users\appveyor\.cargo\registry
- target
environment:
global:
CHANNEL: stable
PROJECT_NAME: uom
# APPVEYOR_CACHE_SKIP_RESTORE: true # Uncomment when caching causes problems
matrix:
# Oldest supported
- TARGET: i686-pc-windows-msvc
CHANNEL: 1.20.0
- TARGET: i686-pc-windows-gnu
CHANNEL: 1.20.0
- TARGET: x86_64-pc-windows-msvc
CHANNEL: 1.20.0
- TARGET: x86_64-pc-windows-gnu
CHANNEL: 1.20.0
# Stable channel
- TARGET: i686-pc-windows-msvc
CHANNEL: stable
- TARGET: i686-pc-windows-gnu
CHANNEL: stable
- TARGET: x86_64-pc-windows-msvc
CHANNEL: stable
- TARGET: x86_64-pc-windows-gnu
CHANNEL: stable
# Beta channel
- TARGET: i686-pc-windows-msvc
CHANNEL: beta
- TARGET: i686-pc-windows-gnu
CHANNEL: beta
- TARGET: x86_64-pc-windows-msvc
CHANNEL: beta
- TARGET: x86_64-pc-windows-gnu
CHANNEL: beta
# Nightly channel
- TARGET: i686-pc-windows-msvc
CHANNEL: nightly
- TARGET: i686-pc-windows-gnu
CHANNEL: nightly
- TARGET: x86_64-pc-windows-msvc
CHANNEL: nightly
- TARGET: x86_64-pc-windows-gnu
CHANNEL: nightly

### MSVC Toolchains ###
# Stable 64-bit MSVC
- channel: stable
target: x86_64-pc-windows-msvc
# Stable 32-bit MSVC
- channel: stable
target: i686-pc-windows-msvc
# Beta 64-bit MSVC
- channel: beta
target: x86_64-pc-windows-msvc
# Beta 32-bit MSVC
- channel: beta
target: i686-pc-windows-msvc

### GNU Toolchains ###
# Stable 64-bit GNU
- channel: stable
target: x86_64-pc-windows-gnu
# Stable 32-bit GNU
- channel: stable
target: i686-pc-windows-gnu
# Beta 64-bit GNU
- channel: beta
target: x86_64-pc-windows-gnu
# Beta 32-bit GNU
- channel: beta
target: i686-pc-windows-gnu

### Allowed failures ###
matrix:
allow_failures:
- channel: nightly
- CHANNEL: nightly

## Install Script ##
install:
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- rustup-init -yv --default-toolchain %channel% --default-host %target%
- set PATH=%PATH%;%USERPROFILE%\.cargo\bin
- rustc -vV
- cargo -vV
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- rustup-init -yv --default-toolchain %CHANNEL% --default-host %TARGET%
- set PATH=%PATH%;%USERPROFILE%\.cargo\bin
- rustc -Vv
- cargo -V

## Build Script ##
build: false
test_script:
- cargo build --verbose --no-default-features --features "autoconvert usize u8 u16 u32 u64 isize i8 i16 i32 i64 bigint biguint rational rational32 rational64 bigrational f32 f64 si std use_serde"
- cargo test --verbose --no-run --no-default-features --features "autoconvert usize u8 u16 u32 u64 isize i8 i16 i32 i64 bigint biguint rational rational32 rational64 bigrational f32 f64 std use_serde"
- cargo test --all --verbose --features "use_serde"
- cargo test --verbose --features "use_serde %CHANNEL:.=_%"

notifications:
- provider: Email
on_build_success: false
- provider: Email
on_build_success: false
67 changes: 38 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,58 @@
language: rust
cache: cargo
sudo: false

# Dependencies of kcov, used by coverage
sudo: required
addons:
apt:
packages:
- libcurl4-openssl-dev
- libelf-dev
- libdw-dev
- binutils-dev
- cmake
sources:
- kalakris-cmake
- libssl-dev

rust:
- stable
- beta
- nightly
- 1.20.0
- 1.20.0 # Oldest supported
#- stable # Done by explicit job
- beta
- nightly

matrix:
allow_failures:
- rust: nightly
- rust: nightly
include:
- env: TEST
rust: stable
script: |
set -e
cargo test --verbose --features "use_serde ${TRAVIS_RUST_VERSION//./_}"
cargo test --manifest-path tests/feature_check/Cargo.toml --verbose --features "${TRAVIS_RUST_VERSION//./_}"
cargo test --verbose --no-default-features --features "autoconvert f32 f64 si use_serde ${TRAVIS_RUST_VERSION//./_}"
cargo test --verbose --no-run --no-default-features --features "autoconvert usize u8 u16 u32 u64 isize i8 i16 i32 i64 bigint biguint rational rational32 rational64 bigrational f32 f64 std use_serde ${TRAVIS_RUST_VERSION//./_}"
- env: RUSTFMT
rust: 1.26.1
rust: stable
install:
- rustup component add rustfmt-preview
script:
- cargo fmt -- --write-mode=diff

before_script: |
test "${TRAVIS_RUST_VERSION//./_}" != "stable" ||
(test -x /home/travis/.cargo/bin/cargo-coveralls || cargo install cargo-travis) ||
(test $(grep "cargo-travis" /home/travis/.cargo/.crates.toml | sed -r "s/\"cargo-travis ([^\ ]+).+/\1/") = $(cargo search cargo-travis --limit 1 | sed -r "s/cargo-travis \(([^\)]+)\).+/\1/") || cargo install cargo-travis --force)
- cargo fmt -- --check
- env: RUSTFLAGS="-D warnings"
rust: stable
script:
- RUSTFLAGS="-D warnings" cargo check --tests
- env: CLIPPY
rust: nightly
install:
- rustup component add clippy-preview
script:
- cargo clippy -- -D clippy
- env: TARPAULIN
rust: stable
script:
- docker run --security-opt seccomp=unconfined -v "$PWD:/volume" xd009642/tarpaulin sh -c "cargo build && cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID"

script: |
cargo build --verbose --no-default-features --features "autoconvert usize u8 u16 u32 u64 isize i8 i16 i32 i64 bigint biguint rational rational32 rational64 bigrational f32 f64 si std use_serde" &&
cargo test --verbose --no-run --no-default-features --features "autoconvert usize u8 u16 u32 u64 isize i8 i16 i32 i64 bigint biguint rational rational32 rational64 bigrational f32 f64 std use_serde ${TRAVIS_RUST_VERSION//./_}" &&
cargo test --verbose --features "use_serde ${TRAVIS_RUST_VERSION//./_}" &&
cargo test --manifest-path tests/feature_check/Cargo.toml --verbose --features "${TRAVIS_RUST_VERSION//./_}"
install:
- rustc -Vv
- cargo -V

after_success: |
test "${TRAVIS_RUST_VERSION//./_}" != "stable" || cargo coveralls
script:
- set -e
- cargo test --verbose --features "use_serde ${TRAVIS_RUST_VERSION//./_}"
- cargo test --manifest-path tests/feature_check/Cargo.toml --verbose --features "${TRAVIS_RUST_VERSION//./_}"

notifications:
email:
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@

// Compile with `no_std` when the `std` feature is not specified.
#![cfg_attr(not(feature = "std"), no_std)]
// Default rustc lints.
// Rustc lints.
// #![warn(bare_trait_objects)] // Requires rustc 1.27.
#![warn(missing_copy_implementations)]
#![warn(missing_debug_implementations)]
#![warn(missing_docs)]
Expand Down
2 changes: 1 addition & 1 deletion src/si/length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ where
}
}

#[cfg(test)]
#[cfg(all(test, feature = "std"))]
mod tests {
storage_types! {
types: Float;
Expand Down
2 changes: 1 addition & 1 deletion src/tests/quantity.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Tests for the `quantity!` macro.

#[cfg(feature = "autoconvert")]
storage_types! {
use tests::*;

Expand Down Expand Up @@ -50,6 +49,7 @@ storage_types! {
assert_eq!(&"10 kg //10,000 g".parse::<k::Length>(), &Err(ParseQuantityError::UnknownUnit));
}

#[cfg(feature = "autoconvert")]
quickcheck! {
#[allow(trivial_casts)]
fn add(l: A<V>, r: A<V>) -> bool {
Expand Down

0 comments on commit f177d59

Please sign in to comment.