-
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #628 +/- ##
=======================================
Coverage ? 96%
=======================================
Files ? 78
Lines ? 8851
Branches ? 0
=======================================
Hits ? 8497
Misses ? 354
Partials ? 0
Continue to review full report at Codecov.
|
Nice!
These observations aside, it looks good to me 👍 |
|
I'd prefer to see those reverted for now - we can open another PR to properly fill in the missing gaps and then start failing builds if docs are missing. |
The I'll disable |
I'd like to go ahead and merge this - do you want to have a look first @jturner314 @termoshtt? |
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 is great progress in the right direction, but there are a few issues that need to be resolved before we merge this.
.travis.yml
Outdated
sudo: required | ||
dist: trusty | ||
|
||
rust: |
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.
We should keep the fixed Rust version (1.31.0) as one of the tested versions in addition to the latest stable. (This prevents us from accidentally merging code that requires a newer Rust version without realizing it.)
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 is going to be a little annoying to do as some of the code checking dependencies require a newer version. Would it be acceptable if code coverage is disable on 1.31.0?
|
||
fn main() { | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
if cfg!(feature = "test-blas-openblas-sys") { | ||
if cfg!(feature = "blas") { |
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 in Cargo.toml
), then add the following to Cargo.toml
:
[dependencies]
...
# This should be used only for the `test-blas-openblas-sys` feature.
openblas-src = { version = "0.6.0", optional = true, default-features = false }
[features]
...
# This feature is used for testing BLAS support with the system OpenBLAS.
test-blas-openblas-sys = ["blas", "blas-src/openblas", "openblas-src", "openblas-src/cblas", "openblas-src/system"]
Then, to test BLAS support using the system's installed OpenBLAS, enable the test-blas-openblas-sys
feature. (I've tried running cargo 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 a foo
feature and then run these tests of cfg!(test) && cfg!(feature = "foo")
?
.travis.yml
Outdated
rust: | ||
- stable | ||
- beta | ||
- nightly |
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.
The "nightly"
feature needs to be enabled for the nightly run (so that e.g. the benchmarks get compiled).
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.
Yes, that is true. I thought I was doing that, but I'll double check.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious; why is the "rayon"
feature necessary here?
Note that the ndarray-parallel
crate (the stuff in the parallel
directory) became obsolete after its functionality was added directly to ndarray
behind the "rayon"
feature.
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.
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).
ci/after_success.sh
Outdated
echo "Uploaded code coverage to codecov.io" | ||
} | ||
|
||
coverage_coveralls() { |
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.
I'd prefer to remove coveralls and just use codecov.io (since it would be nice to pick just one for simplicity, and codecov.io is already used for ndarray-stats
). IIUC, this would eliminate the need for the COVERAGE_RUN
variable.
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.
I had both as it isn't anymore complicated, but I can certainly just have one.
ci/after_success.sh
Outdated
# 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 |
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.
Do we need to move the coverage results like this? The docs for the cargo coverage
command seem to indicate that it automatically merges all results together into target/kcov
when run multiple times, but I may be misinterpreting the docs.
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.
Unfortunately yes. cargo coverage
merges results from one run, but not from several different runs with different features unfortunately.
ci/after_success.sh
Outdated
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 |
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.
The commands above don't run all the tests. (They miss the ones in serialization-tests
, blas-tests
, and numeric-tests
.)
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.
That's odd; the --all
flag should run all tests from all workspaces. Could this be left as-is and once this pull request in merged, I'll work on #637?
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.
numeric-tests is explicitly not in the workspace, so that it can use its own profile/compilation settings. It can be added if that can be achieved another way
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.
ci/script.sh
Outdated
# Run the test suite. | ||
check_tests() { | ||
cargo test --all --examples --tests --benches --no-default-features | ||
cargo test --all --examples --tests --benches --features "$FEATURES" |
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.
IIUC, the commands above don't run all the tests. (They miss the ones in serialization-tests
, blas-tests
, and numeric-tests
.)
As I see it, we have two options:
-
Keep the existing
serialization-tests
,blas-tests
, andnumeric-tests
crates and run their tests in the scripts. -
Merge them into the
ndarray
crate, adding the necessary optional dependencies and creating the necessary test-specific features inndarray
, similar to how I'm suggesting to handle thetest-blas-openblas-src
feature.
I think option 2 is a bit cleaner, but either is fine with me. Either way, we need to make sure that we run these tests.
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.
I created an issue about specifically this in #637. I agree that keeping these scripts separate isn't nice and integrating them I think would be the best option.
@JP-Ellis I'm happy to help on integrating the test workspaces, if you can find some minimal version of this to merge in |
- 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 <[email protected]>
One warning is due to the use of the deprecated `RcArray`, the other is due to the new `approx` change in master.
Signed-off-by: JP-Ellis <[email protected]>
Signed-off-by: JP-Ellis <[email protected]>
I've rebased this pull request on top of master. I've also incorporated some of the changes mentioned above, including:
Let me know if there's anything else that should be added? There's one thing discussed above which I haven't changed: the Note that I've also switch from using It might be worth considering |
Signed-off-by: JP-Ellis <[email protected]>
Signed-off-by: JP-Ellis <[email protected]>
Signed-off-by: JP-Ellis <[email protected]>
Signed-off-by: JP-Ellis <[email protected]>
This pull request's primary goal is to add code coverage, which can be seen at codecov and coveralls (note that former only displays stats from the
master
branch on the front page, but you can see stats from commits at https://codecov.io/gh/JP-Ellis/ndarray/commits).In addition, this pull requests also adds
cargo clippy
andcargo fmt
. Failure to pass these does not cause the build to break, but serves as a warning.I also took the slight liberty to change some of the features relating to testing. Nightly features are kept behind the
nightly
flag (which has no other dependencies), andcargo test
automatically enables thecfg(test)
flag making thetst
feature somewhat redundant. Tests which are specific to certain features (such asblas
) can be enabled by invokingcargo
with the--feature blas
flag.Lastly, the first build does take a long time due to the
cargo travis
installation; however, I have enabled caching with travis so that subsequent runs can complete substantially faster.EDIT: Forgot to mention that I've added the flags
-D warnings
and-D missing_docs
which causes the build to fail if there are any warnings or missing documentation on public facing elements. Fortunately, there were very few such warnings which I've fixed (albeit temporarily in the case of the documentation).