You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a package at the minute where functions have a sex argument, specified either by an upper case "M" or upper-case "F". When running autotest on this package, it treats the sex argument as logical, even though sex only accepts character input in the roxygen examples. This causes expect_autotest_no_err(autotest_package()) to fail, when it would otherwise pass.
I'll demonstrate the issue with some simple functions. These functions take two input strings, and paste0() them together. The only difference between them is in the roxygen @examples sections:
#' Check autotest for GitHub issue ("A"/"B")#' @param arg_1 Single-length character vector.#' @param arg_2 Single-length character vector.#' @examples#' # Try with "T"#' foo(arg_1 = "A", arg_2 = "B")#' @exportfoo<-function(arg_1, arg_2) {
checkmate::qassert(arg_1, "S1")
checkmate::qassert(arg_2, "S1")
paste0(arg_1, arg_2)
}
#' Check autotest for GitHub issue ("M")#' @param arg_1 Single-length character vector.#' @param arg_2 Single-length character vector.#' @examples#' # Try with "T"#' bar(arg_1 = "A", arg_2 = "T")#' @exportbar<-function(arg_1, arg_2) {
checkmate::qassert(arg_1, "S1")
checkmate::qassert(arg_2, "S1")
paste0(arg_1, arg_2)
}
#' Check autotest for GitHub issue ("F")#' @param arg_1 Single-length character vector.#' @param arg_2 Single-length character vector.#' @examples#' # Try with "F"#' qux(arg_1 = "F", arg_2 = "B")#' @exportqux<-function(arg_1, arg_2) {
checkmate::qassert(arg_1, "S1")
checkmate::qassert(arg_2, "S1")
paste0(arg_1, arg_2)
}
After using devtools::document() and devtools::load_all() to make them available to autotest, running autotest::examples_to_yaml(package = ".", c("foo", "bar", "qux")) makes the following output:
When I autotest these functions, the resulting output has errors for bar() and qux(), but not foo(). These errors specifically come from trying to treat arg_2 in bar() and arg_1 in qux() as single logical values, instead of as single strings.
autotest::autotest_package(functions= c("foo", "bar", "qux"), test=TRUE)
# A tibble: 25 x 9typetest_namefn_nameparameterparameter_typeoperationcontenttestyaml_hash<chr><chr><chr><chr><chr><chr><chr><lgl><chr>1errorNAbarNANAnormalf~":quot~ TRUE b3a1d9a3~ 2 error negate_l~ bar arg_2 single logical Negate d~ ":quot~TRUEb3a1d9a3~3errornegate_l~bararg_2singlelogicalNegated~":quot~ TRUE b3a1d9a3~ 4 error return_s~ bar (return ~ (return objec~ error fr~ "Asser~TRUEb3a1d9a3~5errorNAquxNANAnormalf~":quot~ TRUE fffd053f~ 6 error negate_l~ qux arg_1 single logical Negate d~ ":quot~TRUEfffd053f~7errornegate_l~quxarg_1singlelogicalNegated~":quot~ TRUE fffd053f~ 8 error return_s~ qux (return ~ (return objec~ error fr~ "Asser~TRUEfffd053f~9diagnosticsingle_c~bararg_1singlecharac~lower-ca~"is ca~ TRUE b3a1d9a3~10 diagnostic single_c~ bar arg_1 single charac~ upper-ca~ "isca~TRUEb3a1d9a3~# i 15 more rows# i Use `print(n = ...)` to see more rows
My guess is that autotest is parsing the upper-case "F" and "T" arguments as the F/T symbols for FALSE/TRUE, and mutating them accordingly. This is making autotest fail where it shouldn't.
I'm working on a package at the minute where functions have a
sex
argument, specified either by an upper case"M"
or upper-case"F"
. When runningautotest
on this package, it treats thesex
argument as logical, even thoughsex
only accepts character input in the roxygen examples. This causesexpect_autotest_no_err(autotest_package())
to fail, when it would otherwise pass.I'll demonstrate the issue with some simple functions. These functions take two input strings, and
paste0()
them together. The only difference between them is in the roxygen@examples
sections:After using
devtools::document()
anddevtools::load_all()
to make them available toautotest
, runningautotest::examples_to_yaml(package = ".", c("foo", "bar", "qux"))
makes the following output:When I
autotest
these functions, the resulting output has errors forbar()
andqux()
, but notfoo()
. These errors specifically come from trying to treatarg_2
inbar()
andarg_1
inqux()
as single logical values, instead of as single strings.My guess is that
autotest
is parsing the upper-case"F"
and"T"
arguments as theF
/T
symbols forFALSE
/TRUE
, and mutating them accordingly. This is making autotest fail where it shouldn't.sessionInfo()
Click for details
The text was updated successfully, but these errors were encountered: