-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Code Coverage #628
Add Code Coverage #628
Changes from all commits
be96539
dee845a
deddcd9
23717be
13cdbbc
4a1fd42
2f363e9
5379aa1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,50 @@ | ||
language: rust | ||
# use trusty for newer openblas | ||
|
||
sudo: required | ||
dist: trusty | ||
|
||
matrix: | ||
include: | ||
- rust: 1.32.0 | ||
env: | ||
- FEATURES='test docs' | ||
- RUSTFLAGS='-D warnings' | ||
env: FEATURES="blas serde-1 docs" | ||
- rust: stable | ||
env: | ||
- FEATURES='test docs' | ||
- RUSTFLAGS='-D warnings' | ||
env: FEATURES="blas serde-1 docs" | ||
- rust: beta | ||
env: | ||
- FEATURES='test docs' | ||
- CHANNEL='beta' | ||
- RUSTFLAGS='-D warnings' | ||
env: FEATURES="blas serde-1 docs" | ||
- rust: nightly | ||
env: | ||
- FEATURES='test docs' | ||
- CHANNEL='nightly' | ||
env: FEATURES="blas serde-1 docs nightly" | ||
allow_failures: | ||
- rust: beta | ||
- rust: nightly | ||
|
||
env: | ||
global: | ||
- HOST=x86_64-unknown-linux-gnu | ||
- CARGO_INCREMENTAL=0 | ||
- RUSTFLAGS="-D warnings" | ||
|
||
cache: cargo | ||
|
||
addons: | ||
apt: | ||
update: true | ||
packages: | ||
- libopenblas-dev | ||
- gfortran | ||
# kcov dependencies | ||
- cmake | ||
- g++ | ||
- pkg-config | ||
- jq | ||
- libcurl4-openssl-dev | ||
- libelf-dev | ||
- libdw-dev | ||
- binutils-dev | ||
- libiberty-dev | ||
|
||
|
||
before_script: | ||
- ./ci/before_script.sh | ||
|
||
script: | ||
- ./scripts/all-tests.sh "$FEATURES" "$CHANNEL" | ||
- ./ci/script.sh | ||
|
||
after_success: | ||
- ./ci/after_success.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#![cfg(feature = "nightly")] | ||
#![feature(test)] | ||
#![allow(unused_imports)] | ||
#![allow( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#![cfg(feature = "nightly")] | ||
#![feature(test)] | ||
|
||
extern crate test; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#![cfg(feature = "nightly")] | ||
#![feature(test)] | ||
#![allow( | ||
clippy::many_single_char_names, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#![cfg(feature = "nightly")] | ||
#![feature(test)] | ||
#![allow( | ||
clippy::many_single_char_names, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#![cfg(feature = "nightly")] | ||
#![feature(test)] | ||
#![allow( | ||
clippy::many_single_char_names, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#![cfg(feature = "nightly")] | ||
#![feature(test)] | ||
#![allow( | ||
clippy::many_single_char_names, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#![cfg(feature = "nightly")] | ||
#![feature(test)] | ||
|
||
extern crate test; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#![cfg(feature = "nightly")] | ||
#![cfg(feature = "rayon")] | ||
#![feature(test)] | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/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 | ||
|
||
|
||
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_BIN --merge kcov \ | ||
kcov-no-default-features \ | ||
kcov-features | ||
} | ||
|
||
coverage_codecov() { | ||
if [[ "$TRAVIS_RUST_VERSION" != "stable" ]]; then | ||
return | ||
fi | ||
|
||
run_kcov | ||
|
||
bash <(curl -s https://codecov.io/bash) -s kcov | ||
echo "Uploaded code coverage to codecov.io" | ||
} | ||
|
||
main() { | ||
coverage_codecov | ||
} | ||
|
||
main |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/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() { | ||
if [[ "$TRAVIS_RUST_VERSION" != "stable" ]]; then | ||
return | ||
fi | ||
cargo install cargo-update || echo "cargo-update already installed" | ||
cargo install cargo-kcov || echo "cargo-kcov already installed" | ||
# Update cached binaries | ||
cargo install-update -a | ||
} | ||
|
||
main() { | ||
rustup_tools | ||
cargo_tools | ||
} | ||
|
||
main |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 --no-default-features | ||
cargo test --all --features "$FEATURES" | ||
} | ||
|
||
main() { | ||
check_lints | ||
check_format | ||
check_tests | ||
} | ||
|
||
main |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#![cfg(feature = "nightly")] | ||
#![feature(test)] | ||
|
||
extern crate test; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,10 +13,11 @@ keywords = ["data-structure", "multidimensional", "parallel", "concurrent"] | |
categories = ["data-structures", "science", "concurrency"] | ||
|
||
[dependencies] | ||
rayon = { version = "1.0" } | ||
ndarray = { version = "0.12.0", path = "../" } | ||
rayon = "1.0" | ||
ndarray = { version = "0.12.0", path = "../", features = ["rayon"]} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious; why is the Note that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I remember correctly, it wasn't running the tests correctly without the rayon feature being enabled (but it was a little while ago that I did this). |
||
|
||
[dev-dependencies] | ||
approx = "0.3.2" | ||
num_cpus = "1.2" | ||
itertools = { version = "0.8.0", default-features = false } | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#![cfg(feature = "nightly")] | ||
#![feature(test)] | ||
|
||
extern crate num_cpus; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't quite right. The BLAS backend is user-selectable. We shouldn't emit a linking directive for the OpenBLAS backend unless testing
ndarray
's BLAS support. (This directive should not be emitted just because BLAS support is enabled, because the user may want to use a different backend.)I think the cleanest solution is to delete
build.rs
entirely (and the corresponding line inCargo.toml
), then add the following toCargo.toml
:Then, to test BLAS support using the system's installed OpenBLAS, enable the
test-blas-openblas-sys
feature. (I've tried runningcargo test --features=test-blas-openblas-sys
on my computer, and this does work without the"openblas-src/system"
feature, but not with that feature. I suspect that this is just an issue with my computer's OpenBLAS installation, and that it'll work fine on CI.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I was misunderstanding how this works (and I'm not sure I fully understand what you would like). My reasoning was that if seems weird to have a feature called
test-foo
. If anything, should we not have afoo
feature and then run these tests ofcfg!(test) && cfg!(feature = "foo")
?