R Under development (unstable) (2023-04-30 r84357 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > if (Sys.getenv("_LOCAL_TESTS_")=="TRUE") { ## not on CRAN + if(require("testthat", quietly = TRUE)) { + pkg <- "blackbox" + require(pkg, character.only=TRUE, quietly=TRUE) + ## test_package(pkg) ## for an installed package + if (interactive()) { + if (FALSE) { ## tests not included in package (using unpublished data, etc.) + oldpath <- getwd() + ptpath <- paste0(blackbox::projpath(),"/package/tests_private/") + subpaths <- dir(ptpath,full.names = TRUE) + virgin_opts <- blackbox.options() + priv_timings <- list() + # the migraine scripts have rm(list=ls()) hence we copy some variable in the options 'keep_over_blackbox_tests' and 'blackbox_path' + options(keep_over_blackbox_tests=mget(c("oldpath","subpaths","virgin_opts","priv_timings"),.GlobalEnv)) + for (st in getOption("keep_over_blackbox_tests")$subpaths) { + options("blackbox_path"=st) + setwd(st) + blackbox.options(getOption("keep_over_blackbox_tests")$virgin_opts) + priv_timing <- system.time(source("migraine_1.R")) + keep_over_blackbox_tests <- getOption("keep_over_blackbox_tests") + keep_over_blackbox_tests$priv_timings[[getOption("blackbox_path")]] <- priv_timing + options("keep_over_blackbox_tests"=keep_over_blackbox_tests) + } + setwd(getOption("keep_over_blackbox_tests")$oldpath) + #priv_testfiles <- dir(ptpath,pattern="*.R",full.names = TRUE) + #priv_timings <- t(sapply(priv_testfiles, function(fich){system.time(source(fich))})) + print(getOption("keep_over_blackbox_tests")$priv_timings) + } + } 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" ) + } + } > > proc.time() user system elapsed 0.25 0.06 0.25