From d10128f61b7370590c42356649980f633a120a63 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:28:02 +0200 Subject: [PATCH 1/5] add testthat helper state --- tests/testthat/helper-state.R | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/testthat/helper-state.R diff --git a/tests/testthat/helper-state.R b/tests/testthat/helper-state.R new file mode 100644 index 000000000..588923f31 --- /dev/null +++ b/tests/testthat/helper-state.R @@ -0,0 +1,13 @@ +testthat::set_state_inspector(function() { + list( + attached = search(), + connections = nrow(showConnections()), + cwd = getwd(), + envvars = Sys.getenv(), + libpaths = .libPaths(), + locale = Sys.getlocale(), + options = .Options, + packages = .packages(all.available = TRUE), + NULL + ) +}) From a4329440b29cbc9995447fb7afe0521e8ccd21e5 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Fri, 13 Oct 2023 19:59:48 +0200 Subject: [PATCH 2/5] just to trigger CI --- R/data_merge.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/R/data_merge.R b/R/data_merge.R index 58be12f8a..6badebada 100644 --- a/R/data_merge.R +++ b/R/data_merge.R @@ -221,10 +221,10 @@ data_merge.data.frame <- function(x, y, join = "left", by = NULL, id = NULL, ver missing_in_y <- setdiff(by, colnames(y)) stop_message <- c( "Not all columns specified in `by` were found in the data frames.", - if (length(missing_in_x) > 0) { + if (length(missing_in_x) > 0L) { paste0("Following columns are in `by` but absent in `x`: ", text_concatenate(missing_in_x)) }, - if (length(missing_in_y) > 0) { + if (length(missing_in_y) > 0L) { paste0("Following columns are in `by` but absent in `y`: ", text_concatenate(missing_in_y)) } ) @@ -264,10 +264,10 @@ data_merge.data.frame <- function(x, y, join = "left", by = NULL, id = NULL, ver # for later sorting if (join != "bind") { - if (nrow(x) > 0) { + if (nrow(x) > 0L) { x$.data_merge_id_x <- seq_len(nrow(x)) } - if (nrow(y) > 0) { + if (nrow(y) > 0L) { y$.data_merge_id_y <- (seq_len(nrow(y))) + nrow(x) } } @@ -364,10 +364,10 @@ data_merge.list <- function(x, join = "left", by = NULL, id = NULL, verbose = TR out <- rbind(x, y[match(colnames(x), colnames(y))]) } else { # add ID for merging - if (nrow(x) > 0) { + if (nrow(x) > 0L) { x$.data_merge_row <- seq_len(nrow(x)) } - if (nrow(y) > 0) { + if (nrow(y) > 0L) { y$.data_merge_row <- (nrow(x) + 1):(nrow(x) + nrow(y)) } by <- intersect(colnames(x), colnames(y)) From 617d857f383889eab1767c7817abf030d5e31d7b Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Fri, 13 Oct 2023 20:08:23 +0200 Subject: [PATCH 3/5] parallel testing causing issues? --- DESCRIPTION | 1 - 1 file changed, 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 55ed6b449..027c4d932 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -73,7 +73,6 @@ Language: en-US Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3.9000 Config/testthat/edition: 3 -Config/testthat/parallel: true Config/Needs/website: rstudio/bslib, r-lib/pkgdown, From 5e3375d4de23d39fba48f7239c53e9d6e2f1cc6d Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Fri, 13 Oct 2023 21:20:43 +0200 Subject: [PATCH 4/5] cleaner but fragile approach to test options --- tests/testthat/helper-state.R | 37 ++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/testthat/helper-state.R b/tests/testthat/helper-state.R index 588923f31..f4c714c8e 100644 --- a/tests/testthat/helper-state.R +++ b/tests/testthat/helper-state.R @@ -1,4 +1,39 @@ testthat::set_state_inspector(function() { + # sometimes a dependency might add a custom option, so we need to + # make sure we don't fail because of such additions + options <- options() + + # Result of `dput(names(options()))` + base_options <- c( + "add.smooth", "askpass", "asksecret", "bitmapType", "browser", + "browserNLdisabled", "buildtools.check", "buildtools.with", "callr.condition_handler_cli_message", + "CBoundsCheck", "check.bounds", "citation.bibtex.max", "connectionObserver", + "continue", "contrasts", "defaultPackages", "demo.ask", "deparse.cutoff", + "deparse.max.lines", "device", "device.ask.default", "digits", + "download.file.method", "dvipscmd", "echo", "editor", "encoding", + "example.ask", "expressions", "ggvis.renderer", "help_type", + "help.search.types", "help.try.all.packages", "HTTPUserAgent", + "install.packages.compile.from.source", "internet.info", "keep.parse.data", + "keep.parse.data.pkgs", "keep.source", "keep.source.pkgs", "locatorBell", + "mailer", "matprod", "max.contour.segments", "max.print", "menu.graphics", + "na.action", "nwarnings", "OutDec", "page_viewer", "pager", "papersize", + "PCRE_limit_recursion", "PCRE_study", "PCRE_use_JIT", "pdfviewer", + "pkgType", "plumber.docs.callback", "plumber.swagger.url", "printcmd", + "profvis.keep_output", "profvis.print", "profvis.prof_extension", + "profvis.prof_output", "prompt", "repos", "restart", "reticulate.initialized", + "reticulate.repl.busy", "reticulate.repl.hook", "reticulate.repl.initialize", + "reticulate.repl.teardown", "rl_word_breaks", "rsconnect.check.certificate", + "rstudio.notebook.executing", "RStudioGD.antialias", "RStudioGD.backend", + "scipen", "shiny.launch.browser", "shinygadgets.showdialog", + "show.coef.Pvalues", "show.error.messages", "show.signif.stars", + "showErrorCalls", "showNCalls", "showWarnCalls", "str", "str.dendrogram.last", + "terminal.manager", "texi2dvi", "timeout", "ts.eps", "ts.S.compat", + "unzip", "useFancyQuotes", "verbose", "viewer", "warn", "warning.length", + "warnPartialMatchArgs", "warnPartialMatchAttr", "warnPartialMatchDollar", + "width" + ) + options <- options[base_options] + list( attached = search(), connections = nrow(showConnections()), @@ -6,7 +41,7 @@ testthat::set_state_inspector(function() { envvars = Sys.getenv(), libpaths = .libPaths(), locale = Sys.getlocale(), - options = .Options, + options = options, packages = .packages(all.available = TRUE), NULL ) From e25a87b63a135b8e532d1b7717def840d78fde14 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sun, 26 May 2024 09:40:56 +0200 Subject: [PATCH 5/5] no longer needed --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index 8ae6ab2e6..ec594a4e7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -77,6 +77,7 @@ Language: en-US Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 Config/testthat/edition: 3 +Config/testthat/parallel: true Config/Needs/website: rstudio/bslib, r-lib/pkgdown,