Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
6bf4c5c
fix parseFunctionNames() parsing only the first function name.
Jun 24, 2016
5a99c80
improve parseFunctionNames logic flow
Jul 7, 2016
43b6ea9
style fix
Jul 12, 2016
e6e68ec
remove duplicated test cases
Jul 18, 2016
7e4d383
update documentation
Jul 18, 2016
a898733
update documentation
Jul 18, 2016
a396b05
add "unlist" to blacklist since its causing failures
Jul 18, 2016
a1bc23a
one test per file NOT wrapped in function
Jul 18, 2016
6a457a8
correct parsing during test case generation
Jul 18, 2016
2141dcd
use identicalTo with 1e-6 tolerance instead of equalTo
Jul 19, 2016
c0829d0
output complex numbers with high precision using hexNumeric
Jul 26, 2016
773647f
save attributes expected values
Jul 26, 2016
db44a4c
keepInteger so integers are not converted to doubles during parsing/i…
Jul 27, 2016
efe501c
add functions for automated test case generation
Aug 25, 2016
6f7f3dd
update package namespace/description
Aug 25, 2016
3761931
add doc
Aug 25, 2016
bcb9ea1
fix issue #1
Aug 25, 2016
08b626b
fix syntax (issue #2)
Aug 25, 2016
5500a7b
fix processing generated test cases (issue #4)
Aug 25, 2016
7cbc8b9
remove decorate from namespace (issue #3)
Aug 25, 2016
9091b09
code clean up
Aug 25, 2016
b36dfbb
remove stringr from imports (issue #6)
Aug 25, 2016
1c71160
added test case (issue #4)
Aug 25, 2016
627b525
fix digest namespace import
Aug 25, 2016
3c60ea8
fix find_packages_using_function() output + test case (issue #1)
Aug 25, 2016
5b55dea
fix digest call
Aug 25, 2016
152692a
fix test cases
Aug 25, 2016
ec70417
fix devtools:check() warnings/errs
Aug 25, 2016
60bc9ca
fix build icon
Aug 25, 2016
3b186c7
exclude dontrun{} codes in examples and fix function signatures (issu…
Aug 25, 2016
d1f4749
code clean up
Aug 25, 2016
65fe8dd
'No run' should be 'Not run'
Aug 25, 2016
601bcce
remove "file.show(" lines from extracted example codes
Aug 25, 2016
826a2f4
code style
Aug 26, 2016
50aa609
reuse code for extract/run example/testcase/vignet
Aug 26, 2016
49cfaf9
start fix (issue #5)
Aug 26, 2016
5ed5bc4
syntax
Aug 26, 2016
03ef09c
documentation
Aug 26, 2016
69e4b46
fix location generated test cases
Aug 28, 2016
a52b6d8
Do not remove failing test cases. Keep them for subsequent debugging.
akbertram Jan 12, 2017
1432dad
Fixes for broken test-generation tool
akbertram Jan 12, 2017
765c7db
Fixed typo in validate_tests()
akbertram Jan 12, 2017
f61a346
Fixes for validate_tests()
akbertram Jan 12, 2017
ffb80be
Recursively search for tests for validation
akbertram Jan 12, 2017
60456bb
Tightened-up R script regex
akbertram Jan 12, 2017
44a7a3f
Fixed FUNCTIONS environment variable parsing
akbertram Jan 12, 2017
cea3b89
Fixed FUNCTIONS environment handling
akbertram Jan 12, 2017
2be5f3c
Fixed handling of bigger list of functions
akbertram Jan 12, 2017
1b9246f
Added more status information during validation run
akbertram Jan 12, 2017
7c09b7d
Improved status output of script running
akbertram Jan 12, 2017
1c2aba8
Add timeouts to package examples, tests
akbertram Jan 15, 2017
b708ef6
Increased timeouts
akbertram Jan 15, 2017
ad34dc2
Added validation cache
akbertram Jan 15, 2017
d2724c9
Set seperate capture.folder for each package
akbertram Jan 15, 2017
4e0ba4a
Reverted attempt to set capture directory
akbertram Jan 15, 2017
789a14d
Added size limit and timeout for test validation
akbertram Jan 16, 2017
9a54982
Ensure even throughly hung scripts are eventually killed
akbertram Jan 17, 2017
1f6ec3a
Skip existing package dirs to allow resuming an aborted job
akbertram Jan 17, 2017
50b26b6
Extended limit for captured arguments to 10k
akbertram Jan 17, 2017
d9baf67
Fixed bug in argument capture routine.
akbertram Jan 17, 2017
f7f1b93
Increased total test case limit length to 20k
akbertram Jan 17, 2017
af8b127
Deparse function inputs with hex doubles as well as expected
akbertram Mar 29, 2017
6cdb396
in generate_test_cases add extra arg to limit the number of packages
Aug 31, 2017
5168753
add generate_test_cases_using() to use provided list of packages
Aug 31, 2017
ecb3690
update documentation and namespace
Aug 31, 2017
413bbe0
fix generate_test_cases_using()
Aug 31, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Package: testr
Type: Package
Title: What the Package Does (Title Case)
Version: 0.1.0
Author: Who wrote it
Maintainer: Who to complain to <yourfault@somewhere.net>
Title: R test case generator
Version: 0.1.3
Author: Github com allr
Maintainer: Parham Solaimani <parham@bedatadriven.com>
Description: Package aimed at generating testthat compatible tests.
License: GPL (>= 2)
Imports:
Expand All @@ -22,5 +22,5 @@ Suggests:
rmarkdown,
roxygen2
LazyData: TRUE
RoxygenNote: 5.0.1
RoxygenNote: 6.0.1
VignetteBuilder: knitr
7 changes: 6 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Generated by roxygen2: do not edit by hand

export(clear_decoration)
export(decorate)
export(gen_from_code)
export(gen_from_function)
export(gen_from_package)
export(gen_from_source)
export(generate)
export(generate_test_cases)
export(generate_test_cases_using)
export(get_tests)
export(prune)
export(setup_capture)
export(start_capture)
Expand All @@ -16,5 +18,8 @@ export(stop_capture_all)
export(testr_options)
export(undecorate)
export(write_capture)
export(write_captured_tests)
import(devtools)
import(methods)
importFrom(Rcpp,evalCpp)
useDynLib(testr)
2 changes: 1 addition & 1 deletion R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was generated by Rcpp::compileAttributes
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

WriteCapInfo_cpp <- function(fname, args_env) {
Expand Down
55 changes: 32 additions & 23 deletions R/capture.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#' @title Decorates function to capture calls and return values
#' Decorates function to capture calls and return values
#'
#' @description This function is respinsible for writing down capture information for decorated function calls.
#' Replaces the function by decorated function in the global environment
#' @param func function name as a character string
#' @param package name of package to look for function
#' @param verbose if to print additional output
#' @export
#' @seealso write_capture
#'
decorate <- function(func, package, verbose) {
decorate <- function(func, package, verbose)
{
if (identical(class(library), "function") && getRversion() < '3.3.0') {
suppressMessages(trace(library,
exit=quote(if (!missing(package)) testr:::refresh_decoration(package)),
exit = quote(if (!missing(package)) testr:::refresh_decoration(package)),
print = FALSE))
}
if (!cache$trace_replaced && getRversion() < '3.3.0') {
Expand All @@ -32,46 +32,51 @@ decorate <- function(func, package, verbose) {
return(invisible())
}
}
if (package != ".GlobalEnv")
if (package != ".GlobalEnv") {
package <- substr(package, 9, nchar(package))
else
} else {
package <- NA
}
}
if (is.na(package))
if (is.na(package)) {
isS3 <- is_s3_generic(func)
else
} else {
isS3 <- is_s3_generic(func, getNamespace(package))
}
if (isS3) {
warning("Not decorating S3 generic")
return(invisible())
}
write.call <- call("write_capture", if (is.na(package)) func else paste(package, func, sep=":::"), quote(sys.frame(-4))) #nolint
write.call <- call("write_capture", if (is.na(package)) func else paste(package, func, sep = ":::"), quote(sys.frame(-4))) #nolint
write.call[[1]] <- testr::write_capture
tc <- call("trace",
func,
quote(write.call),
print = testr_options("verbose"))
hidden <- FALSE
if (!func %in% ls(as.environment(if (is.na(package)) .GlobalEnv else paste("package", package, sep=":")))) {
tc[["where"]] <- call("getNamespace", package)
if (!func %in% ls(as.environment(if (is.na(package)) .GlobalEnv else paste("package", package, sep = ":")))) {
if (!is.na(package))
tc[["where"]] <- call("getNamespace", package)
hidden <- TRUE
}
if (verbose) {
eval(tc)
} else {
suppressMessages(eval(tc))
}
.decorated[[func]] <- list(func=func, package=package, hidden=hidden)
.decorated[[func]] <- list(func = func, package = package, hidden = hidden)
}

#' @title undecorate function
#' undecorate function
#'
#' @description Reset previously decorate function
#' @param func function name as a character string
#' @param verbose if to print additional output
#' @export
#' @seealso write_capture Decorate
#'
undecorate <- function(func, verbose) {
undecorate <- function(func, verbose)
{
if (class(func) == "character"){
fname <- func
} else {
Expand All @@ -91,10 +96,10 @@ undecorate <- function(func, verbose) {
} else {
suppressMessages(do.call(untrace, params))
}
rm(list=c(func), envir=.decorated)
rm(list = c(func), envir = .decorated)
}

#' @title Write down capture information
#' Write down capture information
#'
#' @description This function is respinsible for writing down capture information for decorated function calls.
#' @param fname function name
Expand All @@ -104,13 +109,14 @@ undecorate <- function(func, verbose) {
#' @importFrom Rcpp evalCpp
#' @export
#'
write_capture <- function(fname, args.env){
write_capture <- function(fname, args.env)
{
if (!testr_options("capture.arguments"))
return(NULL)
.Call("testr_WriteCapInfo_cpp", PACKAGE = "testr", fname, args.env)
}

#' @title Setup information capturing for list of function
#' Setup information capturing for list of function
#'
#' @description This function is respinsible for setting up capturing for functions
#'
Expand All @@ -119,7 +125,8 @@ write_capture <- function(fname, args.env){
#' @param verbose if to print additional status information
#' @seealso Decorate
#' @export
setup_capture <- function(flist, package, verbose = testr_options("verbose")) {
setup_capture <- function(flist, package, verbose = testr_options("verbose"))
{
old <- testr_options("capture.arguments")
if (old)
testr_options("capture.arguments", FALSE)
Expand All @@ -131,14 +138,15 @@ setup_capture <- function(flist, package, verbose = testr_options("verbose")) {
testr_options("capture.arguments", TRUE)
}

#' @title Check if function is eligible for wrapping to capture arguments and return values
#' Check if function is eligible for wrapping to capture arguments and return values
#'
#' @description This function checks that supplied function for capture is not a keyword, operator or in the blacklist (functions like rm, .GlobalEnv, etc.)
#' This is an internal function and is supposed to be used in setup_capture
#' @param func function name to check
#' @return TRUE/FALSE if can be captured or not
#' @seealso setup_capture
eligible_capture <- function(func){
eligible_capture <- function(func)
{
return (!length(utils::getAnywhere(func)$objs) == 0
&& class(utils::getAnywhere(func)[1]) == "function"
&& !func %in% blacklist
Expand All @@ -150,13 +158,14 @@ eligible_capture <- function(func){
}


#' @title Clear decoration
#' Clear decoration
#'
#' @description Clear anything previously decorate
#' @param verbose if to print additional debugging information. Default \code{TRUE}.
#' @seealso undecorate
#' @export
clear_decoration <- function(verbose) {
clear_decoration <- function(verbose)
{
for (fname in ls(.decorated, all.names = TRUE))
undecorate(fname, verbose = verbose)
}
Loading