зеркало из https://github.com/microsoft/LightGBM.git
[R-package] Added instructions for generating R test coverage (#2664)
This commit is contained in:
Родитель
2048b1393f
Коммит
f449a78df3
|
@ -321,6 +321,9 @@ nosetests.xml
|
|||
coverage.xml
|
||||
*,cover
|
||||
.hypothesis/
|
||||
**/coverage.html
|
||||
**/coverage.html.zip
|
||||
R-package/tests/testthat/Rplots.pdf
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
|
|
@ -126,6 +126,30 @@ Please visit [demo](https://github.com/microsoft/LightGBM/tree/master/R-package/
|
|||
* [Leaf (in)Stability](https://github.com/microsoft/LightGBM/blob/master/R-package/demo/leaf_stability.R)
|
||||
* [Weight-Parameter Adjustment Relationship](https://github.com/microsoft/LightGBM/blob/master/R-package/demo/weight_param.R)
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
||||
The R package's unit tests are run automatically on every commit, via integrations like [Travis CI](https://travis-ci.org/microsoft/LightGBM/) and [Azure DevOps](https://dev.azure.com/lightgbm-ci/lightgbm-ci/_build). Adding new tests in `R-package/tests/testthat` is a valuable way to improve the reliability of the R package.
|
||||
|
||||
When adding tests, you may want to use test coverage to identify untested areas and to check if the tests you've added are covering all branches of the intended code.
|
||||
|
||||
The example below shows how to generate code coverage for the R package on a macOS or Linux setup, using `gcc-8` to compile `LightGBM`. To adjust for your environment, swap out the 'Install' step with [the relevant code from the instructions above](#install).
|
||||
|
||||
```shell
|
||||
# Install
|
||||
export CXX=/usr/local/bin/g++-8
|
||||
export CC=/usr/local/bin/gcc-8
|
||||
Rscript build_r.R
|
||||
|
||||
# Get coverage
|
||||
rm -rf lightgbm_r/build
|
||||
Rscript -e " \
|
||||
coverage <- covr::package_coverage('./lightgbm_r', quiet=FALSE);
|
||||
print(coverage);
|
||||
covr::report(coverage, file = file.path(getwd(), 'coverage.html'), browse = TRUE);
|
||||
"
|
||||
```
|
||||
|
||||
External (Unofficial) Repositories
|
||||
----------------------------------
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче