diff --git a/.covrignore b/.covrignore index e18d9803c..1f7274455 100644 --- a/.covrignore +++ b/.covrignore @@ -1,3 +1,3 @@ R/deprec-*.R R/compat-*.R -R/usethis-defunct.R +R/usethis-deprecated.R diff --git a/DESCRIPTION b/DESCRIPTION index 1b915cec1..e779235bf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: usethis Title: Automate Package and Project Setup -Version: 2.2.3.9000 +Version: 3.0.0.9000 Authors@R: c( person("Hadley", "Wickham", , "hadley@posit.co", role = "aut", comment = c(ORCID = "0000-0003-4757-117X")), diff --git a/NAMESPACE b/NAMESPACE index 65d3ef186..0a1e4ae87 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,7 +14,6 @@ export(browse_github_issues) export(browse_github_pulls) export(browse_package) export(browse_project) -export(browse_travis) export(create_download_url) export(create_from_github) export(create_github_token) @@ -34,7 +33,6 @@ export(edit_rstudio_snippets) export(edit_template) export(gh_token_help) export(git_branch_default) -export(git_credentials) export(git_default_branch) export(git_default_branch_configure) export(git_default_branch_rediscover) @@ -87,8 +85,6 @@ export(use_agpl3_license) export(use_agpl_license) export(use_apache_license) export(use_apl2_license) -export(use_appveyor) -export(use_appveyor_badge) export(use_article) export(use_author) export(use_badge) @@ -121,7 +117,6 @@ export(use_devtools) export(use_directory) export(use_git) export(use_git_config) -export(use_git_credentials) export(use_git_hook) export(use_git_ignore) export(use_git_protocol) @@ -159,7 +154,6 @@ export(use_partial_warnings) export(use_pipe) export(use_pkgdown) export(use_pkgdown_github_pages) -export(use_pkgdown_travis) export(use_posit_cloud_badge) export(use_proprietary_license) export(use_r) @@ -180,9 +174,9 @@ export(use_spell_check) export(use_standalone) export(use_template) export(use_test) +export(use_test_helper) export(use_testthat) export(use_tibble) -export(use_tidy_ci) export(use_tidy_coc) export(use_tidy_contributing) export(use_tidy_dependencies) @@ -192,14 +186,11 @@ export(use_tidy_github) export(use_tidy_github_actions) export(use_tidy_github_labels) export(use_tidy_issue_template) -export(use_tidy_labels) export(use_tidy_logo) export(use_tidy_style) export(use_tidy_support) export(use_tidy_thanks) export(use_tidy_upkeep_issue) -export(use_travis) -export(use_travis_badge) export(use_tutorial) export(use_upkeep_issue) export(use_usethis) diff --git a/NEWS.md b/NEWS.md index 12dea1720..a698b8d7a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,19 +1,79 @@ # usethis (development version) -* `browse_github_token()`, `browse_github_pat()`, and `github_token()` have been removed after being deprecated in usethis 2.0.0. `create_github_token()`, `gh::gh_token()`, and `gh_token_help()` should be used instead. +# usethis 3.0.0 -* `pr_pull_upstream()` and `pr_sync()` have been removed after being deprecated in usethis 2.0.0. `pr_merge_main()` and `pr_push()` should be used instead. +## Transition to cli package for UI -* `pr_merge_main()` now offers the choice to not open the files with merge conflicts (@olivroy, #1720). +* The `ui_*()` functions have been marked as + [superseded](https://lifecycle.r-lib.org/articles/stages.html#superseded). + External users of these functions are encouraged to use the + [cli package](https://cli.r-lib.org/) instead. + The cli package did not have the required functionality when the + `usethis::ui_*()` functions were first created, but it does now and it's the + superior option. + There is a cli vignette about how to make this transition: + `vignette("usethis-ui", package = "cli")`. + usethis no longer uses the `ui_*()` functions internally, in favor of new + cli-based helpers that are not exported. + +## Deprecated function and argument removal + +We are removing functions and arguments that were deprecated as of usethis +v2.0.0, which was released in December 2020. + +These changes have been in place for a long time now: + +* Switch from git2r to gert (+ credentials). +* Use of git config and the gh package to infer, e.g., the target repo spec. +* Pivot towards GitHub Actions and away from Travis and AppVeyor. + +Functions that are removed and, where applicable, what to use instead: + +* `git_credentials()` +* `use_git_credentials()` +* `browse_github_token()` (do `create_github_token()`) +* `browse_github_pat()` (do `create_github_token()`) +* `github_token()` (do `gh_token_help()` or `gh::gh_token()`) +* `pr_pull_upstream()` (do `pr_merge_main()`) +* `pr_sync()` (do `pr_merge_main(); pr_push()`) +* `use_appveyor()` +* `use_appveyor_badge()` +* `use_travis()` +* `use_travis_badge()` +* `browse_travis()` +* `use_pkgdown_travis()` +* `use_tidy_ci()` *deprecated in v2.1.0* (do `use_tidy_github_actions()`) +* `use_tidy_labels()` *deprecated in v2.1.0* (do `use_tidy_github_labels()`) + +Function arguments that are removed: + +* `create_from_github(auth_token =, credentials =)` +* `use_github(auth_token =, credentials =)` +* `use_github_labels(repo_spec =, host =, auth_token =)` +* `use_github_links(auth_token =, host =)` +* `use_github_release(host =, auth_token =)` + +## Other changes + +* `use_zip()` and `use_course()` are equipped to handle a ZIP where the parent + folder is implicit (@burnsal, #1961). + +* `use_test_helper()` is a new function to create a test helper file + (@olivroy, #1822). + +* `use_cpp11()` makes it easier to update `NAMESPACE` (@pachadotdev, #1921). + +* `pr_merge_main()` now offers the choice to not open the files with merge + conflicts (@olivroy, #1720). * `edit_rstudio_snippets()` now accepts yaml snippets (@olivroy, #1941). * `use_standalone()` inserts an improved header that includes the code needed to update the standalone file (@krlmlr, #1903). -* `use_release_issue()` and `use_upkeep()` behave better when the user has a - fork. The user is asked just once to choose between `origin` and `upstream` as - the target repo (#2023). +* `use_release_issue()` and `use_upkeep_issue()` behave better when the user has + a fork. The user is asked just once to choose between `origin` and `upstream` + as the target repo (#2023). * The README templates now recommend [pak](https://pak.r-lib.org) instead of devtools for package installation (@olivroy, #1723). @@ -23,25 +83,13 @@ * `use_git()` no longer asks if you want to restart RStudio when using Positron. -* `use_test()` and `use_r()` now work when you are in `tests/testthat/_snaps/{foo}.md` (@olivroy, #1988). +* `use_test()` and `use_r()` now work when you are in + `tests/testthat/_snaps/{foo}.md` (@olivroy, #1988). * The URLs baked into the badge generated by `use_coverage(type = "codecov")` - no longer specify a branch (#2008). - -* The `ui_*()` functions have been marked as - [superseded](https://lifecycle.r-lib.org/articles/stages.html#superseded). - External users of these functions are encouraged to use the - [cli package](https://cli.r-lib.org/) instead. - The cli package did not have the required functionality when the - `usethis::ui_*()` functions were first created, but it does now and it's the - superior option. - There is a cli vignette about how to make this transition: - `vignette("usethis-ui", package = "cli")`. - - usethis no longer uses the `ui_*()` functions internally, in favor of new - cli-based helpers that are not exported. + are updated and no longer specify a branch(#2008). -* `usethis::use_version()` now tolerates empty / blank lines preceding the +* `usethis::use_version()` now tolerates empty lines preceding the first section title in the package NEWS file. (#1976) # usethis 2.2.3 @@ -206,14 +254,14 @@ * `use_tidy_logo()` is a new function that calls `use_logo()` on the appropriate hex sticker PNG file at (#1871). -## Defunct functions +## Deprecated functions -* `use_tidy_eval()` is now defunct because it imports and re-exports a large +* `use_tidy_eval()` is now deprecated because it imports and re-exports a large number of functions that are no longer needed in order to do tidy evaluation (#1656). * `use_travis()`, `use_pkgdown_travis()`, `browse_travis()`, and `use_appveyor()` - are now defunct because we no longer recommend Travis or Appveyor. We + are now deprecated because we no longer recommend Travis or Appveyor. We recommend GitHub actions instead (#1517). # usethis 2.1.6 @@ -531,7 +579,7 @@ GitHub Actions is the preferred platform for continuous integration, because tha `use_tidy_pkgdown()` implements the complete pkgdown configuration used by the tidyverse team (#224). -`pr_sync()` is defunct and can be replicated by calling `pr_pull()`, `pr_merge_main()`, then `pr_push()`. +`pr_sync()` is deprecated and can be replicated by calling `pr_pull()`, `pr_merge_main()`, then `pr_push()`. ## Licensing improvements @@ -1183,7 +1231,7 @@ build paths within it (#415, #425). * `create_from_github()`: the `repo` argument is renamed to `repo_spec`, since it takes input of the form "OWNER/REPO" (#376). -* `use_depsy_badge()` is defunct. The Depsy project has officially concluded and is no longer being maintained (#354). +* `use_depsy_badge()` is deprecated. The Depsy project has officially concluded and is no longer being maintained (#354). * `use_github()` fails earlier, with a more informative message, in the absence of a GitHub personal access token (PAT). Also looks for the PAT more proactively in the usual environment variables (i.e., GITHUB_PAT, GITHUB_TOKEN) (#320, #340, @cderv). diff --git a/R/badge.R b/R/badge.R index b97bf08d1..1427a207d 100644 --- a/R/badge.R +++ b/R/badge.R @@ -165,16 +165,6 @@ use_posit_cloud_badge <- function(url) { invisible(TRUE) } -#' @rdname badges -#' @export -use_rscloud_badge <- function(url) { - lifecycle::deprecate_warn( - "2.2.0", "use_rscloud_badge()", - "use_posit_cloud_badge()" - ) - use_posit_cloud_badge(url) -} - has_badge <- function(href) { readme_path <- proj_path("README.md") if (!file_exists(readme_path)) { diff --git a/R/browse.R b/R/browse.R index 726a97950..71888aeed 100644 --- a/R/browse.R +++ b/R/browse.R @@ -9,7 +9,6 @@ #' DESCRIPTION file is sought first in the local package library and then #' on CRAN. #' * Fixed templates: -#' - Travis CI: `https://travis-ci.{EXT}/{OWNER}/{PACKAGE}` #' - Circle CI: `https://circleci.com/gh/{OWNER}/{PACKAGE}` #' - CRAN landing page: `https://cran.r-project.org/package={PACKAGE}` #' - GitHub mirror of a CRAN package: `https://github.com/cran/{PACKAGE}` @@ -29,8 +28,6 @@ #' issue. #' * `browse_github_pulls()`: Visits the GitHub Pull Request index or one #' specific pull request. -#' * `browse_travis()`: Visits the project's page on -#' [Travis CI](https://www.travis-ci.com/). #' * `browse_circleci()`: Visits the project's page on #' [Circle CI](https://circleci.com). #' * `browse_cran()`: Visits the package on CRAN, via the canonical URL. diff --git a/R/course.R b/R/course.R index 772743717..ddfbb8cb3 100644 --- a/R/course.R +++ b/R/course.R @@ -11,13 +11,13 @@ #' @param url Link to a ZIP file containing the materials. To reduce the chance #' of typos in live settings, these shorter forms are accepted: #' -#' * GitHub repo spec: "OWNER/REPO". Equivalent to -#' `https://github.com/OWNER/REPO/DEFAULT_BRANCH.zip`. -#' * bit.ly or rstd.io shortlinks: "bit.ly/xxx-yyy-zzz" or "rstd.io/foofy". -#' The instructor must then arrange for the shortlink to point to a valid -#' download URL for the target ZIP file. The helper -#' [create_download_url()] helps to create such URLs for GitHub, DropBox, -#' and Google Drive. +#' * GitHub repo spec: "OWNER/REPO". Equivalent to +#' `https://github.com/OWNER/REPO/DEFAULT_BRANCH.zip`. +#' * bit.ly or rstd.io shortlinks: "bit.ly/xxx-yyy-zzz" or "rstd.io/foofy". +#' The instructor must then arrange for the shortlink to point to a valid +#' download URL for the target ZIP file. The helper +#' [create_download_url()] helps to create such URLs for GitHub, DropBox, +#' and Google Drive. #' @param destdir Destination for the new folder. Defaults to the location #' stored in the global option `usethis.destdir`, if defined, or to the user's #' Desktop or similarly conspicuous place otherwise. @@ -360,15 +360,15 @@ tidy_unzip <- function(zipfile, cleanup = FALSE) { ## DropBox ZIP files often include lots of hidden R, RStudio, and Git files filenames <- filenames[keep_lgl(filenames)] - td <- top_directory(filenames) - loose_parts <- is.na(td) - - if (loose_parts) { + parents <- path_before_slash(filenames) + unique_parents <- unique(parents) + if (length(unique_parents) == 1 && unique_parents != "") { + target <- path(base_path, unique_parents) + utils::unzip(zipfile, files = filenames, exdir = base_path) + } else { + # there is no parent; archive contains loose parts target <- path_ext_remove(zipfile) utils::unzip(zipfile, files = filenames, exdir = target) - } else { - target <- path(base_path, td) - utils::unzip(zipfile, files = filenames, exdir = base_path) } ui_bullets(c( "v" = "Unpacking ZIP file into {.path {pth(target, base_path)}} @@ -398,7 +398,7 @@ tidy_unzip <- function(zipfile, cleanup = FALSE) { } } - invisible(target) + invisible(unclass(target)) } #' @rdname use_course_details @@ -525,15 +525,17 @@ keep_lgl <- function(file, !grepl(ignores, file, perl = TRUE) } -top_directory <- function(filenames) { - in_top <- path_dir(filenames) == "." - unique_top <- unique(filenames[in_top]) - is_directory <- grepl("/$", unique_top) - if (length(unique_top) > 1 || !is_directory) { - NA_character_ - } else { - unique_top +path_before_slash <- function(filepath) { + f <- function(x) { + parts <- strsplit(x, "/", fixed = TRUE)[[1]] + if (length(parts) > 1 || grepl("/", x)) { + parts[1] + } else { + "" + } } + purrr::map_chr(filepath, f) + } content_type <- function(h) { diff --git a/R/coverage.R b/R/coverage.R index 2406cd8bd..6a6332513 100644 --- a/R/coverage.R +++ b/R/coverage.R @@ -44,7 +44,7 @@ use_covr_ignore <- function(files) { } use_codecov_badge <- function(repo_spec) { - url <- glue("https://codecov.io/gh/{repo_spec}") + url <- glue("https://app.codecov.io/gh/{repo_spec}") img <- glue("https://codecov.io/gh/{repo_spec}/graph/badge.svg") use_badge("Codecov test coverage", url, img) } diff --git a/R/cpp11.R b/R/cpp11.R index 0649aea10..576d21398 100644 --- a/R/cpp11.R +++ b/R/cpp11.R @@ -12,6 +12,7 @@ use_cpp11 <- function() { check_is_package("use_cpp11()") check_installed("cpp11") check_uses_roxygen("use_cpp11()") + check_has_package_doc("use_cpp11()") use_src() use_dependency("cpp11", "LinkingTo") diff --git a/R/create.R b/R/create.R index c1b1281e0..0275ed886 100644 --- a/R/create.R +++ b/R/create.R @@ -188,15 +188,7 @@ create_from_github <- function(repo_spec, rstudio = NULL, open = rlang::is_interactive(), protocol = git_protocol(), - host = NULL, - auth_token = deprecated(), - credentials = deprecated()) { - if (lifecycle::is_present(auth_token)) { - deprecate_warn_auth_token("create_from_github") - } - if (lifecycle::is_present(credentials)) { - deprecate_warn_credentials("create_from_github") - } + host = NULL) { check_protocol(protocol) parsed_repo_spec <- parse_repo_url(repo_spec) diff --git a/R/github-actions.R b/R/github-actions.R index e2c2d5f88..91bf90bd8 100644 --- a/R/github-actions.R +++ b/R/github-actions.R @@ -124,10 +124,12 @@ use_github_action <- function(name = NULL, ui_bullets(c("_" = "Learn more at {.url {readme}}.")) } - badge <- badge %||% is_check_action(url) - if (badge) { + if (badge %||% is_check_action(url)) { use_github_actions_badge(path_file(save_as)) } + if (badge %||% is_coverage_action(url)) { + use_codecov_badge(target_repo_spec()) + } invisible(new) } @@ -167,6 +169,10 @@ is_check_action <- function(url) { grepl("^check-", path_file(url)) } +is_coverage_action <- function(url) { + grepl("test-coverage", path_file(url)) +} + #' Generates a GitHub Actions badge #' #' Generates a GitHub Actions badge and that's all. This exists primarily for diff --git a/R/github-labels.R b/R/github-labels.R index cb5a37e3b..7da4f1d80 100644 --- a/R/github-labels.R +++ b/R/github-labels.R @@ -43,10 +43,6 @@ #' This keeps the issue page visually harmonious while still giving enough #' variation to easily distinguish different types of label. #' -#' @param repo_spec,host,auth_token `r lifecycle::badge("deprecated")`: These -#' arguments are now deprecated and will be removed in the future. Any input -#' provided via these arguments is not used. The target repo, host, and auth -#' token are all now determined from the current project's Git remotes. #' @param labels A character vector giving labels to add. #' @param rename A named vector with names giving old names and values giving #' new names. @@ -77,24 +73,11 @@ #' descriptions = c("foofiest" = "the foofiest issue you ever saw") #' ) #' } -use_github_labels <- function(repo_spec = deprecated(), - labels = character(), +use_github_labels <- function(labels = character(), rename = character(), colours = character(), descriptions = character(), - delete_default = FALSE, - host = deprecated(), - auth_token = deprecated()) { - if (lifecycle::is_present(repo_spec)) { - deprecate_warn_repo_spec("use_github_labels") - } - if (lifecycle::is_present(host)) { - deprecate_warn_host("use_github_labels") - } - if (lifecycle::is_present(auth_token)) { - deprecate_warn_auth_token("use_github_labels") - } - + delete_default = FALSE) { tr <- target_repo(github_get = TRUE, ok_configs = c("ours", "fork")) check_can_push(tr = tr, "to modify labels") diff --git a/R/github.R b/R/github.R index 2ee06f7ea..c3eb0affb 100644 --- a/R/github.R +++ b/R/github.R @@ -39,11 +39,6 @@ #' For a hypothetical GitHub Enterprise instance, either #' "https://github.acme.com/api/v3" or "https://github.acme.com" is #' acceptable. -#' @param auth_token,credentials `r lifecycle::badge("deprecated")`: No longer -#' consulted now that usethis uses the gert package for Git operations, -#' instead of git2r; gert relies on the credentials package for auth. The API -#' requests are now authorized with the token associated with the `host`, as -#' retrieved by [gh::gh_token()]. #' #' @export #' @examples @@ -61,16 +56,7 @@ use_github <- function(organisation = NULL, private = FALSE, visibility = c("public", "private", "internal"), protocol = git_protocol(), - host = NULL, - auth_token = deprecated(), - credentials = deprecated()) { - if (lifecycle::is_present(auth_token)) { - deprecate_warn_auth_token("use_github") - } - if (lifecycle::is_present(credentials)) { - deprecate_warn_credentials("use_github") - } - + host = NULL) { visibility_specified <- !missing(visibility) visibility <- match.arg(visibility) check_protocol(protocol) @@ -197,9 +183,6 @@ use_github <- function(organisation = NULL, #' an interactive session, the user can confirm which repo to use for the #' links. In a noninteractive session, links are formed using `upstream`. #' -#' @param host,auth_token `r lifecycle::badge("deprecated")`: No longer consulted -#' now that usethis consults the current project's GitHub remotes to get the -#' `host` and then relies on gh to discover an appropriate token. #' @param overwrite By default, `use_github_links()` will not overwrite existing #' fields. Set to `TRUE` to overwrite existing links. #' @export @@ -208,16 +191,7 @@ use_github <- function(organisation = NULL, #' use_github_links() #' } #' -use_github_links <- function(auth_token = deprecated(), - host = deprecated(), - overwrite = FALSE) { - if (lifecycle::is_present(auth_token)) { - deprecate_warn_auth_token("use_github_links") - } - if (lifecycle::is_present(host)) { - deprecate_warn_host("use_github_links") - } - +use_github_links <- function(overwrite = FALSE) { check_is_package("use_github_links()") gh_url <- github_url_from_git_remotes() diff --git a/R/issue.R b/R/issue.R index a4b0e6085..9e4b2e44f 100644 --- a/R/issue.R +++ b/R/issue.R @@ -7,8 +7,8 @@ #' by the tidyverse team. #' #' * `issue_close_community()` closes an issue, because it's not a bug report or -#' feature request, and points the author towards RStudio Community as a -#' better place to discuss usage (). +#' feature request, and points the author towards Posit Community as a +#' better place to discuss usage (). #' #' * `issue_reprex_needed()` labels the issue with the "reprex" label and #' gives the author some advice about what is needed. diff --git a/R/pr.R b/R/pr.R index 79da47e89..c881871e6 100644 --- a/R/pr.R +++ b/R/pr.R @@ -532,6 +532,7 @@ pr_forget <- function() pr_clean(mode = "forget") pr_clean <- function(number = NULL, target = c("source", "primary"), mode = c("finish", "forget")) { + withr::defer(rstudio_git_tickle()) mode <- match.arg(mode) repo <- git_repo() tr <- target_repo(github_get = NA, role = target, ask = FALSE) @@ -967,7 +968,7 @@ pr_branch_delete <- function(pr) { if (is.null(pr_ref)) { ui_bullets(c( - "i" = "PR {.val {pr$pr_string}} originated from branch {.val {pr_remref}}, + "i" = "PR {.href [{pr$pr_string}]({pr$pr_html_url})} originated from branch {.val {pr_remref}}, which no longer exists." )) return(invisible(FALSE)) @@ -975,14 +976,14 @@ pr_branch_delete <- function(pr) { if (is.na(pr$pr_merged_at)) { ui_bullets(c( - "i" = "PR {.val {pr$pr_string}} is unmerged, we will not delete the + "i" = "PR {.href [{pr$pr_string}]({pr$pr_html_url})} is unmerged, we will not delete the remote branch {.val {pr_remref}}." )) return(invisible(FALSE)) } ui_bullets(c( - "v" = "PR {.val {pr$pr_string}} has been merged, deleting remote branch + "v" = "PR {.href [{pr$pr_string}]({pr$pr_html_url})} has been merged, deleting remote branch {.val {pr_remref}}." )) # TODO: tryCatch here? diff --git a/R/r.R b/R/r.R index 0d87ff688..557af63be 100644 --- a/R/r.R +++ b/R/r.R @@ -43,9 +43,12 @@ #' @param name Either a string giving a file name (without directory) or #' `NULL` to take the name from the currently open file in RStudio. #' @inheritParams edit_file -#' @seealso The [testing](https://r-pkgs.org/testing-basics.html) and +#' @seealso +#' * The [testing](https://r-pkgs.org/testing-basics.html) and #' [R code](https://r-pkgs.org/code.html) chapters of #' [R Packages](https://r-pkgs.org). +#' * [use_test_helper()] to create a testthat helper file. +#' #' @export #' #' @examples @@ -85,6 +88,55 @@ use_test <- function(name = NULL, open = rlang::is_interactive()) { invisible(TRUE) } +#' Create or edit a test helper file +#' +#' This function creates (or opens) a test helper file, typically +#' `tests/testthat/helper.R`. Test helper files are executed at the +#' beginning of every automated test run and are also executed by +#' [`load_all()`][pkgload::load_all]. A helper file is a great place to +#' define test helper functions for use throughout your test suite, such as +#' a custom expectation. +#' +#' @param name Can be used to specify the optional "SLUG" in +#' `tests/testthat/helper-SLUG.R`. +#' @inheritParams edit_file +#' @seealso +#' * [use_test()] to create a test file. +#' * The testthat vignette on special files +#' `vignette("special-files", package = "testthat")`. +#' @export +#' +#' @examples +#' \dontrun{ +#' use_test_helper() +#' use_test_helper("mocks") +#' } +use_test_helper <- function(name = NULL, open = rlang::is_interactive()) { + maybe_name(name) + + if (!uses_testthat()) { + ui_abort(c( + "x" = "Your package must use {.pkg testthat} to use a helper file.", + "_" = "Call {.run usethis::use_testthat()} to set up {.pkg testthat}." + )) + } + + target_path <- proj_path( + path("tests", "testthat", as_test_helper_file(name)) + ) + + if (!file_exists(target_path)) { + ui_bullets(c( + "i" = "Test helper files are executed at the start of all automated + test runs.", + "i" = "{.run devtools::load_all()} also sources test helper files." + )) + } + edit_file(target_path, open = open) + + invisible(TRUE) +} + # helpers ----------------------------------------------------------------- compute_name <- function(name = NULL, ext = "R", error_call = caller_env()) { @@ -172,3 +224,14 @@ check_file_name <- function(name, call = caller_env()) { valid_file_name <- function(x) { grepl("^[a-zA-Z0-9._-]+$", x) } + +as_test_helper_file <- function(name = NULL) { + file <- name %||% "helper.R" + if (!grepl("^helper", file)) { + file <- glue("helper-{file}") + } + if (path_ext(file) == "") { + file <- path_ext_set(file, "R") + } + unclass(file) +} diff --git a/R/release.R b/R/release.R index 1773766ae..1f69c2440 100644 --- a/R/release.R +++ b/R/release.R @@ -217,22 +217,11 @@ release_type <- function(version) { #' assume that current state (SHA of `HEAD`, package version, NEWS) is the #' submitted state. #' -#' @param host,auth_token `r lifecycle::badge("deprecated")`: No longer -#' consulted now that usethis allows the gh package to lookup a token based on -#' a URL determined from the current project's GitHub remotes. #' @param publish If `TRUE`, publishes a release. If `FALSE`, creates a draft #' release. #' @export -use_github_release <- function(publish = TRUE, - host = deprecated(), - auth_token = deprecated()) { +use_github_release <- function(publish = TRUE) { check_is_package("use_github_release()") - if (lifecycle::is_present(host)) { - deprecate_warn_host("use_github_release") - } - if (lifecycle::is_present(auth_token)) { - deprecate_warn_auth_token("use_github_release") - } tr <- target_repo(github_get = TRUE, ok_configs = c("ours", "fork")) check_can_push(tr = tr, "to create a release") diff --git a/R/usethis-defunct.R b/R/usethis-defunct.R deleted file mode 100644 index eb0c9cd8f..000000000 --- a/R/usethis-defunct.R +++ /dev/null @@ -1,350 +0,0 @@ -#' Deprecated Git functions -#' -#' @description -#' `r lifecycle::badge("deprecated")` -#' -#' * `git_branch_default()` has been replaced by [git_default_branch()]. -#' -#' @keywords internal -#' @export -git_branch_default <- function() { - lifecycle::deprecate_soft("2.1.0", "git_branch_default()", "git_default_branch()") - git_default_branch() -} - -#' Defunct tidyverse functions -#' -#' @description -#' `r lifecycle::badge("defunct")` -#' -#' * `use_tidy_labels()` has been replaced by [use_tidy_github_labels()]. -#' * `use_tidy_ci()` has been replaced by [use_tidy_github_actions()]. -#' * `use_tidy_eval()` is defunct because there's no longer a need to -#' systematically import and re-export a large number of functions in order -#' to use tidy evaluation. Instead, use [use_import_from()] to tactically -#' import functions as you need them. -#' -#' @keywords internal -#' @export -use_tidy_labels <- function() { - lifecycle::deprecate_stop("2.1.0", "use_tidy_labels()", "use_tidy_github_labels()") -} - -#' @rdname use_tidy_labels -#' @export -use_tidy_ci <- function(...) { - lifecycle::deprecate_stop("2.1.0", "use_tidy_ci()", "use_tidy_github_actions()") -} - -#' @rdname use_tidy_labels -#' @keywords internal -#' @export -use_tidy_eval <- function() { - lifecycle::deprecate_stop( - "2.2.0", - "use_tidy_eval()", - details = c( - "There is no longer a need to systematically import and/or re-export functions", - "Instead import functions as needed, with e.g.:", - 'usethis::use_import_from("rlang", c(".data", ".env"))' - ) - ) -} - -#' Defunct git2r functions -#' -#' @description -#' `r lifecycle::badge("defunct")` -#' -#' In usethis v2.0.0, usethis switched from git2r to gert (+ credentials) for -#' all Git operations. This pair of packages (gert + credentials) is designed to -#' discover and use the same credentials as command line Git. As a result, a -#' great deal of credential-handling assistance has been removed from usethis, -#' primarily around SSH keys. -#' -#' If you have credential problems, focus your troubleshooting on getting the -#' credentials package to find your credentials. The [introductory -#' vignette](https://docs.ropensci.org/credentials/articles/intro.html) -#' is a good place to start. -#' -#' If you use the HTTPS protocol (which we recommend), a GitHub personal access -#' token will satisfy all auth needs, for both Git and the GitHub API, and is -#' therefore the easiest approach to get working. See [gh_token_help()] for -#' more. -#' -#' @param protocol Deprecated. -#' @param auth_token Deprecated. -#' @param credentials Deprecated. -#' -#' @return These functions raise a warning and return an invisible `NULL`. -#' @export -git_credentials <- function(protocol = deprecated(), - auth_token = deprecated()) { - lifecycle::deprecate_stop( - "2.0.0", - "git_credentials()", - details = git2r_explanation - ) - invisible() -} - -#' @rdname git_credentials -#' @export -use_git_credentials <- function(credentials = deprecated()) { - lifecycle::deprecate_stop( - "2.0.0", - "use_git_credentials()", - details = git2r_explanation - ) - invisible() -} - -git2r_explanation <- glue(" - usethis now uses the gert package for Git operations, instead of git2r, and - gert relies on the credentials package for auth. Therefore git2r credentials - are no longer accepted.") - -deprecate_warn_credentials <- function(whos_asking, details = NULL) { - whos_asking <- sub("[()]+$", "", whos_asking) - what <- glue("{whos_asking}(credentials = )") - - lifecycle::deprecate_warn( - "2.0.0", - what, - details = details %||% git2r_explanation - ) -} - -deprecate_warn_host <- function(whos_asking, details = NULL) { - whos_asking <- sub("[()]+$", "", whos_asking) - what <- glue("{whos_asking}(host = )") - - host_explanation <- glue(" - usethis now determines the `host` from the current project's \\ - Git remotes. - The `host` argument is ignored and will eventually be removed.") - - lifecycle::deprecate_warn( - "2.0.0", - what, - details = details %||% host_explanation - ) -} - -deprecate_warn_auth_token <- function(whos_asking, details = NULL) { - whos_asking <- sub("[()]+$", "", whos_asking) - what <- glue("{whos_asking}(auth_token = )") - - auth_token_explanation <- glue(" - usethis now delegates token lookup to the gh package, which retrieves \\ - credentials based on the targeted host URL. - This URL is determined by the current project's Git remotes. - The `auth_token` argument is ignored and will eventually be removed.") - - lifecycle::deprecate_warn( - "2.0.0", - what, - details = details %||% auth_token_explanation - ) -} - -deprecate_warn_repo_spec <- function(whos_asking, details = NULL) { - whos_asking <- sub("[()]+$", "", whos_asking) - what <- glue("{whos_asking}(repo_spec = )") - - repo_spec_explanation <- glue(" - usethis now consults the current project's Git remotes to determine the \\ - target repo. - The `repo_spec` argument is ignored and will eventually be removed.") - - lifecycle::deprecate_warn( - "2.0.0", - what, - details = details %||% repo_spec_explanation - ) -} - - -# ci ---------------------------------------------------------------------- - - -#' Defunct Travis and Appveyor functions -#' -#' @description -#' `r lifecycle::badge("defunct")` -#' -#' These functions which formally supported CI on Appveyor and Travis are -#' now defunct as we no longer recommend using these services. We now -#' recommend using GitHub actions, e.g. with [use_github_action()]. -#' -#' @export -#' @keywords internal -use_travis <- function(browse = rlang::is_interactive(), - ext = c("com", "org")) { - - lifecycle::deprecate_stop( - when = "2.0.0", - what = "use_travis()", - with = "use_github_action()" - ) -} - -#' @export -#' @rdname use_travis -use_travis_badge <- function(ext = c("com", "org"), repo_spec = NULL) { - lifecycle::deprecate_stop( - when = "2.0.0", - what = "use_travis_badge()" - ) -} - -#' @export -#' @rdname use_travis -use_pkgdown_travis <- function() { - lifecycle::deprecate_stop( - when = "2.0.0", - what = "use_pkgdown_travis()", - with = "use_pkgdown_github_pages()" - ) -} - -#' @export -#' @rdname use_travis -use_appveyor <- function(browse = rlang::is_interactive()) { - lifecycle::deprecate_stop( - when = "2.0.0", - what = "use_appveyor()", - with = "use_github_action()" - ) -} - -#' @export -#' @rdname use_travis -use_appveyor_badge <- function(repo_spec = NULL) { - lifecycle::deprecate_stop( - when = "2.0.0", - what = "use_appveyor_badge()", - ) -} - -#' @export -#' @rdname use_travis -browse_travis <- function(package = NULL, ext = c("com", "org")) { - lifecycle::deprecate_stop( - when = "2.2.0", - what = "browse_travis()", - ) -} - - -# GitHub actions -------------------------------------------------------------- - -#' Defunct GitHub Actions workflows -#' -#' @description -#' `r lifecycle::badge("deprecated")` -#' -#' * `use_github_actions()` is deprecated because it was just an alias -#' for [use_github_action_check_release()]. -#' -#' * `use_github_action_check_full()` is overkill for most packages and is -#' not recommended. -#' -#' * `use_github_action_check_release()`, `use_github_action_check_standard()`, -#' and `use_github_action_pr_commands()` are deprecated in favor of -#' [use_github_action()], which can now suggest specific workflows to use. -#' -#' @export -#' @keywords internal -use_github_actions <- function() { - lifecycle::deprecate_warn( - when = "2.2.0", - what = "use_github_actions()", - with = "use_github_action('check-release')" - ) - use_github_action('check-release') -} - -#' @rdname use_github_actions -#' @export -use_github_action_check_release <- function(save_as = "R-CMD-check.yaml", - ref = NULL, - ignore = TRUE, - open = FALSE) { - - lifecycle::deprecate_warn( - when = "2.2.0", - what = "use_github_action_check_release()", - with = "use_github_action('check-release')" - ) - - use_github_action( - "check-release.yaml", - ref = ref, - save_as = save_as, - ignore = ignore, - open = open - ) - use_github_actions_badge(save_as) -} - -#' @rdname use_github_actions -#' @export -use_github_action_check_standard <- function(save_as = "R-CMD-check.yaml", - ref = NULL, - ignore = TRUE, - open = FALSE) { - lifecycle::deprecate_warn( - when = "2.2.0", - what = "use_github_action_check_standard()", - with = "use_github_action('check-standard')" - ) - - use_github_action( - "check-standard.yaml", - ref = ref, - save_as = save_as, - ignore = ignore, - open = open - ) - use_github_actions_badge(save_as) -} - -#' @rdname use_github_actions -#' @export -use_github_action_pr_commands <- function(save_as = "pr-commands.yaml", - ref = NULL, - ignore = TRUE, - open = FALSE) { - lifecycle::deprecate_warn( - when = "2.2.0", - what = "use_github_action_pr_commands()", - with = "use_github_action('pr-commands')" - ) - - use_github_action( - "pr-commands.yaml", - ref = ref, - save_as = save_as, - ignore = ignore, - open = open - ) -} - -#' @rdname use_github_actions -#' @export -use_github_action_check_full <- function(save_as = "R-CMD-check.yaml", - ignore = TRUE, - open = FALSE, - repo_spec = NULL) { - details <- glue(" - It is overkill for the vast majority of R packages. - The \"check-full\" workflow is among those configured by \\ - `use_tidy_github_actions()`. - If you really want it, request it by name with `use_github_action()`.") - lifecycle::deprecate_stop( - "2.1.0", - "use_github_action_check_full()", - details = details - ) -} diff --git a/R/usethis-deprecated.R b/R/usethis-deprecated.R new file mode 100644 index 000000000..56241f176 --- /dev/null +++ b/R/usethis-deprecated.R @@ -0,0 +1,164 @@ +#' Deprecated Git functions +#' +#' @description +#' `r lifecycle::badge("deprecated")` +#' +#' `git_branch_default()` has been replaced by [git_default_branch()]. +#' +#' @keywords internal +#' @export +git_branch_default <- function() { + lifecycle::deprecate_warn("2.1.0", "git_branch_default()", "git_default_branch()") + git_default_branch() +} + +#' Deprecated badge function +#' +#' @description +#' `r lifecycle::badge("deprecated")` +#' +#' `use_rscloud_badge()` has been replaced by [use_posit_cloud_badge()]. +#' +#' @keywords internal +#' @export +use_rscloud_badge <- function(url) { + lifecycle::deprecate_stop( + "2.2.0", "use_rscloud_badge()", + "use_posit_cloud_badge()" + ) +} + +#' Deprecated tidyverse functions +#' +#' @description +#' `r lifecycle::badge("deprecated")` +#' +#' * `use_tidy_eval()` is deprecated because there's no longer a need to +#' systematically import and re-export a large number of functions in order +#' to use tidy evaluation. Instead, use [use_import_from()] to tactically +#' import functions as you need them. +#' @keywords internal +#' @export +use_tidy_eval <- function() { + lifecycle::deprecate_stop( + "2.2.0", + "use_tidy_eval()", + details = c( + "There is no longer a need to systematically import and/or re-export functions", + "Instead import functions as needed, with e.g.:", + 'usethis::use_import_from("rlang", c(".data", ".env"))' + ) + ) +} + +# GitHub actions -------------------------------------------------------------- + +#' Deprecated GitHub Actions functions +#' +#' @description +#' `r lifecycle::badge("deprecated")` +#' +#' * `use_github_actions()` is deprecated because it was just an alias +#' for [use_github_action_check_release()]. +#' +#' * `use_github_action_check_full()` is overkill for most packages and is +#' not recommended. +#' +#' * `use_github_action_check_release()`, `use_github_action_check_standard()`, +#' and `use_github_action_pr_commands()` are deprecated in favor of +#' [use_github_action()], which can now suggest specific workflows to use. +#' +#' @export +#' @keywords internal +use_github_actions <- function() { + lifecycle::deprecate_warn( + when = "2.2.0", + what = "use_github_actions()", + with = "use_github_action('check-release')" + ) + use_github_action('check-release') +} + +#' @rdname use_github_actions +#' @export +use_github_action_check_release <- function(save_as = "R-CMD-check.yaml", + ref = NULL, + ignore = TRUE, + open = FALSE) { + + lifecycle::deprecate_warn( + when = "2.2.0", + what = "use_github_action_check_release()", + with = "use_github_action('check-release')" + ) + + use_github_action( + "check-release.yaml", + ref = ref, + save_as = save_as, + ignore = ignore, + open = open + ) + use_github_actions_badge(save_as) +} + +#' @rdname use_github_actions +#' @export +use_github_action_check_standard <- function(save_as = "R-CMD-check.yaml", + ref = NULL, + ignore = TRUE, + open = FALSE) { + lifecycle::deprecate_warn( + when = "2.2.0", + what = "use_github_action_check_standard()", + with = "use_github_action('check-standard')" + ) + + use_github_action( + "check-standard.yaml", + ref = ref, + save_as = save_as, + ignore = ignore, + open = open + ) + use_github_actions_badge(save_as) +} + +#' @rdname use_github_actions +#' @export +use_github_action_pr_commands <- function(save_as = "pr-commands.yaml", + ref = NULL, + ignore = TRUE, + open = FALSE) { + lifecycle::deprecate_warn( + when = "2.2.0", + what = "use_github_action_pr_commands()", + with = "use_github_action('pr-commands')" + ) + + use_github_action( + "pr-commands.yaml", + ref = ref, + save_as = save_as, + ignore = ignore, + open = open + ) +} + +#' @rdname use_github_actions +#' @export +use_github_action_check_full <- function(save_as = "R-CMD-check.yaml", + ignore = TRUE, + open = FALSE, + repo_spec = NULL) { + details <- glue(" + It is overkill for the vast majority of R packages. + The \"check-full\" workflow is among those configured by \\ + `use_tidy_github_actions()`. + If you really want it, request it by name with `use_github_action()`.") + lifecycle::deprecate_stop( + "2.1.0", + "use_github_action_check_full()", + details = details + ) +} diff --git a/README.Rmd b/README.Rmd index ed3b4ac0a..35d75aa9b 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,8 +19,7 @@ knitr::opts_chunk$set( [![R-CMD-check](https://github.com/r-lib/usethis/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/usethis/actions/workflows/R-CMD-check.yaml) [![CRAN status](https://www.r-pkg.org/badges/version/usethis)](https://CRAN.R-project.org/package=usethis) [![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) -[![.github/workflows/R-CMD-check](https://github.com/r-lib/usethis/actions/workflows/.github/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/usethis/actions/workflows/.github/workflows/R-CMD-check.yaml) -[![Codecov test coverage](https://codecov.io/gh/r-lib/usethis/graph/badge.svg)](https://codecov.io/gh/r-lib/usethis) +[![Codecov test coverage](https://codecov.io/gh/r-lib/usethis/graph/badge.svg)](https://app.codecov.io/gh/r-lib/usethis) usethis is a workflow package: it automates repetitive tasks that arise during project setup and development, both for R packages and non-package projects. diff --git a/README.md b/README.md index b865cb055..2dc670044 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,8 @@ status](https://www.r-pkg.org/badges/version/usethis)](https://CRAN.R-project.org/package=usethis) [![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) -[![.github/workflows/R-CMD-check](https://github.com/r-lib/usethis/actions/workflows/.github/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/usethis/actions/workflows/.github/workflows/R-CMD-check.yaml) [![Codecov test -coverage](https://codecov.io/gh/r-lib/usethis/graph/badge.svg)](https://codecov.io/gh/r-lib/usethis) +coverage](https://codecov.io/gh/r-lib/usethis/graph/badge.svg)](https://app.codecov.io/gh/r-lib/usethis) usethis is a workflow package: it automates repetitive tasks that arise @@ -61,8 +60,8 @@ library(usethis) # Create a new package ------------------------------------------------- path <- file.path(tempdir(), "mypkg") create_package(path) -#> ✔ Creating '/tmp/RtmpMuqeSm/mypkg/'. -#> ✔ Setting active project to "/private/tmp/RtmpMuqeSm/mypkg". +#> ✔ Creating '/tmp/RtmpCJHMlj/mypkg/'. +#> ✔ Setting active project to "/private/tmp/RtmpCJHMlj/mypkg". #> ✔ Creating 'R/'. #> ✔ Writing 'DESCRIPTION'. #> Package: mypkg @@ -75,13 +74,13 @@ create_package(path) #> license #> Encoding: UTF-8 #> Roxygen: list(markdown = TRUE) -#> RoxygenNote: 7.3.1 +#> RoxygenNote: 7.3.2 #> ✔ Writing 'NAMESPACE'. #> ✔ Setting active project to "". # only needed since this session isn't interactive proj_activate(path) -#> ✔ Setting active project to "/private/tmp/RtmpMuqeSm/mypkg". -#> ✔ Changing working directory to '/tmp/RtmpMuqeSm/mypkg/' +#> ✔ Setting active project to "/private/tmp/RtmpCJHMlj/mypkg". +#> ✔ Changing working directory to '/tmp/RtmpCJHMlj/mypkg/' # Modify the description ---------------------------------------------- use_mit_license("My Name") diff --git a/_pkgdown.yml b/_pkgdown.yml index fbc30fc2c..df4d8a5e7 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -58,6 +58,7 @@ reference: - use_rmarkdown_template - use_spell_check - use_test + - use_test_helper - use_vignette - use_addin - use_citation @@ -91,11 +92,9 @@ reference: - title: Continuous integration contents: - use_github_action - - use_appveyor - use_circleci - use_gitlab_ci - use_jenkins - - use_travis - title: Tidyverse development desc: > Conventions used in the tidyverse and r-lib organisations @@ -155,20 +154,11 @@ reference: - use_rmarkdown_template - use_rstudio - use_rstudio_preferences - - title: Defunct and deprecated functions - desc: > - - Defunct lifecycle - - - Deprecated lifecycle - + - title: Deprecated functions contents: - - git_credentials - git_branch_default - use_github_actions - - use_tidy_labels - - use_travis + - use_tidy_eval articles: - title: Basics @@ -187,8 +177,3 @@ articles: contents: - articles/ui-cli-conversion - articles/badge-accessibility - -redirects: - - ["reference/browse_github_pat.html", "reference/github-token.html"] - - ["reference/pr_pull_upstream.html","reference/pull-requests.html"] - - ["reference/browse_github_token.html", "reference/github-token.html"] diff --git a/cran-comments.md b/cran-comments.md index 44b7bf32e..6df713ca7 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,8 +1,26 @@ -This is a patch release in response to a 2024-01-22 email from Kurt Hornik about -check NOTEs related to Rd \usage sections. I have eliminated the NOTEs. - -I did NOT rerun reverse dependency checks for this patch release. - ## R CMD check results 0 errors | 0 warnings | 0 notes + +## revdepcheck results + +We checked 217 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. + + * We saw 2 new problems + * We failed to check 0 packages + +Issues with CRAN packages are summarised below. + +### New problems + +* circle + This package makes reference to a function that is now removed from usethis. + This function has been hard-deprecated (i.e. throws an error with advice on + how to update) since usethis v2.2.0, released in December 2020. + I have opened an issue in circle's GitHub repository. + +* exampletestr + This package has a brittle test that checks for exact wording of an error + message originating in usethis. + That test fails because usethis's error message has changed slightly. + I have opened an issue in exampletestr's GitHub repository. diff --git a/inst/templates/lifecycle-archived.svg b/inst/templates/lifecycle-archived.svg deleted file mode 100644 index 745ab0c78..000000000 --- a/inst/templates/lifecycle-archived.svg +++ /dev/null @@ -1,21 +0,0 @@ - - lifecycle: archived - - - - - - - - - - - - - - - lifecycle - - archived - - diff --git a/inst/templates/lifecycle-defunct.svg b/inst/templates/lifecycle-defunct.svg deleted file mode 100644 index d5c9559ed..000000000 --- a/inst/templates/lifecycle-defunct.svg +++ /dev/null @@ -1,21 +0,0 @@ - - lifecycle: defunct - - - - - - - - - - - - - - - lifecycle - - defunct - - diff --git a/inst/templates/lifecycle-maturing.svg b/inst/templates/lifecycle-maturing.svg deleted file mode 100644 index 897370ecf..000000000 --- a/inst/templates/lifecycle-maturing.svg +++ /dev/null @@ -1,21 +0,0 @@ - - lifecycle: maturing - - - - - - - - - - - - - - - lifecycle - - maturing - - diff --git a/inst/templates/lifecycle-questioning.svg b/inst/templates/lifecycle-questioning.svg deleted file mode 100644 index 7c1721d05..000000000 --- a/inst/templates/lifecycle-questioning.svg +++ /dev/null @@ -1,21 +0,0 @@ - - lifecycle: questioning - - - - - - - - - - - - - - - lifecycle - - questioning - - diff --git a/inst/templates/lifecycle-soft-deprecated.svg b/inst/templates/lifecycle-soft-deprecated.svg deleted file mode 100644 index 9c166ff30..000000000 --- a/inst/templates/lifecycle-soft-deprecated.svg +++ /dev/null @@ -1,21 +0,0 @@ - - lifecycle: soft-deprecated - - - - - - - - - - - - - - - lifecycle - - soft-deprecated - - diff --git a/man/badges.Rd b/man/badges.Rd index 831a574c1..b69ea32b5 100644 --- a/man/badges.Rd +++ b/man/badges.Rd @@ -8,7 +8,6 @@ \alias{use_lifecycle_badge} \alias{use_binder_badge} \alias{use_posit_cloud_badge} -\alias{use_rscloud_badge} \title{README badges} \usage{ use_badge(badge_name, href, src) @@ -22,8 +21,6 @@ use_lifecycle_badge(stage) use_binder_badge(ref = git_default_branch(), urlpath = NULL) use_posit_cloud_badge(url) - -use_rscloud_badge(url) } \arguments{ \item{badge_name}{Badge name. Used in error message and alt text} diff --git a/man/browse-this.Rd b/man/browse-this.Rd index 5b474f32a..0057dba6c 100644 --- a/man/browse-this.Rd +++ b/man/browse-this.Rd @@ -47,7 +47,6 @@ DESCRIPTION file is sought first in the local package library and then on CRAN. \item Fixed templates: \itemize{ -\item Travis CI: \verb{https://travis-ci.\{EXT\}/\{OWNER\}/\{PACKAGE\}} \item Circle CI: \verb{https://circleci.com/gh/\{OWNER\}/\{PACKAGE\}} \item CRAN landing page: \verb{https://cran.r-project.org/package=\{PACKAGE\}} \item GitHub mirror of a CRAN package: \verb{https://github.com/cran/\{PACKAGE\}} @@ -70,8 +69,6 @@ in the source repo or your fork. issue. \item \code{browse_github_pulls()}: Visits the GitHub Pull Request index or one specific pull request. -\item \code{browse_travis()}: Visits the project's page on -\href{https://www.travis-ci.com/}{Travis CI}. \item \code{browse_circleci()}: Visits the project's page on \href{https://circleci.com}{Circle CI}. \item \code{browse_cran()}: Visits the package on CRAN, via the canonical URL. diff --git a/man/create_from_github.Rd b/man/create_from_github.Rd index ff901adc9..ceab18cac 100644 --- a/man/create_from_github.Rd +++ b/man/create_from_github.Rd @@ -11,9 +11,7 @@ create_from_github( rstudio = NULL, open = rlang::is_interactive(), protocol = git_protocol(), - host = NULL, - auth_token = deprecated(), - credentials = deprecated() + host = NULL ) } \arguments{ @@ -69,12 +67,6 @@ variable. For a hypothetical GitHub Enterprise instance, either "https://github.acme.com/api/v3" or "https://github.acme.com" is acceptable.} - -\item{auth_token, credentials}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}: No longer -consulted now that usethis uses the gert package for Git operations, -instead of git2r; gert relies on the credentials package for auth. The API -requests are now authorized with the token associated with the \code{host}, as -retrieved by \code{\link[gh:gh_token]{gh::gh_token()}}.} } \description{ Creates a new local project and Git repository from a repo on GitHub, by diff --git a/man/figures/lifecycle-archived.svg b/man/figures/lifecycle-archived.svg deleted file mode 100644 index 745ab0c78..000000000 --- a/man/figures/lifecycle-archived.svg +++ /dev/null @@ -1,21 +0,0 @@ - - lifecycle: archived - - - - - - - - - - - - - - - lifecycle - - archived - - diff --git a/man/figures/lifecycle-defunct.svg b/man/figures/lifecycle-defunct.svg deleted file mode 100644 index d5c9559ed..000000000 --- a/man/figures/lifecycle-defunct.svg +++ /dev/null @@ -1,21 +0,0 @@ - - lifecycle: defunct - - - - - - - - - - - - - - - lifecycle - - defunct - - diff --git a/man/figures/lifecycle-maturing.svg b/man/figures/lifecycle-maturing.svg deleted file mode 100644 index 897370ecf..000000000 --- a/man/figures/lifecycle-maturing.svg +++ /dev/null @@ -1,21 +0,0 @@ - - lifecycle: maturing - - - - - - - - - - - - - - - lifecycle - - maturing - - diff --git a/man/figures/lifecycle-questioning.svg b/man/figures/lifecycle-questioning.svg deleted file mode 100644 index 7c1721d05..000000000 --- a/man/figures/lifecycle-questioning.svg +++ /dev/null @@ -1,21 +0,0 @@ - - lifecycle: questioning - - - - - - - - - - - - - - - lifecycle - - questioning - - diff --git a/man/figures/lifecycle-soft-deprecated.svg b/man/figures/lifecycle-soft-deprecated.svg deleted file mode 100644 index 9c166ff30..000000000 --- a/man/figures/lifecycle-soft-deprecated.svg +++ /dev/null @@ -1,21 +0,0 @@ - - lifecycle: soft-deprecated - - - - - - - - - - - - - - - lifecycle - - soft-deprecated - - diff --git a/man/git_branch_default.Rd b/man/git_branch_default.Rd index 2d81e8542..f7b1bf112 100644 --- a/man/git_branch_default.Rd +++ b/man/git_branch_default.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/usethis-defunct.R +% Please edit documentation in R/usethis-deprecated.R \name{git_branch_default} \alias{git_branch_default} \title{Deprecated Git functions} @@ -8,8 +8,7 @@ git_branch_default() } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} -\itemize{ -\item \code{git_branch_default()} has been replaced by \code{\link[=git_default_branch]{git_default_branch()}}. -} + +\code{git_branch_default()} has been replaced by \code{\link[=git_default_branch]{git_default_branch()}}. } \keyword{internal} diff --git a/man/git_credentials.Rd b/man/git_credentials.Rd deleted file mode 100644 index 7a445b69c..000000000 --- a/man/git_credentials.Rd +++ /dev/null @@ -1,39 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/usethis-defunct.R -\name{git_credentials} -\alias{git_credentials} -\alias{use_git_credentials} -\title{Defunct git2r functions} -\usage{ -git_credentials(protocol = deprecated(), auth_token = deprecated()) - -use_git_credentials(credentials = deprecated()) -} -\arguments{ -\item{protocol}{Deprecated.} - -\item{auth_token}{Deprecated.} - -\item{credentials}{Deprecated.} -} -\value{ -These functions raise a warning and return an invisible \code{NULL}. -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#defunct}{\figure{lifecycle-defunct.svg}{options: alt='[Defunct]'}}}{\strong{[Defunct]}} - -In usethis v2.0.0, usethis switched from git2r to gert (+ credentials) for -all Git operations. This pair of packages (gert + credentials) is designed to -discover and use the same credentials as command line Git. As a result, a -great deal of credential-handling assistance has been removed from usethis, -primarily around SSH keys. - -If you have credential problems, focus your troubleshooting on getting the -credentials package to find your credentials. The \href{https://docs.ropensci.org/credentials/articles/intro.html}{introductory vignette} -is a good place to start. - -If you use the HTTPS protocol (which we recommend), a GitHub personal access -token will satisfy all auth needs, for both Git and the GitHub API, and is -therefore the easiest approach to get working. See \code{\link[=gh_token_help]{gh_token_help()}} for -more. -} diff --git a/man/issue-this.Rd b/man/issue-this.Rd index 7486ddc4d..eb490fbee 100644 --- a/man/issue-this.Rd +++ b/man/issue-this.Rd @@ -22,8 +22,8 @@ with large numbers of issues, particularly motivated by the challenges faced by the tidyverse team. \itemize{ \item \code{issue_close_community()} closes an issue, because it's not a bug report or -feature request, and points the author towards RStudio Community as a -better place to discuss usage (\url{https://community.rstudio.com}). +feature request, and points the author towards Posit Community as a +better place to discuss usage (\url{https://forum.posit.co}). \item \code{issue_reprex_needed()} labels the issue with the "reprex" label and gives the author some advice about what is needed. } diff --git a/man/use_github.Rd b/man/use_github.Rd index 134d300d7..3402239f7 100644 --- a/man/use_github.Rd +++ b/man/use_github.Rd @@ -9,9 +9,7 @@ use_github( private = FALSE, visibility = c("public", "private", "internal"), protocol = git_protocol(), - host = NULL, - auth_token = deprecated(), - credentials = deprecated() + host = NULL ) } \arguments{ @@ -39,12 +37,6 @@ environment variable. For a hypothetical GitHub Enterprise instance, either "https://github.acme.com/api/v3" or "https://github.acme.com" is acceptable.} - -\item{auth_token, credentials}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}: No longer -consulted now that usethis uses the gert package for Git operations, -instead of git2r; gert relies on the credentials package for auth. The API -requests are now authorized with the token associated with the \code{host}, as -retrieved by \code{\link[gh:gh_token]{gh::gh_token()}}.} } \description{ \code{use_github()} takes a local project and: diff --git a/man/use_github_actions.Rd b/man/use_github_actions.Rd index dd7532346..1bc46c634 100644 --- a/man/use_github_actions.Rd +++ b/man/use_github_actions.Rd @@ -1,12 +1,12 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/usethis-defunct.R +% Please edit documentation in R/usethis-deprecated.R \name{use_github_actions} \alias{use_github_actions} \alias{use_github_action_check_release} \alias{use_github_action_check_standard} \alias{use_github_action_pr_commands} \alias{use_github_action_check_full} -\title{Defunct GitHub Actions workflows} +\title{Deprecated GitHub Actions functions} \usage{ use_github_actions() diff --git a/man/use_github_labels.Rd b/man/use_github_labels.Rd index 5a7732fe3..9433ba7ed 100644 --- a/man/use_github_labels.Rd +++ b/man/use_github_labels.Rd @@ -10,14 +10,11 @@ \title{Manage GitHub issue labels} \usage{ use_github_labels( - repo_spec = deprecated(), labels = character(), rename = character(), colours = character(), descriptions = character(), - delete_default = FALSE, - host = deprecated(), - auth_token = deprecated() + delete_default = FALSE ) use_tidy_github_labels() @@ -31,11 +28,6 @@ tidy_label_colours() tidy_label_descriptions() } \arguments{ -\item{repo_spec, host, auth_token}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}: These -arguments are now deprecated and will be removed in the future. Any input -provided via these arguments is not used. The target repo, host, and auth -token are all now determined from the current project's Git remotes.} - \item{labels}{A character vector giving labels to add.} \item{rename}{A named vector with names giving old names and values giving diff --git a/man/use_github_links.Rd b/man/use_github_links.Rd index b42928b29..798e9f4c4 100644 --- a/man/use_github_links.Rd +++ b/man/use_github_links.Rd @@ -4,17 +4,9 @@ \alias{use_github_links} \title{Use GitHub links in URL and BugReports} \usage{ -use_github_links( - auth_token = deprecated(), - host = deprecated(), - overwrite = FALSE -) +use_github_links(overwrite = FALSE) } \arguments{ -\item{host, auth_token}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}: No longer consulted -now that usethis consults the current project's GitHub remotes to get the -\code{host} and then relies on gh to discover an appropriate token.} - \item{overwrite}{By default, \code{use_github_links()} will not overwrite existing fields. Set to \code{TRUE} to overwrite existing links.} } diff --git a/man/use_github_release.Rd b/man/use_github_release.Rd index 2fc78ae3b..7877fbd9f 100644 --- a/man/use_github_release.Rd +++ b/man/use_github_release.Rd @@ -4,19 +4,11 @@ \alias{use_github_release} \title{Publish a GitHub release} \usage{ -use_github_release( - publish = TRUE, - host = deprecated(), - auth_token = deprecated() -) +use_github_release(publish = TRUE) } \arguments{ \item{publish}{If \code{TRUE}, publishes a release. If \code{FALSE}, creates a draft release.} - -\item{host, auth_token}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}: No longer -consulted now that usethis allows the gh package to lookup a token based on -a URL determined from the current project's GitHub remotes.} } \description{ Pushes the current branch (if safe) then publishes a GitHub release for the diff --git a/man/use_r.Rd b/man/use_r.Rd index 24f11959e..fab4428e2 100644 --- a/man/use_r.Rd +++ b/man/use_r.Rd @@ -71,7 +71,10 @@ use_r() } } \seealso{ -The \href{https://r-pkgs.org/testing-basics.html}{testing} and +\itemize{ +\item The \href{https://r-pkgs.org/testing-basics.html}{testing} and \href{https://r-pkgs.org/code.html}{R code} chapters of \href{https://r-pkgs.org}{R Packages}. +\item \code{\link[=use_test_helper]{use_test_helper()}} to create a testthat helper file. +} } diff --git a/man/use_rscloud_badge.Rd b/man/use_rscloud_badge.Rd new file mode 100644 index 000000000..5d352b81b --- /dev/null +++ b/man/use_rscloud_badge.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/usethis-deprecated.R +\name{use_rscloud_badge} +\alias{use_rscloud_badge} +\title{Deprecated badge function} +\usage{ +use_rscloud_badge(url) +} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + +\code{use_rscloud_badge()} has been replaced by \code{\link[=use_posit_cloud_badge]{use_posit_cloud_badge()}}. +} +\keyword{internal} diff --git a/man/use_test_helper.Rd b/man/use_test_helper.Rd new file mode 100644 index 000000000..367fb18ac --- /dev/null +++ b/man/use_test_helper.Rd @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/r.R +\name{use_test_helper} +\alias{use_test_helper} +\title{Create or edit a test helper file} +\usage{ +use_test_helper(name = NULL, open = rlang::is_interactive()) +} +\arguments{ +\item{name}{Can be used to specify the optional "SLUG" in +\code{tests/testthat/helper-SLUG.R}.} + +\item{open}{Whether to open the file for interactive editing.} +} +\description{ +This function creates (or opens) a test helper file, typically +\code{tests/testthat/helper.R}. Test helper files are executed at the +beginning of every automated test run and are also executed by +\code{\link[pkgload:load_all]{load_all()}}. A helper file is a great place to +define test helper functions for use throughout your test suite, such as +a custom expectation. +} +\examples{ +\dontrun{ +use_test_helper() +use_test_helper("mocks") +} +} +\seealso{ +\itemize{ +\item \code{\link[=use_test]{use_test()}} to create a test file. +\item The testthat vignette on special files +\code{vignette("special-files", package = "testthat")}. +} +} diff --git a/man/use_tidy_eval.Rd b/man/use_tidy_eval.Rd new file mode 100644 index 000000000..f6718b83d --- /dev/null +++ b/man/use_tidy_eval.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/usethis-deprecated.R +\name{use_tidy_eval} +\alias{use_tidy_eval} +\title{Deprecated tidyverse functions} +\usage{ +use_tidy_eval() +} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +\itemize{ +\item \code{use_tidy_eval()} is deprecated because there's no longer a need to +systematically import and re-export a large number of functions in order +to use tidy evaluation. Instead, use \code{\link[=use_import_from]{use_import_from()}} to tactically +import functions as you need them. +} +} +\keyword{internal} diff --git a/man/use_tidy_labels.Rd b/man/use_tidy_labels.Rd deleted file mode 100644 index 6cce8aca8..000000000 --- a/man/use_tidy_labels.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/usethis-defunct.R -\name{use_tidy_labels} -\alias{use_tidy_labels} -\alias{use_tidy_ci} -\alias{use_tidy_eval} -\title{Defunct tidyverse functions} -\usage{ -use_tidy_labels() - -use_tidy_ci(...) - -use_tidy_eval() -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#defunct}{\figure{lifecycle-defunct.svg}{options: alt='[Defunct]'}}}{\strong{[Defunct]}} -\itemize{ -\item \code{use_tidy_labels()} has been replaced by \code{\link[=use_tidy_github_labels]{use_tidy_github_labels()}}. -\item \code{use_tidy_ci()} has been replaced by \code{\link[=use_tidy_github_actions]{use_tidy_github_actions()}}. -\item \code{use_tidy_eval()} is defunct because there's no longer a need to -systematically import and re-export a large number of functions in order -to use tidy evaluation. Instead, use \code{\link[=use_import_from]{use_import_from()}} to tactically -import functions as you need them. -} -} -\keyword{internal} diff --git a/man/use_travis.Rd b/man/use_travis.Rd deleted file mode 100644 index ee1e5b08b..000000000 --- a/man/use_travis.Rd +++ /dev/null @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/usethis-defunct.R -\name{use_travis} -\alias{use_travis} -\alias{use_travis_badge} -\alias{use_pkgdown_travis} -\alias{use_appveyor} -\alias{use_appveyor_badge} -\alias{browse_travis} -\title{Defunct Travis and Appveyor functions} -\usage{ -use_travis(browse = rlang::is_interactive(), ext = c("com", "org")) - -use_travis_badge(ext = c("com", "org"), repo_spec = NULL) - -use_pkgdown_travis() - -use_appveyor(browse = rlang::is_interactive()) - -use_appveyor_badge(repo_spec = NULL) - -browse_travis(package = NULL, ext = c("com", "org")) -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#defunct}{\figure{lifecycle-defunct.svg}{options: alt='[Defunct]'}}}{\strong{[Defunct]}} - -These functions which formally supported CI on Appveyor and Travis are -now defunct as we no longer recommend using these services. We now -recommend using GitHub actions, e.g. with \code{\link[=use_github_action]{use_github_action()}}. -} -\keyword{internal} diff --git a/man/zip-utils.Rd b/man/zip-utils.Rd index fbb0b7747..2e569ce3b 100644 --- a/man/zip-utils.Rd +++ b/man/zip-utils.Rd @@ -17,15 +17,15 @@ use_zip( \arguments{ \item{url}{Link to a ZIP file containing the materials. To reduce the chance of typos in live settings, these shorter forms are accepted: - -\if{html}{\out{
}}\preformatted{* GitHub repo spec: "OWNER/REPO". Equivalent to - `https://github.com/OWNER/REPO/DEFAULT_BRANCH.zip`. -* bit.ly or rstd.io shortlinks: "bit.ly/xxx-yyy-zzz" or "rstd.io/foofy". - The instructor must then arrange for the shortlink to point to a valid - download URL for the target ZIP file. The helper - [create_download_url()] helps to create such URLs for GitHub, DropBox, - and Google Drive. -}\if{html}{\out{
}}} +\itemize{ +\item GitHub repo spec: "OWNER/REPO". Equivalent to +\verb{https://github.com/OWNER/REPO/DEFAULT_BRANCH.zip}. +\item bit.ly or rstd.io shortlinks: "bit.ly/xxx-yyy-zzz" or "rstd.io/foofy". +The instructor must then arrange for the shortlink to point to a valid +download URL for the target ZIP file. The helper +\code{\link[=create_download_url]{create_download_url()}} helps to create such URLs for GitHub, DropBox, +and Google Drive. +}} \item{destdir}{Destination for the new folder. Defaults to the location stored in the global option \code{usethis.destdir}, if defined, or to the user's diff --git a/revdep/README.md b/revdep/README.md index 1ecf9100a..23b2f2eba 100644 --- a/revdep/README.md +++ b/revdep/README.md @@ -1,8 +1,16 @@ # Revdeps -## New problems (1) +## Failed to check (1) -|package |version |error |warning |note | -|:-------|:-------|:------|:-------|:----| -|[cffr](problems.md#cffr)|0.5.0 |__+1__ | | | +|package |version |error |warning |note | +|:-------|:-------|:-----|:-------|:----| +|scaper |0.1.0 |1 | | | + +## New problems (3) + +|package |version |error |warning |note | +|:---------------|:-------|:--------|:-------|:------| +|[circle](problems.md#circle)|0.7.2 |1 |__+1__ | | +|[exampletestr](problems.md#exampletestr)|1.7.1 |1 __+1__ | | | +|[pharmaverseadam](problems.md#pharmaverseadam)|1.0.0 | | |__+1__ | diff --git a/revdep/cran.md b/revdep/cran.md index 633030f13..3b19c4fbf 100644 --- a/revdep/cran.md +++ b/revdep/cran.md @@ -1,15 +1,24 @@ ## revdepcheck results -We checked 181 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. +We checked 217 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. - * We saw 1 new problems - * We failed to check 0 packages + * We saw 3 new problems + * We failed to check 1 packages Issues with CRAN packages are summarised below. ### New problems (This reports the first line of each new failure) -* cffr +* circle + checking dependencies in R code ... WARNING + +* exampletestr checking tests ... ERROR +* pharmaverseadam + checking installed package size ... NOTE + +### Failed to check + +* scaper (NA) diff --git a/revdep/problems.md b/revdep/problems.md index d9ef6a546..3051c2622 100644 --- a/revdep/problems.md +++ b/revdep/problems.md @@ -1,14 +1,55 @@ -# cffr +# circle
-* Version: 0.5.0 -* GitHub: https://github.com/ropensci/cffr -* Source code: https://github.com/cran/cffr -* Date/Publication: 2023-05-05 12:00:02 UTC -* Number of recursive dependencies: 71 +* Version: 0.7.2 +* GitHub: https://github.com/ropensci/circle +* Source code: https://github.com/cran/circle +* Date/Publication: 2022-08-24 07:50:02 UTC +* Number of recursive dependencies: 76 -Run `revdepcheck::cloud_details(, "cffr")` for more info +Run `revdepcheck::cloud_details(, "circle")` for more info + +
+ +## Newly broken + +* checking dependencies in R code ... WARNING + ``` + Missing or unexported object: ‘usethis::github_token’ + ``` + +## In both + +* checking running R code from vignettes ... ERROR + ``` + Errors in running code in vignettes: + when running code in ‘circle.Rmd’ + ... + + > knitr::opts_chunk$set(collapse = TRUE, comment = "#>") + + > knitr::include_graphics("../man/figures/user-key.png") + + When sourcing ‘circle.R’: + Error: Cannot find the file(s): "../man/figures/user-key.png" + Execution halted + + ‘circle.Rmd’ using ‘UTF-8’... failed + ‘tic.Rmd’ using ‘UTF-8’... OK + ``` + +# exampletestr + +
+ +* Version: 1.7.1 +* GitHub: https://github.com/rorynolan/exampletestr +* Source code: https://github.com/cran/exampletestr +* Date/Publication: 2023-06-11 03:10:02 UTC +* Number of recursive dependencies: 97 + +Run `revdepcheck::cloud_details(, "exampletestr")` for more info
@@ -16,23 +57,52 @@ Run `revdepcheck::cloud_details(, "cffr")` for more info * checking tests ... ERROR ``` + Running ‘spelling.R’ Running ‘testthat.R’ Running the tests in ‘tests/testthat.R’ failed. - Last 13 lines of output: - 'test-write_citation.R:46:3', 'test-write_citation.R:111:3' - - ══ Failed tests ════════════════════════════════════════════════════════════════ - ── Failure ('test-cff_to_bibtex.R:416:3'): Errors ────────────────────────────── - `b <- cff_to_bibtex("testthat")` produced warnings. + Complete output: + > library(testthat) + > library(exampletestr) + > + > get_os <- function() { + + sysinf <- Sys.info() + + if (!is.null(sysinf)) { + ... + 6. └─exampletestr:::extract_examples("detect", tempdir(check = TRUE)) + 7. └─usethis::local_project(path = pkg_dir, quiet = TRUE) + 8. └─usethis::proj_set(path = path, force = force) + 9. └─usethis:::ui_abort(...) + 10. └─cli::cli_abort(...) + 11. └─rlang::abort(...) - [ FAIL 1 | WARN 10 | SKIP 110 | PASS 311 ] - Deleting unused snapshots: - • write_bib/append.bib - • write_bib/ascii.bib - • write_bib/noext.bib - • write_citation/append - • write_citation/noext + [ FAIL 1 | WARN 0 | SKIP 0 | PASS 27 ] Error: Test failures Execution halted ``` +## In both + +* checking running R code from vignettes ... ERROR + ``` + Errors in running code in vignettes: + when running code in ‘one-file-at-a-time.Rmd’ + ... + > knitr::opts_knit$set(root.dir = paste0(tempdir(), + + "/", "tempkg")) + + > usethis::proj_set(".") + + When sourcing ‘one-file-at-a-time.R’: + Error: ✖ Path '/tmp/RtmpGIYvQt/file132af710168/vignettes/' does not appear to + ... + + When sourcing ‘whole-package.R’: + Error: ✖ Path '/tmp/RtmpauCurR/file133f1dd70a93/vignettes/' does not appear to + be inside a project or package. + ℹ Read more in the help for `usethis::proj_get()`. + Execution halted + + ‘one-file-at-a-time.Rmd’ using ‘UTF-8’... failed + ‘one-function-at-a-time.Rmd’ using ‘UTF-8’... OK + ‘whole-package.Rmd’ using ‘UTF-8’... failed + ``` diff --git a/tests/testthat/_snaps/badge.md b/tests/testthat/_snaps/badge.md index a212bab6b..9546db429 100644 --- a/tests/testthat/_snaps/badge.md +++ b/tests/testthat/_snaps/badge.md @@ -7,7 +7,7 @@ ! `stage` must be one of "experimental", "stable", "superseded", or "deprecated", not "eperimental". i Did you mean "experimental"? -# use_rscloud_badge() handles bad and good input +# use_posit_cloud_badge() handles bad and good input Code use_posit_cloud_badge() @@ -31,19 +31,3 @@ Error in `use_posit_cloud_badge()`: x `usethis::use_posit_cloud_badge()` requires a link to an existing Posit Cloud project of the form "https://posit.cloud/content/" or "https://posit.cloud/spaces//content/". ---- - - Code - use_rscloud_badge("https://rstudio.cloud/content/123") - Condition - Error in `use_posit_cloud_badge()`: - x `usethis::use_posit_cloud_badge()` requires a link to an existing Posit Cloud project of the form "https://posit.cloud/content/" or "https://posit.cloud/spaces//content/". - ---- - - Code - use_rscloud_badge("https://posit.cloud/project/123") - Condition - Error in `use_posit_cloud_badge()`: - x `usethis::use_posit_cloud_badge()` requires a link to an existing Posit Cloud project of the form "https://posit.cloud/content/" or "https://posit.cloud/spaces//content/". - diff --git a/tests/testthat/_snaps/coverage.md b/tests/testthat/_snaps/coverage.md index c849622be..df963ad75 100644 --- a/tests/testthat/_snaps/coverage.md +++ b/tests/testthat/_snaps/coverage.md @@ -8,6 +8,6 @@ i Badge link will only be printed to screen. [ ] Copy and paste the following lines into 'README': - [![Codecov test coverage](https://codecov.io/gh/OWNER/REPO/graph/badge.svg)](https://codecov.io/gh/OWNER/REPO) + [![Codecov test coverage](https://codecov.io/gh/OWNER/REPO/graph/badge.svg)](https://app.codecov.io/gh/OWNER/REPO) diff --git a/tests/testthat/_snaps/r.md b/tests/testthat/_snaps/r.md index 464dbb06f..f202815b0 100644 --- a/tests/testthat/_snaps/r.md +++ b/tests/testthat/_snaps/r.md @@ -1,3 +1,21 @@ +# use_test_helper() creates a helper file + + Code + use_test_helper(open = FALSE) + Condition + Error in `use_test_helper()`: + x Your package must use testthat to use a helper file. + Call `usethis::use_testthat()` to set up testthat. + +--- + + Code + use_test_helper("foo", open = FALSE) + Message + i Test helper files are executed at the start of all automated test runs. + i `devtools::load_all()` also sources test helper files. + [ ] Edit 'tests/testthat/helper-foo.R'. + # compute_name() errors if no RStudio Code diff --git a/tests/testthat/_snaps/usethis-defunct.md b/tests/testthat/_snaps/usethis-deprecated.md similarity index 91% rename from tests/testthat/_snaps/usethis-defunct.md rename to tests/testthat/_snaps/usethis-deprecated.md index 28fe75572..c752fb4d3 100644 --- a/tests/testthat/_snaps/usethis-defunct.md +++ b/tests/testthat/_snaps/usethis-deprecated.md @@ -1,4 +1,4 @@ -# use_tidy_eval() is defunct +# use_tidy_eval() is deprecated Code use_tidy_eval() diff --git a/tests/testthat/ref/README.Rmd b/tests/testthat/ref/README.Rmd index d02b4e6d4..d95bafab6 100644 --- a/tests/testthat/ref/README.Rmd +++ b/tests/testthat/ref/README.Rmd @@ -14,66 +14,169 @@ library(fs) ## Different styles of ZIP file -Examples based on foo folder found here. +usethis has an unexported function `tidy_unzip()`, which is used under the hood in `use_course()` and `use_zip()`. +It is a wrapper around `utils::unzip()` that uses some heuristics to choose a good value for `exdir`, which is the "the directory to extract files to." +Why do we do this? +Because it's really easy to _not_ get the desired result when unpacking a ZIP archive. + +Common aggravations: + +* Instead of the unpacked files being corraled within a folder, they explode as "loose parts" into the current working directory. Too little nesting. +* The unpacked files are contained in a folder, but that folder itself is contained inside another folder. Too much nesting. + +`tidy_unzip()` tries to get the nesting just right. + +Why doesn't unzipping "just work"? +Because the people who make `.zip` files make lots of different choices when they actually create the archive and these details aren't baked in, i.e. a successful roundtrip isn't automatic. +It usually requires some peeking inside the archive and adjusting the unpack options. + +This README documents specific `.zip` situations that we anticipate. + +## Explicit parent folder + +Consider the foo folder: ```{bash} tree foo ``` -### Not Loose Parts, a.k.a. GitHub style +Zip it up like so: + +```{bash, eval = FALSE} +zip -r foo-explicit-parent.zip foo/ +``` + +This is the type of ZIP file that we get from GitHub via links of the forms and . + +Inspect it in the shell: + +```{bash} +unzip -Z1 foo-explicit-parent.zip +``` + +Or from R: + +```{r} +foo_files <- unzip("foo-explicit-parent.zip", list = TRUE) +with( + foo_files, + data.frame(Name = Name, dirname = path_dir(Name), basename = path_file(Name)) +) +``` + +Note that the folder `foo/` is explicitly included and all of the files are contained in it (in this case, just one file). + +## Implicit parent folder + +Consider the foo folder: + +```{bash} +tree foo +``` -This is the structure of ZIP files yielded by GitHub via links of the forms and . +Zip it up like so: ```{bash, eval = FALSE} -zip -r foo-not-loose.zip foo/ +zip -r foo-implicit-parent.zip foo/* ``` -Notice that everything is packaged below one top-level directory. +Note the use of `foo/*`, as opposed to `foo` or `foo/`. +This type of ZIP file was reported in . +The example given there is . + +Inspect our small example in the shell: + +```{bash} +unzip -Z1 foo-implicit-parent.zip +``` + +Or from R: ```{r} -foo_not_loose_files <- unzip("foo-not-loose.zip", list = TRUE) +foo_files <- unzip("foo-implicit-parent.zip", list = TRUE) with( - foo_not_loose_files, + foo_files, data.frame(Name = Name, dirname = path_dir(Name), basename = path_file(Name)) ) ``` -### Loose Parts, the Regular Way +Note that `foo/` is not included and its (original) existence is just implicit in the relative path to, e.g., +`foo/file.txt`. + +Here's a similar look at the example from issue #1961: + +```bash +~/rrr/usethis/tests/testthat/ref % unzip -l ~/Downloads/Species\ v2.3.zip +Archive: /Users/jenny/Downloads/Species v2.3.zip + Length Date Time Name +--------- ---------- ----- ---- + 1241 04-27-2023 09:16 species_v2/label_encoder.txt +175187560 04-06-2023 15:13 species_v2/model_arch.pt +174953575 04-14-2023 12:28 species_v2/model_weights.pth +--------- ------- +350142376 3 files +``` + +Note also that the implicit parent folder `species_v2` is not the base of the ZIP file name `Species v2.3.zip`. -This is the structure of many ZIP files I've seen, just in general. +## No parent + +Consider the foo folder: + +```{bash} +tree foo +``` + +Zip it up like so: ```{bash, eval = FALSE} -cd foo -zip ../foo-loose-regular.zip * -cd .. +(cd foo && zip -r ../foo-no-parent.zip .) ``` -All the files are packaged in the ZIP archive as "loose parts", i.e. there is no explicit top-level directory. +Note that we are zipping everything in a folder from *inside* the folder. + +Inspect our small example in the shell: + +```{bash} +unzip -Z1 foo-no-parent.zip +``` + +Or from R: ```{r} -foo_loose_regular_files <- unzip("foo-loose-regular.zip", list = TRUE) +foo_files <- unzip("foo-no-parent.zip", list = TRUE) with( - foo_loose_regular_files, + foo_files, data.frame(Name = Name, dirname = path_dir(Name), basename = path_file(Name)) ) ``` -### Loose Parts, the DropBox Way +All the files are packaged in the ZIP archive as "loose parts", i.e. there is no explicit or implicit top-level directory. + +## No parent, the DropBox Variation This is the structure of ZIP files yielded by DropBox via links of this form . I can't figure out how to even do this with zip locally, so I had to create an example on DropBox and download it. Jim Hester reports it is possible with `archive::archive_write_files()`. -It's basically like the "loose parts" above, except it includes a spurious top-level directory `"/"`. +It's basically like the "no parent" example above, except it includes a spurious top-level directory `"/"`. + +Inspect our small example in the shell: + +```{bash} +unzip -Z1 foo-loose-dropbox.zip +``` + +Or from R: ```{r} # curl::curl_download( # "https://www.dropbox.com/sh/5qfvssimxf2ja58/AABz3zrpf-iPYgvQCgyjCVdKa?dl=1", # destfile = "foo-loose-dropbox.zip" # ) -foo_loose_dropbox_files <- unzip("foo-loose-dropbox.zip", list = TRUE) +foo_files <- unzip("foo-loose-dropbox.zip", list = TRUE) with( - foo_loose_dropbox_files, + foo_files, data.frame(Name = Name, dirname = path_dir(Name), basename = path_file(Name)) ) ``` @@ -87,43 +190,50 @@ mapname: conversion of failed inflating: file.txt ``` -So this is a pretty odd ZIP packing strategy. But we need to plan for it. +which indicates some tripping over the `/`. +Only `file.txt` is left behind. -## Subdirs only at top-level +This is a pretty odd ZIP packing strategy. But we need to plan for it. -Let's make sure we detect loose parts (or not) when the top-level has only directories, not files. +## Only subdirectories -Example based on the yo directory here: +For testing purposes, we also want an example where all the files are inside subdirectories. + +Examples based on the yo directory here: ```{bash} tree yo ``` -```{bash, eval = FALSE} -zip -r yo-not-loose.zip yo/ -``` - -```{r} -(yo_not_loose_files <- unzip("yo-not-loose.zip", list = TRUE)) -top_directory(yo_not_loose_files$Name) -``` +Zip it up, in all the usual ways: ```{bash, eval = FALSE} -cd yo -zip -r ../yo-loose-regular.zip * -cd .. +zip -r yo-explicit-parent.zip yo/ +zip -r yo-implicit-parent.zip yo/* +(cd yo && zip -r ../yo-no-parent.zip .) ``` -```{r} -(yo_loose_regular_files <- unzip("yo-loose-regular.zip", list = TRUE)) -top_directory(yo_loose_regular_files$Name) -``` +Again, I couldn't create the DropBox variant locally, so I did it by downloading from DropBox. -```{r} +```{r eval = FALSE} # curl::curl_download( # "https://www.dropbox.com/sh/afydxe6pkpz8v6m/AADHbMZAaW3IQ8zppH9mjNsga?dl=1", # destfile = "yo-loose-dropbox.zip" # ) -(yo_loose_dropbox_files <- unzip("yo-loose-dropbox.zip", list = TRUE)) -top_directory(yo_loose_dropbox_files$Name) +``` + +Inspect each in the shell: + +```{bash} +unzip -Z1 yo-explicit-parent.zip +``` + +```{bash} +unzip -Z1 yo-implicit-parent.zip +``` +```{bash} +unzip -Z1 yo-no-parent.zip +``` +```{bash} +unzip -Z1 yo-loose-dropbox.zip ``` diff --git a/tests/testthat/ref/README.md b/tests/testthat/ref/README.md index cc301f187..b25b9c00e 100644 --- a/tests/testthat/ref/README.md +++ b/tests/testthat/ref/README.md @@ -4,39 +4,72 @@ ZIP file structures ``` r devtools::load_all("~/rrr/usethis") #> ℹ Loading usethis -#> x unloadNamespace("usethis") failed because another loaded package needs it -#> ℹ Forcing unload. If you encounter problems, please restart R. library(fs) ``` ## Different styles of ZIP file -Examples based on foo folder found here. +usethis has an unexported function `tidy_unzip()`, which is used under +the hood in `use_course()` and `use_zip()`. It is a wrapper around +`utils::unzip()` that uses some heuristics to choose a good value for +`exdir`, which is the “the directory to extract files to.” Why do we do +this? Because it’s really easy to *not* get the desired result when +unpacking a ZIP archive. + +Common aggravations: + +- Instead of the unpacked files being corraled within a folder, they + explode as “loose parts” into the current working directory. Too + little nesting. +- The unpacked files are contained in a folder, but that folder itself + is contained inside another folder. Too much nesting. + +`tidy_unzip()` tries to get the nesting just right. + +Why doesn’t unzipping “just work”? Because the people who make `.zip` +files make lots of different choices when they actually create the +archive and these details aren’t baked in, i.e. a successful roundtrip +isn’t automatic. It usually requires some peeking inside the archive and +adjusting the unpack options. + +This README documents specific `.zip` situations that we anticipate. + +## Explicit parent folder + +Consider the foo folder: ``` bash tree foo -#> foo +#> foo #> └── file.txt -#> -#> 0 directories, 1 file +#> +#> 1 directory, 1 file +``` + +Zip it up like so: + +``` bash +zip -r foo-explicit-parent.zip foo/ ``` -### Not Loose Parts, a.k.a. GitHub style +This is the type of ZIP file that we get from GitHub via links of the +forms and +. -This is the structure of ZIP files yielded by GitHub via links of the -forms and -. +Inspect it in the shell: ``` bash -zip -r foo-not-loose.zip foo/ +unzip -Z1 foo-explicit-parent.zip +#> foo/ +#> foo/file.txt ``` -Notice that everything is packaged below one top-level directory. +Or from R: ``` r -foo_not_loose_files <- unzip("foo-not-loose.zip", list = TRUE) +foo_files <- unzip("foo-explicit-parent.zip", list = TRUE) with( - foo_not_loose_files, + foo_files, data.frame(Name = Name, dirname = path_dir(Name), basename = path_file(Name)) ) #> Name dirname basename @@ -44,30 +77,115 @@ with( #> 2 foo/file.txt foo file.txt ``` -### Loose Parts, the Regular Way +Note that the folder `foo/` is explicitly included and all of the files +are contained in it (in this case, just one file). + +## Implicit parent folder -This is the structure of many ZIP files I’ve seen, just in general. +Consider the foo folder: ``` bash -cd foo -zip ../foo-loose-regular.zip * -cd .. +tree foo +#> foo +#> └── file.txt +#> +#> 1 directory, 1 file ``` -All the files are packaged in the ZIP archive as “loose parts”, -i.e. there is no explicit top-level directory. +Zip it up like so: + +``` bash +zip -r foo-implicit-parent.zip foo/* +``` + +Note the use of `foo/*`, as opposed to `foo` or `foo/`. This type of ZIP +file was reported in . The +example given there is +. + +Inspect our small example in the shell: + +``` bash +unzip -Z1 foo-implicit-parent.zip +#> foo/file.txt +``` + +Or from R: + +``` r +foo_files <- unzip("foo-implicit-parent.zip", list = TRUE) +with( + foo_files, + data.frame(Name = Name, dirname = path_dir(Name), basename = path_file(Name)) +) +#> Name dirname basename +#> 1 foo/file.txt foo file.txt +``` + +Note that `foo/` is not included and its (original) existence is just +implicit in the relative path to, e.g., `foo/file.txt`. + +Here’s a similar look at the example from issue \#1961: + +``` bash +~/rrr/usethis/tests/testthat/ref % unzip -l ~/Downloads/Species\ v2.3.zip +Archive: /Users/jenny/Downloads/Species v2.3.zip + Length Date Time Name +--------- ---------- ----- ---- + 1241 04-27-2023 09:16 species_v2/label_encoder.txt +175187560 04-06-2023 15:13 species_v2/model_arch.pt +174953575 04-14-2023 12:28 species_v2/model_weights.pth +--------- ------- +350142376 3 files +``` + +Note also that the implicit parent folder `species_v2` is not the base +of the ZIP file name `Species v2.3.zip`. + +## No parent + +Consider the foo folder: + +``` bash +tree foo +#> foo +#> └── file.txt +#> +#> 1 directory, 1 file +``` + +Zip it up like so: + +``` bash +(cd foo && zip -r ../foo-no-parent.zip .) +``` + +Note that we are zipping everything in a folder from *inside* the +folder. + +Inspect our small example in the shell: + +``` bash +unzip -Z1 foo-no-parent.zip +#> file.txt +``` + +Or from R: ``` r -foo_loose_regular_files <- unzip("foo-loose-regular.zip", list = TRUE) +foo_files <- unzip("foo-no-parent.zip", list = TRUE) with( - foo_loose_regular_files, + foo_files, data.frame(Name = Name, dirname = path_dir(Name), basename = path_file(Name)) ) #> Name dirname basename #> 1 file.txt . file.txt ``` -### Loose Parts, the DropBox Way +All the files are packaged in the ZIP archive as “loose parts”, +i.e. there is no explicit or implicit top-level directory. + +## No parent, the DropBox Variation This is the structure of ZIP files yielded by DropBox via links of this form . I can’t @@ -77,21 +195,31 @@ with `archive::archive_write_files()`. -It’s basically like the “loose parts” above, except it includes a +It’s basically like the “no parent” example above, except it includes a spurious top-level directory `"/"`. +Inspect our small example in the shell: + +``` bash +unzip -Z1 foo-loose-dropbox.zip +#> / +#> file.txt +``` + +Or from R: + ``` r # curl::curl_download( # "https://www.dropbox.com/sh/5qfvssimxf2ja58/AABz3zrpf-iPYgvQCgyjCVdKa?dl=1", # destfile = "foo-loose-dropbox.zip" # ) -foo_loose_dropbox_files <- unzip("foo-loose-dropbox.zip", list = TRUE) +foo_files <- unzip("foo-loose-dropbox.zip", list = TRUE) with( - foo_loose_dropbox_files, + foo_files, data.frame(Name = Name, dirname = path_dir(Name), basename = path_file(Name)) ) #> Name dirname basename -#> 1 / / +#> 1 / / #> 2 file.txt . file.txt ``` @@ -103,72 +231,79 @@ result: mapname: conversion of failed inflating: file.txt -So this is a pretty odd ZIP packing strategy. But we need to plan for -it. +which indicates some tripping over the `/`. Only `file.txt` is left +behind. + +This is a pretty odd ZIP packing strategy. But we need to plan for it. -## Subdirs only at top-level +## Only subdirectories -Let’s make sure we detect loose parts (or not) when the top-level has -only directories, not files. +For testing purposes, we also want an example where all the files are +inside subdirectories. -Example based on the yo directory here: +Examples based on the yo directory here: ``` bash tree yo -#> yo -#> ├── subdir1 +#> yo +#> ├── subdir1 #> │   └── file1.txt -#> └── subdir2 +#> └── subdir2 #> └── file2.txt -#> -#> 2 directories, 2 files +#> +#> 3 directories, 2 files ``` +Zip it up, in all the usual ways: + ``` bash -zip -r yo-not-loose.zip yo/ +zip -r yo-explicit-parent.zip yo/ +zip -r yo-implicit-parent.zip yo/* +(cd yo && zip -r ../yo-no-parent.zip .) ``` +Again, I couldn’t create the DropBox variant locally, so I did it by +downloading from DropBox. + ``` r -(yo_not_loose_files <- unzip("yo-not-loose.zip", list = TRUE)) -#> Name Length Date -#> 1 yo/ 0 2018-01-11 15:48:00 -#> 2 yo/subdir1/ 0 2018-01-11 15:48:00 -#> 3 yo/subdir1/file1.txt 42 2018-01-11 15:48:00 -#> 4 yo/subdir2/ 0 2018-01-11 15:49:00 -#> 5 yo/subdir2/file2.txt 42 2018-01-11 15:49:00 -top_directory(yo_not_loose_files$Name) -#> [1] "yo/" +# curl::curl_download( +# "https://www.dropbox.com/sh/afydxe6pkpz8v6m/AADHbMZAaW3IQ8zppH9mjNsga?dl=1", +# destfile = "yo-loose-dropbox.zip" +# ) ``` +Inspect each in the shell: + ``` bash -cd yo -zip -r ../yo-loose-regular.zip * -cd .. +unzip -Z1 yo-explicit-parent.zip +#> yo/ +#> yo/subdir2/ +#> yo/subdir2/file2.txt +#> yo/subdir1/ +#> yo/subdir1/file1.txt ``` -``` r -(yo_loose_regular_files <- unzip("yo-loose-regular.zip", list = TRUE)) -#> Name Length Date -#> 1 subdir1/ 0 2018-01-11 15:48:00 -#> 2 subdir1/file1.txt 42 2018-01-11 15:48:00 -#> 3 subdir2/ 0 2018-01-11 15:49:00 -#> 4 subdir2/file2.txt 42 2018-01-11 15:49:00 -top_directory(yo_loose_regular_files$Name) -#> [1] NA +``` bash +unzip -Z1 yo-implicit-parent.zip +#> yo/subdir1/ +#> yo/subdir1/file1.txt +#> yo/subdir2/ +#> yo/subdir2/file2.txt ``` -``` r -# curl::curl_download( -# "https://www.dropbox.com/sh/afydxe6pkpz8v6m/AADHbMZAaW3IQ8zppH9mjNsga?dl=1", -# destfile = "yo-loose-dropbox.zip" -# ) -(yo_loose_dropbox_files <- unzip("yo-loose-dropbox.zip", list = TRUE)) -#> Name Length Date -#> 1 / 0 2018-01-11 23:57:00 -#> 2 subdir1/file1.txt 42 2018-01-11 23:57:00 -#> 3 subdir2/file2.txt 42 2018-01-11 23:57:00 -#> 4 subdir1/ 0 2018-01-11 23:57:00 -#> 5 subdir2/ 0 2018-01-11 23:57:00 -top_directory(yo_loose_dropbox_files$Name) -#> [1] NA +``` bash +unzip -Z1 yo-no-parent.zip +#> subdir2/ +#> subdir2/file2.txt +#> subdir1/ +#> subdir1/file1.txt +``` + +``` bash +unzip -Z1 yo-loose-dropbox.zip +#> / +#> subdir1/file1.txt +#> subdir2/file2.txt +#> subdir1/ +#> subdir2/ ``` diff --git a/tests/testthat/ref/foo-explicit-parent.zip b/tests/testthat/ref/foo-explicit-parent.zip new file mode 100644 index 000000000..ac7c2abd2 Binary files /dev/null and b/tests/testthat/ref/foo-explicit-parent.zip differ diff --git a/tests/testthat/ref/foo-implicit-parent.zip b/tests/testthat/ref/foo-implicit-parent.zip new file mode 100644 index 000000000..0c0a13431 Binary files /dev/null and b/tests/testthat/ref/foo-implicit-parent.zip differ diff --git a/tests/testthat/ref/foo-loose-regular.zip b/tests/testthat/ref/foo-loose-regular.zip deleted file mode 100644 index 92e8cc752..000000000 Binary files a/tests/testthat/ref/foo-loose-regular.zip and /dev/null differ diff --git a/tests/testthat/ref/foo-no-parent.zip b/tests/testthat/ref/foo-no-parent.zip new file mode 100644 index 000000000..11756785f Binary files /dev/null and b/tests/testthat/ref/foo-no-parent.zip differ diff --git a/tests/testthat/ref/foo-not-loose.zip b/tests/testthat/ref/foo-not-loose.zip deleted file mode 100644 index 25c6ee63b..000000000 Binary files a/tests/testthat/ref/foo-not-loose.zip and /dev/null differ diff --git a/tests/testthat/ref/yo-explicit-parent.zip b/tests/testthat/ref/yo-explicit-parent.zip new file mode 100644 index 000000000..5691b075a Binary files /dev/null and b/tests/testthat/ref/yo-explicit-parent.zip differ diff --git a/tests/testthat/ref/yo-implicit-parent.zip b/tests/testthat/ref/yo-implicit-parent.zip new file mode 100644 index 000000000..853ad1ee2 Binary files /dev/null and b/tests/testthat/ref/yo-implicit-parent.zip differ diff --git a/tests/testthat/ref/yo-loose-regular.zip b/tests/testthat/ref/yo-loose-regular.zip deleted file mode 100644 index cbf566165..000000000 Binary files a/tests/testthat/ref/yo-loose-regular.zip and /dev/null differ diff --git a/tests/testthat/ref/yo-no-parent.zip b/tests/testthat/ref/yo-no-parent.zip new file mode 100644 index 000000000..24a7b8565 Binary files /dev/null and b/tests/testthat/ref/yo-no-parent.zip differ diff --git a/tests/testthat/ref/yo-not-loose.zip b/tests/testthat/ref/yo-not-loose.zip deleted file mode 100644 index 5681a0cc7..000000000 Binary files a/tests/testthat/ref/yo-not-loose.zip and /dev/null differ diff --git a/tests/testthat/test-badge.R b/tests/testthat/test-badge.R index e90d05f56..6c9b8057d 100644 --- a/tests/testthat/test-badge.R +++ b/tests/testthat/test-badge.R @@ -21,27 +21,13 @@ test_that("use_binder_badge() needs a github repository", { expect_error(use_binder_badge(), class = "usethis_error_bad_github_remote_config") }) -test_that("use_rscloud_badge() handles bad and good input", { +test_that("use_posit_cloud_badge() handles bad and good input", { create_local_project() expect_snapshot(use_posit_cloud_badge(), error = TRUE) expect_snapshot(use_posit_cloud_badge(123), error = TRUE) expect_snapshot(use_posit_cloud_badge("http://posit.cloud/123"), error = TRUE) expect_no_error(use_posit_cloud_badge("https://posit.cloud/content/123")) expect_no_error(use_posit_cloud_badge("https://posit.cloud/spaces/123/content/123")) - - lifecycle::expect_deprecated( - use_rscloud_badge("https://posit.cloud/spaces/123/content/123") - ) - - withr::local_options(lifecycle_verbosity = "quiet") - expect_snapshot( - use_rscloud_badge("https://rstudio.cloud/content/123"), - error = TRUE - ) - expect_snapshot( - use_rscloud_badge("https://posit.cloud/project/123"), - error = TRUE - ) }) test_that("use_badge() does nothing if badge seems to pre-exist", { diff --git a/tests/testthat/test-course.R b/tests/testthat/test-course.R index 0dff96f88..987a64fbb 100644 --- a/tests/testthat/test-course.R +++ b/tests/testthat/test-course.R @@ -83,27 +83,121 @@ test_that("tidy_download() works", { ## tidy_unzip ---- -test_that("tidy_unzip() deals with loose parts, reports unpack destination", { - tmp <- file_temp(ext = ".zip") - fs::file_copy(test_file("yo-loose-regular.zip"), tmp) - dest <- tidy_unzip(tmp) - loose_regular_files <- fs::path_file(fs::dir_ls(dest, recurse = TRUE)) - fs::dir_delete(dest) - - tmp <- file_temp(ext = ".zip") - fs::file_copy(test_file("yo-loose-dropbox.zip"), tmp) - dest <- tidy_unzip(tmp) - loose_dropbox_files <- fs::path_file(fs::dir_ls(dest, recurse = TRUE)) - fs::dir_delete(dest) - - tmp <- file_temp(ext = ".zip") - fs::file_copy(test_file("yo-not-loose.zip"), tmp) - dest <- tidy_unzip(tmp) - not_loose_files <- fs::path_file(fs::dir_ls(dest, recurse = TRUE)) - fs::dir_delete(dest) - - expect_identical(loose_regular_files, loose_dropbox_files) - expect_identical(loose_dropbox_files, not_loose_files) +test_that("tidy_unzip(): explicit parent, file example", { + local_interactive(FALSE) + + zipfile <- withr::local_tempfile(fileext = ".zip") + file_copy(test_file("foo-explicit-parent.zip"), zipfile) + dest <- tidy_unzip(zipfile) + withr::defer(dir_delete(dest)) + expect_equal(path_file(dest), "foo") + + explicit_parent_files <- path_file(dir_ls(dest, recurse = TRUE)) + expect_equal(explicit_parent_files, "file.txt") +}) + +test_that("tidy_unzip(): explicit parent, folders example", { + local_interactive(FALSE) + files <- c("subdir1", "file1.txt", "subdir2", "file2.txt") + + zipfile <- withr::local_tempfile(fileext = ".zip") + file_copy(test_file("yo-explicit-parent.zip"), zipfile) + dest <- tidy_unzip(zipfile) + withr::defer(dir_delete(dest)) + expect_equal(path_file(dest), "yo") + + explicit_parent_files <- path_file(dir_ls(dest, recurse = TRUE)) + expect_setequal(explicit_parent_files, files) +}) + +test_that("tidy_unzip(): implicit parent, file example", { + local_interactive(FALSE) + + zipfile <- withr::local_tempfile(fileext = ".zip") + file_copy(test_file("foo-implicit-parent.zip"), zipfile) + dest <- tidy_unzip(zipfile) + withr::defer(dir_delete(dest)) + expect_equal(path_file(dest), "foo") + + implicit_parent_files <- path_file(dir_ls(dest, recurse = TRUE)) + expect_equal(implicit_parent_files, "file.txt") +}) + +test_that("tidy_unzip(): implicit parent, folders example", { + local_interactive(FALSE) + files <- c("subdir1", "file1.txt", "subdir2", "file2.txt") + + zipfile <- withr::local_tempfile(fileext = ".zip") + file_copy(test_file("yo-implicit-parent.zip"), zipfile) + dest <- tidy_unzip(zipfile) + withr::defer(dir_delete(dest)) + expect_equal(path_file(dest), "yo") + + implicit_parent_files <- path_file(dir_ls(dest, recurse = TRUE)) + expect_setequal(implicit_parent_files, files) +}) + +test_that("tidy_unzip(): no parent, file example", { + local_interactive(FALSE) + + zipfile <- withr::local_tempfile(fileext = ".zip") + file_copy(test_file("foo-no-parent.zip"), zipfile) + dest <- tidy_unzip(zipfile) + withr::defer(dir_delete(dest)) + expect_equal(path_file(dest), path_ext_remove(path_file(zipfile))) + + no_parent_files <- path_file(dir_ls(dest, recurse = TRUE)) + expect_setequal(no_parent_files, "file.txt") +}) + +test_that("tidy_unzip(): no parent, folders example", { + local_interactive(FALSE) + files <- c("subdir1", "file1.txt", "subdir2", "file2.txt") + + zipfile <- withr::local_tempfile(fileext = ".zip") + file_copy(test_file("yo-no-parent.zip"), zipfile) + dest <- tidy_unzip(zipfile) + withr::defer(dir_delete(dest)) + expect_equal(path_file(dest), path_ext_remove(path_file(zipfile))) + + no_parent_files <- path_file(dir_ls(dest, recurse = TRUE)) + expect_setequal(no_parent_files, files) +}) + +test_that("tidy_unzip(): DropBox, file example", { + local_interactive(FALSE) + + zipfile <- withr::local_tempfile(fileext = ".zip") + file_copy(test_file("foo-loose-dropbox.zip"), zipfile) + dest <- tidy_unzip(zipfile) + withr::defer(dir_delete(dest)) + expect_equal(path_file(dest), path_ext_remove(path_file(zipfile))) + + loose_dropbox_files <- path_file(dir_ls(dest, recurse = TRUE)) + expect_setequal(loose_dropbox_files, "file.txt") +}) + +test_that("tidy_unzip(): DropBox, folders example", { + local_interactive(FALSE) + files <- c("subdir1", "file1.txt", "subdir2", "file2.txt") + + zipfile <- withr::local_tempfile(fileext = ".zip") + file_copy(test_file("yo-loose-dropbox.zip"), zipfile) + dest <- tidy_unzip(zipfile) + withr::defer(dir_delete(dest)) + expect_equal(path_file(dest), path_ext_remove(path_file(zipfile))) + + loose_dropbox_files <- path_file(dir_ls(dest, recurse = TRUE)) + expect_setequal(loose_dropbox_files, files) +}) + +test_that("path_before_slash() works", { + expect_equal(path_before_slash(""), "") + expect_equal(path_before_slash("/"), "") + expect_equal(path_before_slash("a/"), "a") + expect_equal(path_before_slash("a/b"), "a") + expect_equal(path_before_slash("a/b/c"), "a") + expect_equal(path_before_slash("a/b/c/"), "a") }) ## helpers ---- @@ -260,15 +354,3 @@ test_that("keep_lgl() keeps and drops correct files", { ) expect_false(any(keep_lgl(droppers))) }) - -test_that("top_directory() identifies a unique top directory (or not)", { - ## there is >= 1 file at top-level or >1 directories - expect_identical(top_directory("a"), NA_character_) - expect_identical(top_directory(c("a/", "b")), NA_character_) - expect_identical(top_directory(c("a/", "b/")), NA_character_) - - ## there are no files at top-level and exactly 1 directory - expect_identical(top_directory("a/"), "a/") - expect_identical(top_directory(c("a/", "a/b")), "a/") - expect_identical(top_directory(c("a/", "a/b", "a/c")), "a/") -}) diff --git a/tests/testthat/test-cpp11.R b/tests/testthat/test-cpp11.R index 880484adb..3dec88b61 100644 --- a/tests/testthat/test-cpp11.R +++ b/tests/testthat/test-cpp11.R @@ -7,17 +7,16 @@ test_that("use_cpp11() requires a package", { test_that("use_cpp11() creates files/dirs, edits DESCRIPTION and .gitignore", { create_local_package() use_roxygen_md() + use_package_doc() # needed for use_cpp11() local_interactive(FALSE) local_check_installed() local_mocked_bindings(check_cpp_register_deps = function() invisible()) use_cpp11() - - deps <- proj_deps() - expect_equal(deps$type, "LinkingTo") - expect_equal(deps$package, "cpp11") + expect_match(desc::desc_get("LinkingTo"), "cpp11") expect_proj_dir("src") + expect_proj_file("src", "code.cpp") ignores <- read_utf8(proj_path("src", ".gitignore")) expect_contains(ignores, c("*.o", "*.so", "*.dll")) diff --git a/tests/testthat/test-r.R b/tests/testthat/test-r.R index 003dfe9af..6839f088f 100644 --- a/tests/testthat/test-r.R +++ b/tests/testthat/test-r.R @@ -10,9 +10,28 @@ test_that("use_test() creates a test file", { expect_proj_file("tests", "testthat", "test-foo.R") }) +test_that("use_test_helper() creates a helper file", { + create_local_package() + + expect_snapshot( + error = TRUE, + use_test_helper(open = FALSE) + ) + use_testthat() + + use_test_helper(open = FALSE) + withr::local_options(list(usethis.quiet = FALSE)) + expect_snapshot( + use_test_helper("foo", open = FALSE) + ) + + expect_proj_file("tests", "testthat", "helper.R") + expect_proj_file("tests", "testthat", "helper-foo.R") +}) + test_that("can use use_test() in a project", { create_local_project() - expect_error(use_test("foofy"), NA) + expect_no_error(use_test("foofy")) }) # helpers ----------------------------------------------------------------- @@ -75,3 +94,13 @@ test_that("compute_active_name() standardises name", { test_that("compute_name() accepts the declared extension", { expect_equal(compute_name("foo.cpp", ext = "cpp"), "foo.cpp") }) + +test_that("as_test_helper_file() works", { + expect_equal(as_test_helper_file(), "helper.R") + expect_equal(as_test_helper_file("helper"), "helper.R") + expect_equal(as_test_helper_file("helper.R"), "helper.R") + expect_equal(as_test_helper_file("stuff"), "helper-stuff.R") + expect_equal(as_test_helper_file("helper-stuff"), "helper-stuff.R") + expect_equal(as_test_helper_file("stuff.R"), "helper-stuff.R") + expect_equal(as_test_helper_file("helper-stuff.R"), "helper-stuff.R") +}) diff --git a/tests/testthat/test-usethis-defunct.R b/tests/testthat/test-usethis-deprecated.R similarity index 72% rename from tests/testthat/test-usethis-defunct.R rename to tests/testthat/test-usethis-deprecated.R index c1612661b..4b385372c 100644 --- a/tests/testthat/test-usethis-defunct.R +++ b/tests/testthat/test-usethis-deprecated.R @@ -1,7 +1,6 @@ -test_that("use_tidy_eval() is defunct", { +test_that("use_tidy_eval() is deprecated", { skip_if_not_installed("roxygen2") pkg <- create_local_package() expect_snapshot(use_tidy_eval(), error = TRUE) }) -