Skip to content

Commit

Permalink
Merge pull request #358 from DrylandEcology/bugfix357_masterCIs_failing
Browse files Browse the repository at this point in the history
- closes #357 by requiring a fixed version of rSOILWAT2 v2.3.5
- fixed DayMet unit tests
- fixed netCDF unit tests
  • Loading branch information
dschlaep committed Mar 5, 2019
2 parents 7bb4972 + 252b173 commit ce37dc6
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 49 deletions.
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,16 @@ install:
script:
- R CMD build --no-build-vignettes --no-manual .
# The extended unit test project
# (commit db3948e6aa746d012dbc4f25b0e9bb2a4186305f) takes about 16 min which
# is too long for the default settings of 10-min and times out
# On failure, display file 'testthat.Rout.fail' for more information and fail
# - travis_wait 30 R CMD check *tar.gz --as-cran --ignore-vignettes --no-manual || { cat rSFSW2.Rcheck/tests/testthat.Rout* && 1; }
- travis_wait 30 R CMD check *tar.gz --as-cran --ignore-vignettes --no-manual && cat rSFSW2.Rcheck/tests/testthat.Rout*
# (commit db3948e6aa746d012dbc4f25b0e9bb2a4186305f) takes about 16 min which
# is too long for the default settings of 10-min and times out --> use `travis_wait`
- travis_wait 30 R CMD check *tar.gz --as-cran --ignore-vignettes --no-manual

after_success:
# Display testthat log file for more information if it exists and has content
- fname="rSFSW2.Rcheck/tests/testthat.Rout" && [ -s $fname ] && cat $fname
# Perform code cover estimate
- travis_wait 30 Rscript -e 'covr::codecov()'

