From be96539d80d604ef906040d88132bdd0719ae0a3 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Mon, 13 May 2019 11:17:17 +1000 Subject: [PATCH 1/8] Update CI to add code coverage - This pull requests also runs `cargo clippy`, though warnings raised by clippy *do not* cause the build to fail. - Also added the flag `nightly` for features only available on nightly (such as the `test` crate for benching). Simultaneously remove the `test` feature as this is automatically handled by `cargo test`, and removed the `test-blas-openblas-sys` as it is equivalent to having `cargo test --features blas`. Signed-off-by: JP-Ellis --- .travis.yml | 53 ++++++++++++++++++------------ Cargo.toml | 25 ++++++-------- benches/bench1.rs | 1 + benches/chunks.rs | 1 + benches/construct.rs | 1 + benches/gemv.rs | 1 + benches/higher-order.rs | 1 + benches/iter.rs | 1 + benches/numeric.rs | 1 + benches/par_rayon.rs | 1 + build.rs | 6 ++-- ci/after_success.sh | 60 ++++++++++++++++++++++++++++++++++ ci/before_script.sh | 28 ++++++++++++++++ ci/script.sh | 34 +++++++++++++++++++ ndarray-rand/benches/bench.rs | 1 + numeric-tests/Cargo.toml | 7 +--- parallel/Cargo.toml | 2 +- parallel/benches/rayon.rs | 1 + serialization-tests/Cargo.toml | 17 +++------- 19 files changed, 183 insertions(+), 59 deletions(-) create mode 100755 ci/after_success.sh create mode 100755 ci/before_script.sh create mode 100755 ci/script.sh diff --git a/.travis.yml b/.travis.yml index 4ffb25ad7..758c05918 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,34 +1,45 @@ language: rust -# use trusty for newer openblas + sudo: required -dist: trusty + +rust: + - 1.32.0 + - stable + - beta + - nightly + matrix: - include: - - rust: 1.32.0 - env: - - FEATURES='test docs' - - RUSTFLAGS='-D warnings' - - rust: stable - env: - - FEATURES='test docs' - - RUSTFLAGS='-D warnings' + allow_failures: - rust: beta - env: - - FEATURES='test docs' - - CHANNEL='beta' - - RUSTFLAGS='-D warnings' - rust: nightly - env: - - FEATURES='test docs' - - CHANNEL='nightly' + env: global: - - HOST=x86_64-unknown-linux-gnu - - CARGO_INCREMENTAL=0 + - RUSTFLAGS="-D warnings" + - FEATURES="blas serde-1 docs" + +cache: cargo + addons: apt: + update: true packages: - libopenblas-dev - gfortran + - libcurl4-openssl-dev + - libelf-dev + - libdw-dev + - cmake + - gcc + - binutils-dev + - libiberty-dev + - libgsl0-dev + +before_script: + - ./ci/before_script.sh + script: - - ./scripts/all-tests.sh "$FEATURES" "$CHANNEL" + - ./ci/script.sh + +after_success: + - ./ci/after_success.sh diff --git a/Cargo.toml b/Cargo.toml index e9ea56d8c..855d16c93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,29 +28,25 @@ bench = false test = true [dependencies] +itertools = { version = "0.8.0", default-features = false } +matrixmultiply = "0.2.0" +num-complex = "0.2" num-integer = "0.1.39" num-traits = "0.2" -num-complex = "0.2" -itertools = { version = "0.8.0", default-features = false } - -rayon = { version = "1.0.3", optional = true } +## Optional dependencies approx = { version = "0.3.2", optional = true } - -# Use via the `blas` crate feature! -cblas-sys = { version = "0.1.4", optional = true, default-features = false } blas-src = { version = "0.2.0", optional = true, default-features = false } - -matrixmultiply = { version = "0.2.0" } -# Use via the `serde-1` crate feature! +cblas-sys = { version = "0.1.4", optional = true, default-features = false } serde = { version = "1.0", optional = true } +rayon = { version = "1.0.3", optional = true } [dev-dependencies] +approx = "0.3.2" defmac = "0.2" +itertools = { version = "0.8.0", default-features = false, features = ["use_std"] } quickcheck = { version = "0.8", default-features = false } rawpointer = "0.1" -approx = "0.3.2" -itertools = { version = "0.8.0", default-features = false, features = ["use_std"] } [features] # Enable blas usage @@ -60,9 +56,8 @@ blas = ["cblas-sys", "blas-src"] # Serde 1.0 serde-1 = ["serde"] -# These features are used for testing -test-blas-openblas-sys = ["blas"] -test = ["test-blas-openblas-sys"] +# Enable nightly-only features +nightly = [] # This feature is used for docs docs = ["approx", "serde-1", "rayon"] diff --git a/benches/bench1.rs b/benches/bench1.rs index 4f44f555c..1f20a5b74 100644 --- a/benches/bench1.rs +++ b/benches/bench1.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "nightly")] #![feature(test)] #![allow(unused_imports)] #![allow( diff --git a/benches/chunks.rs b/benches/chunks.rs index a60a6b1fe..30785d855 100644 --- a/benches/chunks.rs +++ b/benches/chunks.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "nightly")] #![feature(test)] extern crate test; diff --git a/benches/construct.rs b/benches/construct.rs index 3d77a89e0..2ef7a3613 100644 --- a/benches/construct.rs +++ b/benches/construct.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "nightly")] #![feature(test)] #![allow( clippy::many_single_char_names, diff --git a/benches/gemv.rs b/benches/gemv.rs index 4bca08319..e21addec9 100644 --- a/benches/gemv.rs +++ b/benches/gemv.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "nightly")] #![feature(test)] #![allow( clippy::many_single_char_names, diff --git a/benches/higher-order.rs b/benches/higher-order.rs index 2ea0721af..67094c9fe 100644 --- a/benches/higher-order.rs +++ b/benches/higher-order.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "nightly")] #![feature(test)] #![allow( clippy::many_single_char_names, diff --git a/benches/iter.rs b/benches/iter.rs index 5cc04293f..4d1d7ea4b 100644 --- a/benches/iter.rs +++ b/benches/iter.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "nightly")] #![feature(test)] #![allow( clippy::many_single_char_names, diff --git a/benches/numeric.rs b/benches/numeric.rs index 4c579eb71..a2b5bb832 100644 --- a/benches/numeric.rs +++ b/benches/numeric.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "nightly")] #![feature(test)] extern crate test; diff --git a/benches/par_rayon.rs b/benches/par_rayon.rs index 55fed98e0..343f772ec 100644 --- a/benches/par_rayon.rs +++ b/benches/par_rayon.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "nightly")] #![cfg(feature = "rayon")] #![feature(test)] diff --git a/build.rs b/build.rs index ceeeff389..ffb3fbee5 100644 --- a/build.rs +++ b/build.rs @@ -1,10 +1,8 @@ -/// -/// This build script emits the openblas linking directive if requested -/// +//! This build script emits the openblas linking directive if requested fn main() { println!("cargo:rerun-if-changed=build.rs"); - if cfg!(feature = "test-blas-openblas-sys") { + if cfg!(feature = "blas") { println!("cargo:rustc-link-lib={}=openblas", "dylib"); } } diff --git a/ci/after_success.sh b/ci/after_success.sh new file mode 100755 index 000000000..53a992022 --- /dev/null +++ b/ci/after_success.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# Echo all commands before executing them +set -o xtrace +# Forbid any unset variables +set -o nounset +# Exit on any error +set -o errexit + +# We only need to run the coverage suite once +COVERAGE_RUN=false +KCOV_BIN="./target/kcov-master/build/src/kcov" + +run_kcov() { + # Run kcov on all the test suites + if [[ $COVERAGE_RUN != "true" ]]; then + cargo coverage --all --tests --benches --no-default-features + mv target/kcov target/kcov-no-default-features + cargo coverage --all --tests --benches --features "$FEATURES" + mv target/kcov target/kcov-features + + $KCOV_BIN --coveralls-id $TRAVIS_JOB_ID --merge target/kcov \ + target/kcov-no-default-features \ + target/kcov-features + + rm -rf \ + target/kcov-no-default-features \ + target/kcov-features + + COVERAGE_RUN=true + fi +} + +coverage_codecov() { + if [[ "$TRAVIS_RUST_VERSION" != "stable" ]]; then + return + fi + + run_kcov + + bash <(curl -s https://codecov.io/bash) -s target/kcov + echo "Uploaded code coverage to codecov.io" +} + +coverage_coveralls() { + if [[ "$TRAVIS_RUST_VERSION" != "stable" ]]; then + return + fi + + run_kcov + + # Data is automatically uploaded by kcov +} + +main() { + coverage_coveralls + coverage_codecov +} + +main diff --git a/ci/before_script.sh b/ci/before_script.sh new file mode 100755 index 000000000..aa97315ca --- /dev/null +++ b/ci/before_script.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Echo all commands before executing them +set -o xtrace +# Forbid any unset variables +set -o nounset +# Exit on any error +set -o errexit + +# Install clippy and rustfmt +rustup_tools() { + rustup component add clippy rustfmt +} + +# Install cargo tools +cargo_tools() { + cargo install cargo-update || echo "cargo-update already installed" + cargo install cargo-travis || echo "cargo-travis already installed" + # Update cached binaries + cargo install-update -a +} + +main() { + rustup_tools + cargo_tools +} + +main diff --git a/ci/script.sh b/ci/script.sh new file mode 100755 index 000000000..ffc29957b --- /dev/null +++ b/ci/script.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Echo all commands before executing them +set -o xtrace +# Forbid any unset variables +set -o nounset +# Exit on any error +set -o errexit + +# Ensure there are no outstanding lints. +check_lints() { + ## In the future, it would be good if `|| true` can be removed so that + ## clippy warnings abort the build. + cargo clippy --all --features "$FEATURES" || true +} + +# Ensure the code is correctly formatted. +check_format() { + cargo fmt --all -- --check +} + +# Run the test suite. +check_tests() { + cargo test --all --examples --tests --benches --no-default-features + cargo test --all --examples --tests --benches --features "$FEATURES" +} + +main() { + check_lints + check_format + check_tests +} + +main diff --git a/ndarray-rand/benches/bench.rs b/ndarray-rand/benches/bench.rs index bdd010bc1..7bac53b05 100644 --- a/ndarray-rand/benches/bench.rs +++ b/ndarray-rand/benches/bench.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "nightly")] #![feature(test)] extern crate test; diff --git a/numeric-tests/Cargo.toml b/numeric-tests/Cargo.toml index dc1261512..96afc7a05 100644 --- a/numeric-tests/Cargo.toml +++ b/numeric-tests/Cargo.toml @@ -18,9 +18,4 @@ features = ["small_rng"] test = false [features] -test_blas = ["ndarray/blas", "ndarray/test-blas-openblas-sys"] - -[profile.dev] -opt-level = 2 -[profile.test] -opt-level = 2 +test_blas = ["ndarray/blas"] \ No newline at end of file diff --git a/parallel/Cargo.toml b/parallel/Cargo.toml index 9eb8e231e..9aaf58801 100644 --- a/parallel/Cargo.toml +++ b/parallel/Cargo.toml @@ -13,7 +13,7 @@ keywords = ["data-structure", "multidimensional", "parallel", "concurrent"] categories = ["data-structures", "science", "concurrency"] [dependencies] -rayon = { version = "1.0" } +rayon = "1.0" ndarray = { version = "0.12.0", path = "../" } [dev-dependencies] diff --git a/parallel/benches/rayon.rs b/parallel/benches/rayon.rs index 629cb21c4..fe396029f 100644 --- a/parallel/benches/rayon.rs +++ b/parallel/benches/rayon.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "nightly")] #![feature(test)] extern crate num_cpus; diff --git a/serialization-tests/Cargo.toml b/serialization-tests/Cargo.toml index 9c46600e1..5e56a2675 100644 --- a/serialization-tests/Cargo.toml +++ b/serialization-tests/Cargo.toml @@ -9,19 +9,12 @@ test = false [dependencies] ndarray = { path = "../", features = ["serde-1"] } +ron = { version = "0.1.1", optional = true } [features] default = ["ron"] -[dev-dependencies.serde] -version = "1.0" - -[dev-dependencies.serde_json] -version = "1.0" - -[dev-dependencies.rmp-serde] -version = "0.13.1" - -[dependencies.ron] -version = "0.1.1" -optional = true +[dev-dependencies] +serde = "1.0" +serde_json = "1.0" +rmp-serde = "0.13.1" \ No newline at end of file From dee845a109bb659d0e164fdef5e5299fddd185c7 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Mon, 13 May 2019 11:50:52 +1000 Subject: [PATCH 2/8] Fix 2 sets of warnings: One warning is due to the use of the deprecated `RcArray`, the other is due to the new `approx` change in master. --- parallel/Cargo.toml | 3 ++- parallel/src/into_impls.rs | 6 +++--- parallel/tests/azip.rs | 4 +++- parallel/tests/rayon.rs | 4 +++- parallel/tests/zip.rs | 2 -- serialization-tests/tests/serialize.rs | 5 +---- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/parallel/Cargo.toml b/parallel/Cargo.toml index 9aaf58801..21986684f 100644 --- a/parallel/Cargo.toml +++ b/parallel/Cargo.toml @@ -14,9 +14,10 @@ categories = ["data-structures", "science", "concurrency"] [dependencies] rayon = "1.0" -ndarray = { version = "0.12.0", path = "../" } +ndarray = { version = "0.12.0", path = "../", features = ["rayon"]} [dev-dependencies] +approx = "0.3.2" num_cpus = "1.2" itertools = { version = "0.8.0", default-features = false } diff --git a/parallel/src/into_impls.rs b/parallel/src/into_impls.rs index 9ac578d2e..dea5c7b4b 100644 --- a/parallel/src/into_impls.rs +++ b/parallel/src/into_impls.rs @@ -1,4 +1,4 @@ -use ndarray::{Array, ArrayView, ArrayViewMut, Dimension, RcArray}; +use ndarray::{ArcArray, Array, ArrayView, ArrayViewMut, Dimension}; use NdarrayIntoParallelIterator; use Parallel; @@ -16,7 +16,7 @@ where } // This is allowed: goes through `.view()` -impl<'a, A, D> NdarrayIntoParallelIterator for &'a RcArray +impl<'a, A, D> NdarrayIntoParallelIterator for &'a ArcArray where D: Dimension, A: Sync, @@ -41,7 +41,7 @@ where } // This is allowed: goes through `.view_mut()`, which is unique access -impl<'a, A, D> NdarrayIntoParallelIterator for &'a mut RcArray +impl<'a, A, D> NdarrayIntoParallelIterator for &'a mut ArcArray where D: Dimension, A: Sync + Send + Clone, diff --git a/parallel/tests/azip.rs b/parallel/tests/azip.rs index 487552596..8d088c8f1 100644 --- a/parallel/tests/azip.rs +++ b/parallel/tests/azip.rs @@ -1,7 +1,9 @@ +extern crate approx; extern crate itertools; extern crate ndarray; extern crate ndarray_parallel; +use approx::assert_abs_diff_eq; use itertools::enumerate; use ndarray::prelude::*; use ndarray_parallel::par_azip; @@ -37,7 +39,7 @@ fn test_par_azip3() { *c = a.sin(); }); let res = Array::linspace(0., 3.1, 32).mapv_into(f32::sin); - assert!(res.all_close(&ArrayView::from(&c), 1e-4)); + assert_abs_diff_eq!(res, ArrayView::from(&c), epsilon = 1e-4); } #[should_panic] diff --git a/parallel/tests/rayon.rs b/parallel/tests/rayon.rs index 9432f9edf..98e03a6c7 100644 --- a/parallel/tests/rayon.rs +++ b/parallel/tests/rayon.rs @@ -1,7 +1,9 @@ +extern crate approx; extern crate ndarray; extern crate ndarray_parallel; extern crate rayon; +use approx::assert_abs_diff_eq; use ndarray::prelude::*; use ndarray_parallel::prelude::*; @@ -30,7 +32,7 @@ fn test_axis_iter_mut() { .into_par_iter() .for_each(|mut v| v.mapv_inplace(|x| x.exp())); println!("{:?}", a.slice(s![..10, ..5])); - assert!(a.all_close(&b, 0.001)); + assert_abs_diff_eq!(a, b, epsilon = 1e-3); } #[test] diff --git a/parallel/tests/zip.rs b/parallel/tests/zip.rs index 63cdd5e92..8eb98d6fc 100644 --- a/parallel/tests/zip.rs +++ b/parallel/tests/zip.rs @@ -2,8 +2,6 @@ extern crate ndarray; extern crate ndarray_parallel; use ndarray::prelude::*; -use ndarray_parallel::prelude::*; - use ndarray::Zip; const M: usize = 1024 * 10; diff --git a/serialization-tests/tests/serialize.rs b/serialization-tests/tests/serialize.rs index 953f2a434..0d35aabf6 100644 --- a/serialization-tests/tests/serialize.rs +++ b/serialization-tests/tests/serialize.rs @@ -1,11 +1,8 @@ extern crate ndarray; - +extern crate rmp_serde; extern crate serde; - extern crate serde_json; -extern crate rmp_serde; - #[cfg(feature = "ron")] extern crate ron; From deddcd9bb0e662636d8f7f2a159acbcfad3ab447 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Tue, 3 Sep 2019 16:53:07 +1000 Subject: [PATCH 3/8] Remove coveralls support in favour of only codecov Signed-off-by: JP-Ellis --- ci/after_success.sh | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/ci/after_success.sh b/ci/after_success.sh index 53a992022..fc3118021 100755 --- a/ci/after_success.sh +++ b/ci/after_success.sh @@ -7,28 +7,22 @@ set -o nounset # Exit on any error set -o errexit -# We only need to run the coverage suite once -COVERAGE_RUN=false KCOV_BIN="./target/kcov-master/build/src/kcov" run_kcov() { # Run kcov on all the test suites - if [[ $COVERAGE_RUN != "true" ]]; then - cargo coverage --all --tests --benches --no-default-features - mv target/kcov target/kcov-no-default-features - cargo coverage --all --tests --benches --features "$FEATURES" - mv target/kcov target/kcov-features - - $KCOV_BIN --coveralls-id $TRAVIS_JOB_ID --merge target/kcov \ - target/kcov-no-default-features \ - target/kcov-features - - rm -rf \ - target/kcov-no-default-features \ - target/kcov-features - - COVERAGE_RUN=true - fi + cargo coverage --all --tests --benches --no-default-features + mv target/kcov target/kcov-no-default-features + cargo coverage --all --tests --benches --features "$FEATURES" + mv target/kcov target/kcov-features + + $KCOV_BIN --merge target/kcov \ + target/kcov-no-default-features \ + target/kcov-features + + rm -rf \ + target/kcov-no-default-features \ + target/kcov-features } coverage_codecov() { @@ -42,18 +36,7 @@ coverage_codecov() { echo "Uploaded code coverage to codecov.io" } -coverage_coveralls() { - if [[ "$TRAVIS_RUST_VERSION" != "stable" ]]; then - return - fi - - run_kcov - - # Data is automatically uploaded by kcov -} - main() { - coverage_coveralls coverage_codecov } From 23717be09a885b7e1dc1cf55818d4ca4152958e9 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Tue, 3 Sep 2019 16:54:11 +1000 Subject: [PATCH 4/8] Only install cargo-travis on stable Signed-off-by: JP-Ellis --- ci/before_script.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/before_script.sh b/ci/before_script.sh index aa97315ca..9db7f71d9 100755 --- a/ci/before_script.sh +++ b/ci/before_script.sh @@ -14,6 +14,9 @@ rustup_tools() { # Install cargo tools cargo_tools() { + if [[ "$TRAVIS_RUST_VERSION" != "stable" ]]; then + return + fi cargo install cargo-update || echo "cargo-update already installed" cargo install cargo-travis || echo "cargo-travis already installed" # Update cached binaries From 13cdbbc03364746293be57438c3650024adca628 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Tue, 3 Sep 2019 17:01:17 +1000 Subject: [PATCH 5/8] Add "nightly" features Signed-off-by: JP-Ellis --- .travis.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 758c05918..71794ccb4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,13 +2,16 @@ language: rust sudo: required -rust: - - 1.32.0 - - stable - - beta - - nightly - matrix: + include: + - rust: 1.32.0 + env: FEATURES="blas serde-1 docs" + - rust: stable + env: FEATURES="blas serde-1 docs" + - rust: beta + env: FEATURES="blas serde-1 docs" + - rust: nightly + env: FEATURES="blas serde-1 docs nightly" allow_failures: - rust: beta - rust: nightly @@ -16,7 +19,6 @@ matrix: env: global: - RUSTFLAGS="-D warnings" - - FEATURES="blas serde-1 docs" cache: cargo From 4a1fd42fa547d33f39d20a29234feb502528a950 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Tue, 3 Sep 2019 23:04:57 +1000 Subject: [PATCH 6/8] Switch from cargo-travis to cargo-kcov Signed-off-by: JP-Ellis --- .travis.yml | 9 +-------- ci/after_success.sh | 22 +++++++--------------- ci/before_script.sh | 2 +- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index 71794ccb4..443300471 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,14 +28,7 @@ addons: packages: - libopenblas-dev - gfortran - - libcurl4-openssl-dev - - libelf-dev - - libdw-dev - - cmake - - gcc - - binutils-dev - - libiberty-dev - - libgsl0-dev + - kcov before_script: - ./ci/before_script.sh diff --git a/ci/after_success.sh b/ci/after_success.sh index fc3118021..bd0473886 100755 --- a/ci/after_success.sh +++ b/ci/after_success.sh @@ -7,22 +7,14 @@ set -o nounset # Exit on any error set -o errexit -KCOV_BIN="./target/kcov-master/build/src/kcov" - run_kcov() { # Run kcov on all the test suites - cargo coverage --all --tests --benches --no-default-features - mv target/kcov target/kcov-no-default-features - cargo coverage --all --tests --benches --features "$FEATURES" - mv target/kcov target/kcov-features - - $KCOV_BIN --merge target/kcov \ - target/kcov-no-default-features \ - target/kcov-features - - rm -rf \ - target/kcov-no-default-features \ - target/kcov-features + cargo kcov --all --no-default-features --output kcov-no-default-features + cargo kcov --all --features "$FEATURES" --output kcov-features + + kcov --merge kcov \ + kcov-no-default-features \ + kcov-features } coverage_codecov() { @@ -32,7 +24,7 @@ coverage_codecov() { run_kcov - bash <(curl -s https://codecov.io/bash) -s target/kcov + bash <(curl -s https://codecov.io/bash) -s kcov echo "Uploaded code coverage to codecov.io" } diff --git a/ci/before_script.sh b/ci/before_script.sh index 9db7f71d9..d9e9c9e3a 100755 --- a/ci/before_script.sh +++ b/ci/before_script.sh @@ -18,7 +18,7 @@ cargo_tools() { return fi cargo install cargo-update || echo "cargo-update already installed" - cargo install cargo-travis || echo "cargo-travis already installed" + cargo install cargo-kcov || echo "cargo-kcov already installed" # Update cached binaries cargo install-update -a } From 2f363e96ed0eee802c84e19fe2661a6c869f64a5 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Tue, 3 Sep 2019 23:12:12 +1000 Subject: [PATCH 7/8] No need to explicitly specify --examples, --tests, --benches Signed-off-by: JP-Ellis --- ci/script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/script.sh b/ci/script.sh index ffc29957b..911e97608 100755 --- a/ci/script.sh +++ b/ci/script.sh @@ -21,8 +21,8 @@ check_format() { # Run the test suite. check_tests() { - cargo test --all --examples --tests --benches --no-default-features - cargo test --all --examples --tests --benches --features "$FEATURES" + cargo test --all --no-default-features + cargo test --all --features "$FEATURES" } main() { From 5379aa1baacc9c9bea976e094875d4442714c42c Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Tue, 3 Sep 2019 23:18:06 +1000 Subject: [PATCH 8/8] Have to install build kcov as repository kcov is too old Signed-off-by: JP-Ellis --- .travis.yml | 12 +++++++++++- ci/after_success.sh | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 443300471..1115dd728 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,17 @@ addons: packages: - libopenblas-dev - gfortran - - kcov + # kcov dependencies + - cmake + - g++ + - pkg-config + - jq + - libcurl4-openssl-dev + - libelf-dev + - libdw-dev + - binutils-dev + - libiberty-dev + before_script: - ./ci/before_script.sh diff --git a/ci/after_success.sh b/ci/after_success.sh index bd0473886..ad368efee 100755 --- a/ci/after_success.sh +++ b/ci/after_success.sh @@ -7,12 +7,16 @@ set -o nounset # Exit on any error set -o errexit + run_kcov() { + sh <(cargo kcov --print-install-kcov-sh) + KCOV_BIN="./$(ls | grep kcov)/build/src/kcov" + # Run kcov on all the test suites cargo kcov --all --no-default-features --output kcov-no-default-features cargo kcov --all --features "$FEATURES" --output kcov-features - kcov --merge kcov \ + $KCOV_BIN --merge kcov \ kcov-no-default-features \ kcov-features }