Version: | 1.0 |
Date: | 2025-02-20 |
Title: | Wrapper for 'run_examples()' |
Maintainer: | Barry Zeeberg <barryz2013@gmail.com> |
Author: | Barry Zeeberg [aut, cre] |
Depends: | R (≥ 4.2.0) |
Imports: | devtools |
Description: | Captures errors encountered when running 'run_examples()', and processes and archives them. The function 'run_examples()' within the 'devtools' package allows batch execution of all of the examples within a given package. This is much more convenient than testing each example manually. However, a major inconvenience is that if an error is encountered, the program stops and does not complete testing the remaining examples. Also, there is not a systematic record of the results, namely which package functions had no examples, which had examples that failed, and which had examples that succeeded. The current package provides the missing functionality. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Encoding: | UTF-8 |
VignetteBuilder: | knitr |
Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) |
RoxygenNote: | 7.3.1 |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2025-02-21 12:58:01 UTC; barryzeeberg |
Repository: | CRAN |
Date/Publication: | 2025-02-21 20:20:02 UTC |
RunExamples
Description
driver to automate run_examples() and retrieve the test results for each example
Usage
RunExamples(
pack,
run_donttest = TRUE,
run_dontrun = TRUE,
out = sprintf("%s/%s", tempdir(), "runExamplesOut.txt"),
verbose = FALSE
)
Arguments
pack |
character string containing the path name of the package directory |
run_donttest |
parameter to be passed to run_examples() |
run_dontrun |
parameter to be passed to run_examples() |
out |
character string containing the path name of the run_examples() results output file |
verbose |
Boolean if TRUE generate some diagnostic information |
Value
returns a character vector specifying each function example as either "GOOD", "BAD", or "MIA"
Examples
## Not run:
# replace dir and pack with your own versions!!
# run this example within the RStudio Console for the package 'pack'
dir1<-"~/personal/hearts/hearts_card_game_bayesian_inference/packages/"
dir2<-"inference_packages/inference_packages/"
dir<-sprintf("%s/%s",dir1,dir2)
pack<-sprintf("%s/%s",dir,"cardUtils")
v<-RunExamples(pack,verbose=FALSE)
## End(Not run)
balanceCurly
Description
retrieve lines of text between '@examples' and matching curly braces
Usage
balanceCurly(v)
Arguments
v |
character vector |
Value
returns lines of text between '@examples' and matching curly braces
Examples
v<-c("@examples{","xxx","}","{","{")
x<-balanceCurly(v)
cat(x,sep="\n")
parseRunExamples
Description
retrieve the lines containing the function name within the run_examples() results output file
Usage
parseRunExamples(f)
Arguments
f |
character string containing the path name of the run_examples() results output file |
Value
returns a list of the lines containing the function name
Examples
## Not run:
# replace dir and pack with your own versions!!
# run this example within the RStudio Console for the package 'pack'
dir1<-"~/personal/hearts/hearts_card_game_bayesian_inference/packages/"
dir2<-"inference_packages/inference_packages/"
dir<-sprintf("%s/%s",dir1,dir2)
pack<-sprintf("%s/%s",dir,"cardUtils")
out<-"~/test.txt"
sink(out)
on.exit(sink())
try(run_examples(pack,run_donttest=TRUE,run_dontrun=TRUE,document=FALSE))
sink()
x<-parseRunExamples(out)
## End(Not run)
retrieveExamplesFromMan
Description
retrieve the text of examples for man files
Usage
retrieveExamplesFromMan(package)
Arguments
package |
character string full pathname for the package folder |
Value
returns a list whose components are a list of examples text and a list of number of lines in each example text
Examples
## Not run:
# replace package with your own version!!
dir1<-"~/personal/hearts/hearts_card_game_bayesian_inference/packages/"
dir2<-"inference_packages/inference_packages/"
dir<-sprintf("%s/%s",dir1,dir2)
pack<-"cardUtils"
package<-sprintf("%s/%s",dir,pack)
l<-retrieveExamplesFromMan(package)
## End(Not run)
retrieveMan
Description
retrieve the names of all man files
Usage
retrieveMan(package)
Arguments
package |
character string full pathname for the package folder |
Value
returns a list of the names of all man files
Examples
## Not run:
# replace package with your own version!!
dir1<-"~/personal/hearts/hearts_card_game_bayesian_inference/packages/"
dir2<-"inference_packages/inference_packages/"
dir<-sprintf("%s/%s",dir1,dir2)
pack<-"cardUtils"
package<-sprintf("%s/%s",dir,pack)
l<-retrieveMan(package)
## End(Not run)
startExample
Description
parse the output file produced by RunExamples() to determine the next example to start the list provided to run_examples()
Usage
startExample(f, xnames)
Arguments
f |
character string containing the path name of the run_examples() results output file |
xnames |
list of all the function names within the package |
Value
returns a list whose components are
Examples
## Not run:
# replace dir and pack with your own versions!!
# run this example within the RStudio Console for the package 'pack'
dir1<-"~/personal/hearts/hearts_card_game_bayesian_inference/packages/"
dir2<-"inference_packages/inference_packages/"
dir<-sprintf("%s/%s",dir1,dir2)
load_all()
pack<-sprintf("%s/%s",dir,"cardUtils")
out<-sprintf("%s/%s",tempdir(),"runExamplesOut.txt")
l<-retrieveExamplesFromMan(pack)
xnames<-unlist(strsplit(sort(names(l$x)),".Rd"))
sink(out)
on.exit(sink())
suppressMessages(suppressWarnings(try(run_examples(pack))))
sink()
l1<-startExample(out,xnames)
## End(Not run)