after_failure:
# Display failed testthat log file for more information if it exists and has content
- fname="rSFSW2.Rcheck/tests/testthat.Rout.fail" && [ -s $fname ] && cat $fname
11 changes: 6 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rSFSW2
Title: Simulation Framework for SOILWAT2
Version: 3.1.2
Date: 2018-10-27
Version: 3.1.3
Date: 2019-03-01
Authors@R: c(
person("Daniel", "Schlaepfer", email = "daniel.schlaepfer@yale.edu",
comment = c(ORCID = "0000-0001-9973-2065"), role = c("aut", "cre")),
Expand All @@ -12,9 +12,9 @@ Authors@R: c(
Description: Setting up, carrying out, and analyzing ecosystem water balance
simulation experiments with SOILWAT2.
Depends:
R (>= 3.3.0)
R (>= 3.4.0)
Imports:
rSOILWAT2 (>= 2.3.2),
rSOILWAT2 (>= 2.3.5),
RSQLite (>= 2.1.1),
DBI (>= 1.0),
Rcpp (>= 0.12.12),
Expand Down Expand Up @@ -45,7 +45,8 @@ Suggests:
spelling (>= 1.1),
hunspell (>= 2.9),
covr,
lintr
lintr (>= 1.0.3),
goodpractice
Remotes:
github::dschlaep/weathergen
LinkingTo:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ There are several options:
'rSFSW2' will compile some c code via 'Rcpp'. Your computer must be set up
adequately.
- If you use a Windows OS, then you need the
[Rtools](http://cran.us.r-project.org/bin/windows/Rtools/)
[Rtools](https://cran.r-project.org/bin/windows/Rtools/)
installed that match your R version; please find further information for
instance [here](https://www.biostat.wisc.edu/~kbroman/Rintro/Rwinpack.html).
- If you use a macOS, then you need [Xcode](https://developer.apple.com/xcode/)
Expand All @@ -88,7 +88,7 @@ someone without development tools) for a platform to which you do not have
access, then you may consider using one of the cloud services (no endorsements):
- [r-hub](https://builder.r-hub.io) offers different Linux, Windows, and mac OS
flavors as targets
- [win-builder](http://win-builder.r-project.org/) offers Windows OS as target
- [win-builder](https://win-builder.r-project.org/) offers Windows OS as target

Alternatively, you may access the previous binary package version for Windows
OS from our CI appveyor service if the build was successful and an artifact was
Expand Down Expand Up @@ -193,7 +193,7 @@ You can contribute to this project in different ways:
- __Code documentation__
* Read the section 'Object documentation' in
[Wickham's book 'R packages'](http://r-pkgs.had.co.nz/man.html)
* Use [roxygen2](https://cran.r-project.org/web/packages/roxygen2/vignettes/formatting.html)
* Use [roxygen2](https://CRAN.R-project.org/package=roxygen2/vignettes/formatting.html)
to write inline code documentation
* Update help pages and NAMESPACE with the command `devtools::document()`
* Ideally, add examples to function documentation and check these examples
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test_WeatherDB_DayMet.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ if (!any(do_skip) && is_online) {
repeat {
# Make sure that `avail_end_year` is indeed available
# (e.g., during first days of a new year)
testavail <- get_DayMet_NorthAmerica(dir_data = dm_path,
testavail <- try(get_DayMet_NorthAmerica(dir_data = dm_path,
cellID = "daymet_pixel_+002083_+000426",
Xdm_WGS84 = -105.5934, Ydm_WGS84 = 41.31557,
start_year = avail_end_year, end_year = avail_end_year,
dbW_digits = 2L)
dbW_digits = 2L), silent = TRUE)

if (inherits(testavail, "try-error") && avail_end_year > 1980) {
avail_end_year <- avail_end_year - 1L
Expand Down
21 changes: 18 additions & 3 deletions tests/testthat/test_netCDF_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,35 @@ if (!any(do_skip) && is_online) {
)

# Download test files
has_test_ncs <- lapply(test_ncs, function(x) {
is_nc <- function(filename) {
.local <- function() {
stopifnot(requireNamespace("ncdf4"))

nc <- ncdf4::nc_open(filename = filename, write = FALSE, readunlim = TRUE,
verbose = FALSE)
ncdf4::nc_close(nc)
}

try(.local(), silent = TRUE)
}

# suppress warnings if a download fails (e.g., "cannot open URL",
# "NetCDF: Unknown file format")
has_test_ncs <- suppressWarnings(lapply(test_ncs, function(x) {
if (is.na(x[["url"]]) || is.na(x[["expect"]])) {
FALSE
} else {
has <- try(utils::download.file(url = x[["url"]],
destfile = x[["filename"]], quiet = TRUE), silent = TRUE)
if (isTRUE(has == 0)) {

if (isTRUE(has == 0) && isTRUE(is_nc(x[["filename"]]))) {
TRUE
} else {
unlink(x[["filename"]])
FALSE
}
}
})
}))

#--- Tests
test_that("read_time_netCDF:", {
Expand Down
13 changes: 9 additions & 4 deletions tests/testthat/test_rSFSW2_CodeStylePractices.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ test_that("Package code style", {
skip_if_not(identical(tolower(Sys.getenv("RSFSW2_ALLTESTS")), "true"))
skip_on_cran()
skip_on_appveyor()
# minimum version of lintr required for:
# as of 2019-03-01 development is minimum version of lintr required for:
# - empty commas in multi-dimensional array subsetting, e.g., x[, , 1:3]
skip_if_not_installed("lintr", minimum_version = "1.0.2.9000")

lintr_v <- unlist(utils::packageVersion("lintr"))
if (length(lintr_v) < 4 || isTRUE(lintr_v[4L] < 9000)) {
skip("Installed version of lintr is insufficient.")
}

# Files that are not checked for lints
files_not_tolint <- c(
Expand Down Expand Up @@ -48,7 +50,10 @@ test_that("Package code style", {
files_tolint <- pkg_code_files[ids]

for (k in seq_along(files_tolint)) {
badstyle <- lintr::lint(files_tolint[k])
# 2019 Feb 27: this call to `lint` generates a number of warnings
# "argument is not a function" --> ignore for now because we include
# with `pkg_code_files` code that includes scripts etc.
suppressWarnings(badstyle <- lintr::lint(files_tolint[k]))
expect_identical(length(badstyle), 0L, info = print(badstyle))
}
}
Expand Down
31 changes: 4 additions & 27 deletions tests/testthat/test_rSFSW2_Spelling.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,12 @@ test_that("Package spell checks", {
skip_if_not(identical(tolower(Sys.getenv("RSFSW2_ALLTESTS")), "true"))
skip_on_cran()
skip_on_appveyor()

# Check which package is available for spell-checking
do_spelling <- requireNamespace("spelling", quietly = TRUE) &&
utils::packageVersion("spelling") >= "1.1.0"
has_old_devtools <- if (do_spelling) FALSE else {
requireNamespace("devtools", quietly = TRUE) &&
utils::packageVersion("devtools") < "2.0.0"
}
skip_if_not_installed("spelling", minimum_version = "1.1.0")

# Spell check with `hunspell` as backend:
if (do_spelling) {
# TODO: turn spell-checking on for vignettes
temp <- spelling::spell_check_package(pkg_path, vignettes = FALSE)
misspelled <- temp[["word"]]

} else if (has_old_devtools) {
# old devtools version with `ignore` argument
# ignores text in roxygen2 content directives, e.g., \url{}, \var{},
# but checks text in roxygen2 formatting directives, e.g., \sQuote{}

# ignore additional words (keep as short as possible)
spell_ignores <- scan(file.path(pkg_path, "inst", "WORDLIST"),
what = "character", comment.char = "#", quiet = TRUE)

misspelled <- devtools::spell_check(pkg = pkg_path, ignore = spell_ignores)

} else {
skip("No spell-checker found.")
}
# TODO: turn spell-checking on for vignettes
temp <- spelling::spell_check_package(pkg_path, vignettes = FALSE)
misspelled <- temp[["word"]]

expect_identical(length(misspelled), 0L, info = print(misspelled))
})

0 comments on commit ce37dc6

Please sign in to comment.