ropensci / RNeXML

Implementing semantically rich NeXML I/O in R
https://docs.ropensci.org/RNeXML
Other
13 stars 9 forks source link

Tests fail when suggested packages not installed #119

Closed hadley closed 9 years ago

hadley commented 9 years ago
checking tests ... ERROR
Running the tests in ‘tests/test-all.R’ failed.
Last 13 lines of output:
   Taxa:      ... 

   NeXML generated by RNeXML using schema version: 0.9 
   size: 21.7 Kb 
  Authentication successful
  Error in library(phytools) : there is no package called 'phytools'
  Calls: test_check ... lapply -> FUN -> sys.source2 -> eval -> eval -> library
  In addition: Warning messages:
  1: In merge.data.frame(dfs, ..., by = "row.names", all = TRUE, sort = FALSE) :
    column names 'cs15_log snout-vent length.x', 'cs15_log snout-vent length.y' are duplicated in the result
  2: In merge.data.frame(dfs, ..., by = "row.names", all = TRUE, sort = FALSE) :
    column names 'cs31_reef-dwelling.x', 'cs31_reef-dwelling.y' are duplicated in the result
  Execution halted

You can use skip_if_not_installed() to avoid this problem.

cboettig commented 9 years ago

@hadley Thanks for this, now that the new testthat is available on CRAN I guess I can release this. I hadn't done so earlier as the fix requires this skip_if_not_installed() function which wasn't available on previous testthat versions. Not sure what the right strategy is in such cases.

hadley commented 9 years ago

I think the best practice is to make it conditional, i.e.

if (packageVersion("testthat") >= "0.10.0") {
  testthat::skip_if_not_installed(...)
}

but that's a reasonable amount of work for little gain in many cases.