From 397783183911ca459e2f08562e970fc0d309e4b6 Mon Sep 17 00:00:00 2001 From: John Benninghoff Date: Mon, 27 Nov 2023 18:47:39 -0600 Subject: [PATCH 1/6] Bump version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 70b9d476..cc685e8b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: rdev Title: R Development Tools -Version: 1.8.5 +Version: 1.8.5.9000 Authors@R: person("John", "Benninghoff", , "jbenninghoff@mac.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6230-4742")) From 51569dfee8e4957dad27ff310e7d4c9f7864e7a0 Mon Sep 17 00:00:00 2001 From: John Benninghoff Date: Mon, 27 Nov 2023 22:26:05 -0600 Subject: [PATCH 2/6] Update TODO --- TODO.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TODO.md b/TODO.md index d5837108..0523bbfc 100644 --- a/TODO.md +++ b/TODO.md @@ -5,6 +5,7 @@ - [x] Add README.Rmd - [x] Update `DESCRIPTION` and use description data in `README.Rmd` - [x] Add ORCID +- [ ] Update my ORCID details ## Package @@ -49,6 +50,9 @@ - [x] ~~Remove `pkgdown/extra.css` if is accepted~~ - [ ] Remove `preset: bootstrap` if is accepted - [ ] Replace `dev = TRUE` logic if is accepted +- [ ] Consider using RStudio [Extensions](https://rstudio.github.io/rstudio-extensions/index.html): + - [ ] Use Project [Templates](https://rstudio.github.io/rstudio-extensions/rstudio_project_templates.html) like [vertical](https://www.crumplab.com/vertical/) ? + - [ ] Add CSS to R Markdown [Template](https://rstudio.github.io/rstudio-extensions/rmarkdown_templates.html) instead of `assets/extra.css` ? - [ ] Update errors and messages after reading Advanced R [Conditions](https://adv-r.hadley.nz/conditions.html) and re-reading the Tidyverse [Style Guide](https://style.tidyverse.org/index.html) - [ ] Establish default [knitr options](https://yihui.org/knitr/options/), including `knitr::opts_chunk$set(fig.align = "center"")`, add to analysis template, also review [settings](https://github.com/hadley/adv-r/blob/master/common.R) for *Advanced R* - [ ] Reduce the number of Imports, per R CMD check: From 06e77e5ce4ed5a7fa15e618313b4040caf9b6a9b Mon Sep 17 00:00:00 2001 From: John Benninghoff Date: Mon, 27 Nov 2023 22:48:07 -0600 Subject: [PATCH 3/6] Update covr exclusions --- R/urlchecker.R | 4 ++-- R/utils.R | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/R/urlchecker.R b/R/urlchecker.R index 215a5f8f..1f3410b5 100644 --- a/R/urlchecker.R +++ b/R/urlchecker.R @@ -17,12 +17,12 @@ url_check <- urlchecker::url_check # cli is not recorded in Imports. This function is a workaround to ensure use of cli is also # detected by renv. url_update_renv_workaround <- function(...) { - cli::cli_alert_success(...) + cli::cli_alert_success(...) # nocov } # NOTE: use of curl::new_pool() is considered a dependency by renv but not by R CMD check. curl_new_pool_renv_workaround <- function(...) { - curl::new_pool(...) + curl::new_pool(...) # nocov } #' @rdname urlchecker-reexports diff --git a/R/utils.R b/R/utils.R index c0b749ab..b516fa87 100644 --- a/R/utils.R +++ b/R/utils.R @@ -77,6 +77,7 @@ spell_check_notebooks <- function(path = "analysis", glob = "*.Rmd", use_wordlis #' @export update_wordlist_notebooks <- function(pkg = ".", vignettes = TRUE, path = "analysis", glob = "*.Rmd", confirm = TRUE) { + # nocov start as_package <- "spelling" %:::% "as_package" get_wordfile <- "spelling" %:::% "get_wordfile" get_wordlist <- spelling::get_wordlist @@ -94,6 +95,7 @@ update_wordlist_notebooks <- function(pkg = ".", vignettes = TRUE, path = "analy )), method = "radix" ) + # end change if (isTRUE(all.equal(old_words, new_words))) { cat(sprintf("No changes required to %s\n", wordfile)) } else { @@ -125,6 +127,7 @@ update_wordlist_notebooks <- function(pkg = ".", vignettes = TRUE, path = "analy "Added %d and removed %d words in %s\n", length(words_added), length(words_removed), wordfile )) } + # nocov end } deps_check <- function(type, exclude_base = TRUE) { From 02f7c52043d4bc0b43a455534915a8e4e244cbf7 Mon Sep 17 00:00:00 2001 From: John Benninghoff Date: Tue, 28 Nov 2023 12:13:46 -0600 Subject: [PATCH 4/6] Add checkmate assertions --- DESCRIPTION | 1 + NEWS.md | 4 +++ R/build.R | 1 + R/ci.R | 13 ++++++++++ R/helpers.R | 6 ++--- R/release.R | 9 +++++++ R/setup.R | 11 ++++++++ R/to_document.R | 6 +++++ R/utils.R | 16 +++++++++--- renv.lock | 12 +++++++++ tests/testthat/test-build.R | 13 ++++++++++ tests/testthat/test-ci.R | 36 ++++++++++++++++++++++++++ tests/testthat/test-helpers.R | 6 +++-- tests/testthat/test-release.R | 43 +++++++++++++++++++++++++++++-- tests/testthat/test-setup.R | 35 +++++++++++++++++++++++++ tests/testthat/test-to_document.R | 14 ++++++++++ tests/testthat/test-utils.R | 24 +++++++++++++++-- 17 files changed, 237 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index cc685e8b..7f2a115d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,6 +11,7 @@ URL: https://jabenninghoff.github.io/rdev/, https://github.com/jabenninghoff/rdev BugReports: https://github.com/jabenninghoff/rdev/issues Imports: + checkmate, cli, curl, desc, diff --git a/NEWS.md b/NEWS.md index 36bdd538..cebdce1c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# rdev 1.8.6 + +* Check function arguments with [checkmate](https://mllg.github.io/checkmate/index.html) + # rdev 1.8.5 * Changed `use_analysis_package()` to store `_freeze` directory in git per Quarto [guide](https://quarto.org/docs/projects/code-execution.html#using-freeze) diff --git a/R/build.R b/R/build.R index af10fc4f..ec65414c 100644 --- a/R/build.R +++ b/R/build.R @@ -59,6 +59,7 @@ unfreeze <- function() { #' #' @export build_quarto_site <- function(input = NULL, as_job = FALSE, unfreeze = FALSE, ...) { + checkmate::assert_flag(unfreeze) if (!fs::file_exists("README.Rmd")) { stop("README.Rmd does not exist") } diff --git a/R/ci.R b/R/ci.R index f7fa10f7..78c46908 100644 --- a/R/ci.R +++ b/R/ci.R @@ -12,6 +12,8 @@ #' } #' @export check_renv <- function(update = rlang::is_interactive()) { + checkmate::assert_flag(update) + writeLines("renv::status(dev = TRUE)") renv::status(dev = TRUE) @@ -117,6 +119,17 @@ ci <- function(renv = TRUE, # nolint: cyclocomp_linter. extra = TRUE, urls = TRUE, rcmdcheck = TRUE) { + checkmate::assert_flag(renv) + checkmate::assert_flag(missing) + checkmate::assert_flag(pkgdown) + checkmate::assert_flag(styler, null.ok = TRUE) + checkmate::assert_flag(lintr) + checkmate::assert_flag(document) + checkmate::assert_flag(normalize) + checkmate::assert_flag(extra) + checkmate::assert_flag(urls) + checkmate::assert_flag(rcmdcheck) + if (renv) { writeLines("renv::status(dev = TRUE)") status <- renv::status(dev = TRUE) diff --git a/R/helpers.R b/R/helpers.R index b03466c4..9bb1b8cd 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -26,9 +26,9 @@ #' } #' @export local_temppkg <- function(dir = fs::file_temp(), type = "usethis", env = parent.frame()) { - if (!(type %in% c("usethis", "rdev", "analysis", "quarto"))) { - stop("unrecognized package type, '", type, "'") - } + checkmate::assert_string(dir) + checkmate::assert_choice(type, c("usethis", "rdev", "analysis", "quarto")) + checkmate::assert_environment(env) # capture the current project - use try() since proj_get() will error within rcmdcheck() old_project <- NULL diff --git a/R/release.R b/R/release.R index a320721c..adfe2cf1 100644 --- a/R/release.R +++ b/R/release.R @@ -20,6 +20,10 @@ #' #' @export new_branch <- function(name, bump_ver = TRUE, current = FALSE) { + checkmate::assert_string(name) + checkmate::assert_flag(bump_ver) + checkmate::assert_flag(current) + if (gert::git_branch_exists(name, local = TRUE)) { stop("local branch exists") } @@ -66,6 +70,7 @@ get_release <- function(pkg = ".", filename = "NEWS.md") { if (pkg != ".") { stop('currently only get_release(pkg = ".") is supported') } + checkmate::assert_string(filename) pkg_obj <- devtools::as.package(pkg) header_regex <- paste0( @@ -134,6 +139,8 @@ stage_release <- function(pkg = ".", filename = "NEWS.md", host = getOption("rde if (pkg != ".") { stop('currently only stage_release(pkg = ".") is supported') } + checkmate::assert_string(filename) + checkmate::assert_string(host, null.ok = TRUE) rel <- get_release(pkg = pkg, filename = filename) @@ -236,6 +243,8 @@ merge_release <- function(pkg = ".", filename = "NEWS.md", host = getOption("rde if (pkg != ".") { stop('currently only merge_release(pkg = ".") is supported') } + checkmate::assert_string(filename) + checkmate::assert_string(host, null.ok = TRUE) rel <- get_release(pkg = pkg, filename = filename) pr_title <- paste0(rel$package, " ", rel$version) diff --git a/R/setup.R b/R/setup.R index eee801f2..5710124c 100644 --- a/R/setup.R +++ b/R/setup.R @@ -166,6 +166,8 @@ get_github_repo <- function() { #' @keywords internal #' @noRd fix_gitignore <- function(path = ".") { + checkmate::assert_string(path) + giti_path <- fs::path(path, ".gitignore") gitignore <- readLines(giti_path) gitignore <- gitignore[!grepl("^\\.Rproj\\.user$", gitignore)] @@ -203,6 +205,11 @@ fix_gitignore <- function(path = ".") { #' @export create_github_repo <- function(repo_name, repo_desc = "", org = NULL, host = getOption("rdev.host")) { + checkmate::assert_string(repo_name) + checkmate::assert_string(repo_desc) + checkmate::assert_string(org, null.ok = TRUE) + checkmate::assert_string(host, null.ok = TRUE) + conspicuous_place <- "usethis" %:::% "conspicuous_place" user_path_prep <- "usethis" %:::% "user_path_prep" @@ -343,6 +350,8 @@ get_server_url <- function() { #' #' @export use_rdev_package <- function(quiet = TRUE) { + checkmate::assert_flag(quiet) + rlang::local_interactive(value = !quiet) # add templates @@ -475,6 +484,8 @@ use_analysis_package <- function(use_quarto = TRUE, prompt = FALSE) { # workaround for lintr, R CMD check create <- gitignore <- rbuildignore <- NULL + checkmate::assert_flag(use_quarto) + analysis_layout <- tibble::tribble( ~pattern, ~create, ~gitignore, ~rbuildignore, "analysis", TRUE, FALSE, FALSE, diff --git a/R/to_document.R b/R/to_document.R index c44a38d2..f4fddbb1 100644 --- a/R/to_document.R +++ b/R/to_document.R @@ -17,6 +17,10 @@ #' } #' @export to_document <- function(file_path, new_path, overwrite = FALSE) { + checkmate::assert_string(file_path) + checkmate::assert_string(new_path) + checkmate::assert_flag(overwrite) + if (!(fs::path_ext(file_path) %in% c("Rmd", "rmd"))) { stop("'", file_path, "' is not an R Markdown (*.Rmd) file") } @@ -72,6 +76,8 @@ to_document <- function(file_path, new_path, overwrite = FALSE) { #' @return Named list containing analysis notebook title, URL, date, and description #' @export rmd_metadata <- function(file_path) { + checkmate::assert_string(file_path) + if (!(fs::path_ext(file_path) %in% c("Rmd", "rmd"))) { stop("'", file_path, "' is not an R Markdown (*.Rmd) file") } diff --git a/R/utils.R b/R/utils.R index b516fa87..c02749f4 100644 --- a/R/utils.R +++ b/R/utils.R @@ -20,6 +20,8 @@ #' } #' @export sort_file <- function(filename) { + checkmate::assert_string(filename) + if (!fs::file_exists(filename)) stop("cannot sort file, '", filename, "': no such file") writeLines(sort(readLines(filename)), filename) } @@ -47,6 +49,11 @@ sort_rbuildignore <- function() { #' @export spell_check_notebooks <- function(path = "analysis", glob = "*.Rmd", use_wordlist = TRUE, lang = NULL) { + checkmate::assert_string(path) + checkmate::assert_string(glob) + checkmate::assert_flag(use_wordlist) + checkmate::assert_string(lang, null.ok = TRUE) + if (is.null(lang)) { if (!fs::file_exists("DESCRIPTION")) { stop("DESCRIPTION not found") @@ -131,11 +138,10 @@ update_wordlist_notebooks <- function(pkg = ".", vignettes = TRUE, path = "analy } deps_check <- function(type, exclude_base = TRUE) { - base_packages <- rownames(utils::installed.packages(priority = "base")) + checkmate::assert_choice(type, c("missing", "extra")) + checkmate::assert_flag(exclude_base) - if (!(type %in% c("missing", "extra"))) { - stop("invalid type '", type, "'") - } + base_packages <- rownames(utils::installed.packages(priority = "base")) renv_deps <- renv::dependencies() renv_deps <- renv_deps[!endsWith(renv_deps$Source, "/DESCRIPTION"), ] renv_deps <- renv_deps[!renv_deps$Package == pkgload::pkg_name("."), ] @@ -179,6 +185,8 @@ deps_check <- function(type, exclude_base = TRUE) { #' @export #' @rdname deps_check missing_deps <- function(exclude_base = TRUE) { + checkmate::assert_flag(exclude_base) + deps_check("missing", exclude_base) } diff --git a/renv.lock b/renv.lock index eb89615c..05628f82 100644 --- a/renv.lock +++ b/renv.lock @@ -190,6 +190,18 @@ ], "Hash": "9b2191ede20fa29828139b9900922e51" }, + "checkmate": { + "Package": "checkmate", + "Version": "2.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "backports", + "utils" + ], + "Hash": "ed4275b13c6ab74b89a31def0b6bf835" + }, "cli": { "Package": "cli", "Version": "3.6.1", diff --git a/tests/testthat/test-build.R b/tests/testthat/test-build.R index 30dd26cf..b4144000 100644 --- a/tests/testthat/test-build.R +++ b/tests/testthat/test-build.R @@ -40,6 +40,19 @@ test_that("unfreeze errors when components are missing", { # build_quarto_site +test_that("build_quarto_site validates arguments", { + mockery::stub(build_quarto_site, "devtools::build_readme", NULL) + mockery::stub(build_quarto_site, "unfreeze", NULL) + mockery::stub(build_quarto_site, "quarto::quarto_render", NULL) + withr::local_dir(withr::local_tempdir()) + fs::file_create("README.Rmd") + fs::dir_create("analysis") + fs::file_create("analysis/test.Rmd") + fs::file_create("_quarto.yml") + + expect_error(build_quarto_site(unfreeze = NA), "'unfreeze'") +}) + test_that("build_quarto_site errors when components are missing", { withr::local_dir(withr::local_tempdir()) diff --git a/tests/testthat/test-ci.R b/tests/testthat/test-ci.R index 7c06379c..43a19dec 100644 --- a/tests/testthat/test-ci.R +++ b/tests/testthat/test-ci.R @@ -2,6 +2,14 @@ withr::local_dir("test-ci") # check_renv +test_that("check_renv validates arguments", { + mockery::stub(check_renv, "renv::status", NULL) + mockery::stub(check_renv, "renv::clean", NULL) + mockery::stub(check_renv, "renv::update", NULL) + + expect_error(check_renv(update = NA), "'update'") +}) + test_that("All renv functions are called, unless set to FALSE", { mockery::stub(check_renv, "renv::status", NULL) mockery::stub(check_renv, "renv::clean", NULL) @@ -38,6 +46,34 @@ test_that("lint_all checks all file types", { # ci +test_that("ci validates arguments", { + mockery::stub(ci, "renv::status", NULL) + mockery::stub(ci, "missing_deps", NULL) + mockery::stub(ci, "fs::file_exists", NULL) + mockery::stub(ci, "pkgdown::check_pkgdown", NULL) + mockery::stub(ci, "style_all", NULL) + mockery::stub(ci, "lint_all", NULL) + mockery::stub(ci, "gert::git_status", NULL) + mockery::stub(ci, "devtools::document", NULL) + mockery::stub(ci, "desc::desc_normalize", NULL) + mockery::stub(ci, "print_tbl", NULL) + mockery::stub(ci, "extra_deps", NULL) + mockery::stub(ci, "url_check", NULL) + mockery::stub(ci, "html_url_check", NULL) + mockery::stub(ci, "rcmdcheck::rcmdcheck", NULL) + + expect_error(ci(renv = NA), "'renv'") + expect_error(ci(missing = NA), "'missing'") + expect_error(ci(pkgdown = NA), "'pkgdown'") + expect_error(ci(styler = NA), "'styler'") + expect_error(ci(lintr = NA), "'lintr'") + expect_error(ci(document = NA), "'document'") + expect_error(ci(normalize = NA), "'normalize'") + expect_error(ci(extra = NA), "'extra'") + expect_error(ci(urls = NA), "'urls'") + expect_error(ci(rcmdcheck = NA), "'rcmdcheck'") +}) + test_that("All renv functions are called according to ci logic", { renv_sync_true <- list(library = list(), lockfile = list(), synchronized = TRUE) renv_sync_false <- list(library = list(), lockfile = list(), synchronized = FALSE) diff --git a/tests/testthat/test-helpers.R b/tests/testthat/test-helpers.R index 4ec5685f..c0e9de9d 100644 --- a/tests/testthat/test-helpers.R +++ b/tests/testthat/test-helpers.R @@ -1,7 +1,9 @@ # local_temppkg -test_that("local_temppkg errors with an invalid package type", { - expect_error(local_temppkg(type = "badtype"), "^unrecognized package type, 'badtype'$") +test_that("local_temppkg validates arguments", { + expect_error(local_temppkg(dir = NA_character_), "'dir") + expect_error(local_temppkg(type = "badtype"), "'type'") + expect_error(local_temppkg(env = NA), "'env'") }) test_that("local_temppkg creates a valid usethis package", { diff --git a/tests/testthat/test-release.R b/tests/testthat/test-release.R index af52e00a..85adf711 100644 --- a/tests/testthat/test-release.R +++ b/tests/testthat/test-release.R @@ -20,6 +20,24 @@ dev_ver <- structure(list(c(1L, 0L, 0L, 9000L)), class = c( "numeric_version" )) +test_that("new_branch validates arguments", { + mockery::stub(new_branch, "gert::git_branch_exists", NULL) + mockery::stub(new_branch, "gert::git_branch_checkout", NULL) + mockery::stub(new_branch, "usethis::git_default_branch", NULL) + mockery::stub(new_branch, "gert::git_branch_create", NULL) + mockery::stub(new_branch, "desc::desc_get_version", NULL) + mockery::stub(new_branch, "desc::desc_bump_version", NULL) + mockery::stub(new_branch, "gert::git_add", NULL) + mockery::stub(new_branch, "gert::git_commit", NULL) + mockery::stub(new_branch, "gert::git_status", NULL) + mockery::stub(new_branch, "gert::git_stash_save", NULL) + mockery::stub(new_branch, "gert::git_stash_pop", NULL) + + expect_error(new_branch(name = NA_character_), "'name'") + expect_error(new_branch("test", bump_ver = NA), "'bump_ver'") + expect_error(new_branch("test", current = NA), "'current'") +}) + test_that("new_branch errors when local or remote branch exists", { g <- function(name, local = TRUE) { if (name == "local" & local) { @@ -162,10 +180,11 @@ test_that("get_release returns correct package, version, and notes for first rel expect_identical(rel$notes, "Initial release.") }) -test_that('get_release stops when pkg != "."', { +test_that("get_release validates arguments", { expect_error( get_release(pkg = "tpkg"), '^currently only get_release\\(pkg = "\\."\\) is supported$' ) + expect_error(get_release(filename = NA_character_), "'filename'") }) test_that("get_release returns error on invalid NEWS.md format", { @@ -190,7 +209,7 @@ test_that("get_release returns valid but non-rdev version", { # stage_release -test_that('stage_release stops when pkg != "."', { +test_that("stage_release validates arguments", { # stub functions that change state mockery::stub(stage_release, "gert::git_branch_create", NULL) mockery::stub(stage_release, "desc::desc_set_version", NULL) @@ -204,6 +223,8 @@ test_that('stage_release stops when pkg != "."', { expect_error( stage_release(pkg = "tpkg"), '^currently only stage_release\\(pkg = "\\."\\) is supported$' ) + expect_error(stage_release(filename = NA_character_), "'filename'") + expect_error(stage_release(host = NA_character_), "'host'") }) test_that("stage_release returns error on non-rdev version", { @@ -496,3 +517,21 @@ test_that("merge_release errors when expected and returns list", { merge_release(pkg = "tpkg"), '^currently only merge_release\\(pkg = "\\."\\) is supported$' ) }) + +test_that("merge_release validates arguments", { + mockery::stub(merge_release, "get_release", NULL) + mockery::stub(merge_release, "gert::git_remote_info", NULL) + mockery::stub(merge_release, "remotes::parse_github_url", NULL) + mockery::stub(merge_release, "gh::gh", NULL) + mockery::stub(merge_release, "gert::git_branch_checkout", NULL) + mockery::stub(merge_release, "gert::git_branch_delete", NULL) + mockery::stub(merge_release, "gert::git_pull", NULL) + mockery::stub(merge_release, "gert::git_tag_create", NULL) + mockery::stub(merge_release, "gert::git_tag_push", NULL) + + expect_error( + merge_release(pkg = "tpkg"), '^currently only merge_release\\(pkg = "\\."\\) is supported$' + ) + expect_error(merge_release(filename = NA_character_), "'filename'") + expect_error(merge_release(host = NA_character_), "'host'") +}) diff --git a/tests/testthat/test-setup.R b/tests/testthat/test-setup.R index f75fdefe..33de941e 100644 --- a/tests/testthat/test-setup.R +++ b/tests/testthat/test-setup.R @@ -69,6 +69,12 @@ test_that("get_license validates options", { # fix_gitignore +test_that("fix_gitignore validates arguments", { + withr::local_dir(withr::local_tempdir()) + + expect_error(fix_gitignore(path = NA_character_), "'path'") +}) + test_that("fix_gitignore removes extra '.Rproj.user'", { withr::local_dir(withr::local_tempdir()) gitignore_tidy <- c( @@ -90,6 +96,20 @@ test_that("fix_gitignore removes extra '.Rproj.user'", { # create_github_repo +test_that("create_github_repo validates arguments", { + mockery::stub(create_github_repo, "fs::dir_exists", NULL) + mockery::stub(create_github_repo, "gh::gh", NULL) + mockery::stub(create_github_repo, "usethis::create_from_github", NULL) + mockery::stub(create_github_repo, "fs::file_delete", NULL) + mockery::stub(create_github_repo, "usethis::create_package", NULL) + mockery::stub(create_github_repo, "fix_gitignore", NULL) + + expect_error(create_github_repo(repo_name = NA_character_), "'repo_name'") + expect_error(create_github_repo("test", repo_desc = NA_character_), "'repo_desc'") + expect_error(create_github_repo("test", org = NA_character_), "'org'") + expect_error(create_github_repo("test", host = NA_character_), "'host'") +}) + test_that("create_github_repo errors when proposed repo directory exists locally", { mockery::stub(create_github_repo, "fs::dir_exists", TRUE) mockery::stub(create_github_repo, "gh::gh", NULL) @@ -209,8 +229,23 @@ test_that("get_server_url finds the correct server URL", { ) }) +# use_rdev_package + +test_that("use_rdev_package validates arguments", { + withr::local_dir(withr::local_tempdir()) + mockery::stub(use_rdev_package, "gh::gh", NULL) + + expect_error(use_rdev_package(quiet = NA), "'quiet'") +}) + # use_analysis_package +test_that("use_analysis_package validates arguments", { + withr::local_dir(withr::local_tempdir()) + + expect_error(use_analysis_package(use_quarto = NA), "'use_quarto'") +}) + test_that("use_analysis_package returns expected values", { values <- list( dirs = c( diff --git a/tests/testthat/test-to_document.R b/tests/testthat/test-to_document.R index 3c33a0a3..87f44e3e 100644 --- a/tests/testthat/test-to_document.R +++ b/tests/testthat/test-to_document.R @@ -2,6 +2,14 @@ withr::local_dir("test-to_document") # to_document +test_that("to_document validates arguments", { + expect_error(to_document(file_path = NA_character_, new_path = "new.Rmd"), "'file_path'") + expect_error(to_document(file_path = "old.Rmd", new_path = NA_character_), "'new_path'") + expect_error( + to_document(file_path = "old.Rmd", new_path = "new.Rmd", overwrite = NA), "'overwrite'" + ) +}) + test_that("to_document errors when file isn't a well-formed R markdown document", { dest <- fs::file_temp(pattern = "document", ext = "Rmd") withr::local_file(dest) @@ -126,6 +134,12 @@ test_that("to_document copies source file to a directory", { desc_urls <- c("https://example.github.io/package/", "https://github.com/example/package") +test_that("rmd_metadata validates arguments", { + mockery::stub(rmd_metadata, "desc::desc_get_urls", desc_urls) + + expect_error(rmd_metadata(NA_character_), "'file_path'") +}) + test_that("rmd_metadata errors when file isn't a well-formed R markdown document", { mockery::stub(rmd_metadata, "desc::desc_get_urls", desc_urls) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 45850832..4c69baeb 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -1,5 +1,9 @@ # sort_file +test_that("sort_file validates arguments", { + expect_error(sort_file(NA_character_), "'filename'") +}) + test_that("sort_file errors when file does not exist", { expect_error(sort_file("nonexistant"), "^cannot sort file, 'nonexistant': no such file$") }) @@ -33,6 +37,15 @@ test_that("sort_rbuildignore sorts .Rbuildignore", { # spell_check_notebooks +test_that("spell_check_notebooks validates arguments", { + withr::local_dir(withr::local_tempdir()) + + expect_error(spell_check_notebooks(path = NA_character_), "'path'") + expect_error(spell_check_notebooks(glob = NA_character_), "'glob'") + expect_error(spell_check_notebooks(use_wordlist = NA), "'use_wordlist'") + expect_error(spell_check_notebooks(lang = NA_character_), "'lang'") +}) + test_that("spell_check_notebooks logic flows work", { withr::local_dir(withr::local_tempdir()) fs::dir_create("inst") @@ -65,11 +78,12 @@ test_that("spell_check_notebooks logic flows work", { # deps_check -test_that("deps_check errors on invalid type", { +test_that("deps_check validates arguments", { mockery::stub(deps_check, "renv::dependencies", NULL) mockery::stub(deps_check, "desc::desc_get_deps", NULL) - expect_error(deps_check("badtype"), "^invalid type 'badtype'$") + expect_error(deps_check("badtype"), "'badtype'") + expect_error(deps_check("missing", exclude_base = NA), "'exclude_base'") }) test_that("deps_check finds correct missing and extra deps", { @@ -156,6 +170,12 @@ test_that("deps_check finds correct missing and extra deps", { expect_identical(deps_check("missing", exclude_base = FALSE), missing_withbase) }) +test_that("missing_deps validates arguments", { + mockery::stub(missing_deps, "deps_check", NULL) + + expect_error(missing_deps(exclude_base = NA), "'exclude_base'") +}) + test_that("missing_deps and extra_deps call correct deps_check type", { dc <- function(type, exclude_base = TRUE) { type From d34b7d383ba22ec19864d9633557d83280bf586f Mon Sep 17 00:00:00 2001 From: John Benninghoff Date: Tue, 28 Nov 2023 12:21:55 -0600 Subject: [PATCH 5/6] GitHub release 1.8.6 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7f2a115d..294bf198 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: rdev Title: R Development Tools -Version: 1.8.5.9000 +Version: 1.8.6 Authors@R: person("John", "Benninghoff", , "jbenninghoff@mac.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6230-4742")) From e3ef3fe7eaf8a3ee789a787be9f80e4d9180b614 Mon Sep 17 00:00:00 2001 From: John Benninghoff Date: Tue, 28 Nov 2023 12:23:21 -0600 Subject: [PATCH 6/6] build_rdev_site() for release 1.8.6 --- README.md | 15 ++++++++------- docs/404.html | 2 +- docs/LICENSE-text.html | 2 +- docs/LICENSE.html | 2 +- docs/TODO.html | 8 +++++++- docs/articles/analysis-package-layout.html | 2 +- docs/articles/index.html | 2 +- docs/articles/rdev.html | 2 +- docs/articles/style-guide.html | 2 +- docs/authors.html | 6 +++--- docs/index.html | 17 +++++++++-------- docs/news/index.html | 7 ++++++- docs/pkgdown.yml | 2 +- docs/reference/build_analysis_site.html | 2 +- docs/reference/build_quarto_site.html | 2 +- docs/reference/build_rdev_site.html | 2 +- docs/reference/check_renv.html | 2 +- docs/reference/ci.html | 2 +- docs/reference/create_github_repo.html | 2 +- docs/reference/deps_check.html | 2 +- docs/reference/get_license.html | 2 +- docs/reference/get_release.html | 2 +- docs/reference/html_url_check.html | 2 +- docs/reference/index.html | 2 +- docs/reference/init.html | 2 +- docs/reference/lint_all.html | 2 +- docs/reference/local_temppkg.html | 2 +- docs/reference/merge_release.html | 2 +- docs/reference/new_branch.html | 2 +- docs/reference/rdev-package.html | 2 +- docs/reference/rmd_metadata.html | 2 +- docs/reference/setup_analysis.html | 2 +- docs/reference/sort_file.html | 2 +- docs/reference/sort_rbuildignore.html | 2 +- docs/reference/spell_check_notebooks.html | 2 +- docs/reference/stage_release.html | 2 +- docs/reference/style_all.html | 2 +- docs/reference/to_document.html | 2 +- docs/reference/unfreeze.html | 2 +- docs/reference/update_wordlist_notebooks.html | 2 +- docs/reference/urlchecker-reexports.html | 2 +- docs/reference/use_analysis_package.html | 2 +- docs/reference/use_codecov.html | 2 +- docs/reference/use_lintr.html | 2 +- docs/reference/use_package_r.html | 2 +- docs/reference/use_rdev_package.html | 2 +- docs/reference/use_rdev_pkgdown.html | 2 +- docs/reference/use_rprofile.html | 2 +- docs/reference/use_spelling.html | 2 +- docs/reference/use_todo.html | 2 +- docs/search.json | 2 +- 51 files changed, 79 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index 6c17d223..d4695672 100644 --- a/README.md +++ b/README.md @@ -224,20 +224,20 @@ ci() #> * creating vignettes ... OK #> * checking for LF line-endings in source and make files and shell scripts #> * checking for empty or unneeded directories -#> * building ‘rdev_1.8.5.tar.gz’ +#> * building ‘rdev_1.8.6.tar.gz’ #> #> ── R CMD check ───────────────────────────────────────────────────────────────── -#> * using log directory ‘/private/var/folders/vn/cw5f9gws42v9m8mdsds_zbl00000gp/T/RtmpM8E6ri/filea8035355982a/rdev.Rcheck’ +#> * using log directory ‘/private/var/folders/vn/cw5f9gws42v9m8mdsds_zbl00000gp/T/RtmpC5kZVh/file180267d97952d/rdev.Rcheck’ #> * using R version 4.3.2 (2023-10-31) -#> * using platform: x86_64-apple-darwin20 (64-bit) +#> * using platform: aarch64-apple-darwin20 (64-bit) #> * R was compiled by #> Apple clang version 14.0.0 (clang-1400.0.29.202) #> GNU Fortran (GCC) 12.2.0 -#> * running under: macOS Monterey 12.7.1 +#> * running under: macOS Ventura 13.6.2 #> * using session charset: UTF-8 #> * using option ‘--no-manual’ #> * checking for file ‘rdev/DESCRIPTION’ ... OK -#> * this is package ‘rdev’ version ‘1.8.5’ +#> * this is package ‘rdev’ version ‘1.8.6’ #> * package encoding: UTF-8 #> * checking package namespace information ... OK #> * checking package dependencies ... OK @@ -295,9 +295,10 @@ ci() #> NONE #> * checking re-building of vignette outputs ... OK #> * DONE +#> #> Status: OK -#> ── R CMD check results ───────────────────────────────────────── rdev 1.8.5 ──── -#> Duration: 1m 1.2s +#> ── R CMD check results ───────────────────────────────────────── rdev 1.8.6 ──── +#> Duration: 31s #> #> 0 errors ✔ | 0 warnings ✔ | 0 notes ✔ ``` diff --git a/docs/404.html b/docs/404.html index e1b37827..9d7169e7 100644 --- a/docs/404.html +++ b/docs/404.html @@ -25,7 +25,7 @@ rdev - 1.8.5 + 1.8.6