Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should be able to alter the doSvUnit.R script to at least emit warnings and errors as you describe. What you want to do is to run the tests and then inspect the return value of the test runner and have R code that calls, warning() or stop().</p> <p>For an example of how this was done using RUnit, take a look at the codetoolsBioC package in the Bioconductor repository. The relevant code is in inst/templates and copied below:</p> <pre><code>.test &lt;- function(dir, pattern = ".*_test\\.R$") { .failure_details &lt;- function(result) { res &lt;- result[[1L]] if (res$nFail &gt; 0 || res$nErr &gt; 0) { Filter(function(x) length(x) &gt; 0, lapply(res$sourceFileResults, function(fileRes) { names(Filter(function(x) x$kind != "success", fileRes)) })) } else list() } if (missing(dir)) { dir &lt;- system.file("unitTests", package="@PKG@") if (!nzchar(dir)) { dir &lt;- system.file("UnitTests", package="@PKG@") if (!nzchar(dir)) stop("unable to find unit tests, no 'unitTests' dir") } } ## Run unit tests from the directory containing the test files. ## This allows tests to refer to data files with relative paths cwd &lt;- getwd() on.exit(setwd(cwd)) setwd(dir) require("RUnit", quietly=TRUE) || stop("RUnit package not found") RUnit_opts &lt;- getOption("RUnit", list()) RUnit_opts$verbose &lt;- 0L RUnit_opts$silent &lt;- TRUE RUnit_opts$verbose_fail_msg &lt;- TRUE options(RUnit = RUnit_opts) suite &lt;- defineTestSuite(name="@PKG@ RUnit Tests", dirs=getwd(), testFileRegexp=pattern, rngKind="default", rngNormalKind="default") result &lt;- runTestSuite(suite) cat("\n\n") printTextProtocol(result, showDetails=FALSE) if (length(details &lt;- .failure_details(result)) &gt;0) { cat("\nTest files with failing tests\n") for (i in seq_along(details)) { cat("\n ", basename(names(details)[[i]]), "\n") for (j in seq_along(details[[i]])) { cat(" ", details[[i]][[j]], "\n") } } cat("\n\n") stop("unit tests failed for package @PKG@") } result } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload