tests/test-all.R

if (Sys.getenv("_LOCAL_TESTS_")=="TRUE") { ## not on CRAN
  if(require("testthat", quietly = TRUE)) {
    pkg   <- "genepop"
    require(pkg, character.only=TRUE, quietly=TRUE)
    if (interactive())  {
      fn <- get("getActiveProject",envir = asNamespace("rstudioapi"))
      projpath <- fn()
      testfiles <- dir(paste0(projpath,"/tests/testthat/"),pattern="*.R",full.names = TRUE)
      timings <- t(sapply(testfiles,function(fich){system.time(source(fich))}))
      print(colSums(timings))
      ## test_package(pkg) ## for an installed package
    } else {
      report <- test_check(pkg) ## for R CMD check ## report is NULL...
      print(warnings()) # TODO? catch most of these by expect_warning(..)
    }
  } else {
    cat( "package 'testthat' not available, cannot run unit tests\n" )
  }
}

Try the genepop package in your browser

Any scripts or data that you put into this service are public.

genepop documentation built on Jan. 22, 2023, 1:07 a.m.