8000 `cpp_register(quiet=)` set to TRUE on non-interactive session (incl testthat runs) by romainfrancois · Pull Request #289 · r-lib/cpp11 · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Config/Needs/cpp11/cpp_register:
vctrs
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
RoxygenNote: 7.2.1
SystemRequirements: C++11
Remotes:
r-lib/testthat@ad8b726d1734c59ed08ec7d11df4a3d76d8e69df
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

* `cpp_source()` errors on non-existent file (#261).

* `cpp_register()` is quiet by default when R is non interactive (#289).

* updated test to adapt to changes in R 4.2.1 (#290).

# cpp11 0.4.2
Expand Down
4 changes: 2 additions & 2 deletions R/register.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#'
#' # cleanup
#' unlink(dir, recursive = TRUE)
cpp_register <- function(path = ".", quiet = FALSE) {
cpp_register <- function(path = ".", quiet = !is_interactive()) {
stop_unless_installed(get_cpp_register_needs())

r_path <- file.path(path, "R", "cpp11.R")
Expand Down Expand Up @@ -138,7 +138,7 @@ cpp_register <- function(path = ".", quiet = FALSE) {

utils::globalVariables(c("name", "return_type", "line", "decoration", "context", ".", "functions", "res"))

get_registered_functions <- function(decorations, tag, quiet = FALSE) {
get_registered_functions <- function(decorations, tag, quiet = !is_interactive()) {
if (NROW(decorations) == 0) {
return(tibble::tibble(file = character(), line = integer(), decoration = character(), params = list(), context = list(), name = character(), return_type = character(), args = list()))
}
Expand Down
4 changes: 1 addition & 3 deletions R/source.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ cpp_source <- function(file, code = NULL, env = parent.frame(), clean = TRUE, qu
#provide original path for error messages
check_valid_attributes(all_decorations, file = orig_file_path)

cli_suppress(
funs <- get_registered_functions(all_decorations, "cpp11::register")
)
funs <- get_registered_functions(all_decorations, "cpp11::register", quiet = quiet)
cpp_functions_definitions <- generate_cpp_functions(funs, package = package)

cpp_path <- file.path(dirname(new_file_path), "cpp11.cpp")
Expand Down
9 changes: 0 additions & 9 deletions R/utils.R