diff --git a/.github/SUPPORT.md b/.github/SUPPORT.md index a4c20da3b..bc76075c8 100644 --- a/.github/SUPPORT.md +++ b/.github/SUPPORT.md @@ -7,7 +7,7 @@ Before filing an issue, there are a few places to explore and pieces to put toge Start by making a minimal **repr**oducible **ex**ample using the [reprex](https://reprex.tidyverse.org/) package. If you haven't heard of or used reprex before, you're in for a treat! -Seriously, reprex will make all of your R-question-asking endeavors easier (which is a pretty insane ROI for the five to ten minutes it'll take you to learn what it's all about). +Seriously, reprex will make all of your R-question-asking endeavors easier (which is a pretty incredible ROI for the five to ten minutes it'll take you to learn what it's all about). For additional reprex pointers, check out the [Get help!](https://www.tidyverse.org/help/) section of the tidyverse site. ## Where to ask? diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index ee65ccb57..736d83bca 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -57,6 +57,14 @@ jobs: extra-packages: any::rcmdcheck needs: check + - name: git config + if: matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release' + run: | + git config --global user.name "$GITHUB_ACTOR" + git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com" + - uses: r-lib/actions/check-r-package@v2 + env: + _R_CALLS_INVALID_NUMERIC_VERSION_: true with: upload-snapshots: true diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 2c5bb5029..c71d42547 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -26,6 +26,11 @@ jobs: extra-packages: any::covr needs: coverage + - name: git config + run: | + git config --global user.name "$GITHUB_ACTOR" + git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com" + - name: Test coverage run: | covr::codecov( diff --git a/DESCRIPTION b/DESCRIPTION index 6c59771a9..7b5ac9a67 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: usethis Title: Automate Package and Project Setup -Version: 2.2.0.9001 +Version: 2.2.2.9000 Authors@R: c( person("Hadley", "Wickham", , "hadley@posit.co", role = "aut", comment = c(ORCID = "0000-0003-4757-117X")), @@ -47,7 +47,7 @@ Suggests: covr, knitr, magick, - pkgload, + pkgload (>= 1.3.2.1), rmarkdown, roxygen2 (>= 7.1.2), spelling (>= 1.2), @@ -55,6 +55,8 @@ Suggests: testthat (>= 3.1.8) Config/Needs/website: tidyverse/tidytemplate, xml2 Config/testthat/edition: 3 +Config/testthat/parallel: TRUE +Config/testthat/start-first: github-actions, release Encoding: UTF-8 Language: en-US Roxygen: list(markdown = TRUE) diff --git a/NAMESPACE b/NAMESPACE index 701d35d0f..bfee86ea9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -220,3 +220,4 @@ importFrom(purrr,map) importFrom(purrr,map_chr) importFrom(purrr,map_int) importFrom(purrr,map_lgl) +importFrom(utils,available.packages) diff --git a/NEWS.md b/NEWS.md index 0ec6596f2..37ffffc93 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,22 @@ # usethis (development version) +# usethis 2.2.2 + +* Implicit usage of `numeric_version()` via comparison now always provides + character input. This is in response to a request from CRAN to anticipate + future solutions to . + +# usethis 2.2.1 + +* Internal helper `cran_version()`, used in functions such as + `use_release_checklist()` and `use_news_md()`, is more resilient to situations + where no CRAN mirror has been set (#1857). + +* Internal usage of `numeric_version()` now always provides character input, + rather than relying on implicit `as.character()` coercion. This is in response + to a request from CRAN to anticipate future solutions to + (#1869). + # usethis 2.2.0 ## New functions diff --git a/R/cran.R b/R/cran.R index 6bca450ae..632e49706 100644 --- a/R/cran.R +++ b/R/cran.R @@ -13,7 +13,6 @@ use_cran_comments <- function(open = rlang::is_interactive()) { check_is_package("use_cran_comments()") use_template( "cran-comments.md", - data = list(rversion = glue("{version$major}.{version$minor}")), ignore = TRUE, open = open ) diff --git a/R/documentation.R b/R/documentation.R index 633f120ee..6900eb705 100644 --- a/R/documentation.R +++ b/R/documentation.R @@ -1,14 +1,26 @@ #' Package-level documentation #' -#' Adds a dummy `.R` file that will prompt roxygen to generate basic +#' Adds a dummy `.R` file that will cause roxygen2 to generate basic #' package-level documentation. If your package is named "foo", this will make #' help available to the user via `?foo` or `package?foo`. Once you call -#' `devtools::document()`, roxygen will flesh out the `.Rd` file using data from -#' the `DESCRIPTION`. That ensures you don't need to repeat the same information -#' in multiple places. This `.R` file is also a good place for roxygen -#' directives that apply to the whole package (vs. a specific function), such as -#' global namespace tags like `@importFrom`. +#' `devtools::document()`, roxygen2 will flesh out the `.Rd` file using data +#' from the `DESCRIPTION`. That ensures you don't need to repeat (and remember +#' to update!) the same information in multiple places. This `.R` file is also a +#' good place for roxygen directives that apply to the whole package (vs. a +#' specific function), such as global namespace tags like `@importFrom`. #' +#' There is one tricky case: when a **package** named "foo" also has a +#' **function** named `foo()`. In this case, after running `use_package_doc()`, +#' there will be an `R CMD check` warning. The solution is to set the `@aliases` +#' for the package-level help topic by modifying the dummy `.R` file (e.g., +#' `foo-package.R`) as shown below (but substitute the name of your package / +#' function for "foo"): +#' +#' ``` +#' #' @keywords internal +#' #' @aliases foo-package +#' #' "_PACKAGE" +#' ``` #' @seealso The [documentation chapter](https://r-pkgs.org/man.html) of [R #' Packages](https://r-pkgs.org) #' @inheritParams use_template diff --git a/R/git.R b/R/git.R index 91d59f52d..80681423d 100644 --- a/R/git.R +++ b/R/git.R @@ -506,7 +506,7 @@ default_branch_sitrep <- function() { #' Vaccinate your global gitignore file #' -#' Adds `.DS_Store`, `.Rproj.user`, `.Rdata`, `.Rhistory`, and `.httr-oauth` to +#' Adds `.Rproj.user`, `.Rhistory`, `.Rdata`, `.httr-oauth`, `.DS_Store`, and `.quarto` to #' your global (a.k.a. user-level) `.gitignore`. This is good practice as it #' decreases the chance that you will accidentally leak credentials to GitHub. #' `git_vaccinate()` also tries to detect and fix the situation where you have a diff --git a/R/r.R b/R/r.R index 7d559e570..40b7ffa77 100644 --- a/R/r.R +++ b/R/r.R @@ -78,7 +78,7 @@ compute_name <- function(name = NULL, ext = "R", error_call = caller_env()) { if (path_ext(name) == "") { name <- path_ext_set(name, ext) - } else if (path_ext(name) != "R") { + } else if (path_ext(name) != ext) { cli::cli_abort( "{.arg name} must have extension {.str {ext}}, not {.str {path_ext(name)}}.", call = error_call diff --git a/R/release.R b/R/release.R index f207acf4e..61302d6de 100644 --- a/R/release.R +++ b/R/release.R @@ -137,11 +137,11 @@ release_checklist <- function(version, on_cran) { "Wait for CRAN...", "", todo("Accepted :tada:"), - todo("Add preemptive link to blog post in pkgdown news menu", type != "patch"), + todo("Finish & publish blog post", type != "patch"), + todo("Add link to blog post in pkgdown news menu", type != "patch"), todo("`usethis::use_github_release()`"), todo("`usethis::use_dev_version(push = TRUE)`"), todo("`usethis::use_news_md()`", !has_news), - todo("Finish blog post", type != "patch"), todo("Tweet", type != "patch") ) } @@ -403,8 +403,23 @@ get_release_news <- function(SHA = gert::git_info(repo = git_repo())$commit, } } -cran_version <- function(package = project_name(), - available = utils::available.packages()) { +cran_version <- function(package = project_name(), available = NULL) { + + if (!curl::has_internet()) { + return(NULL) + } + + if (is.null(available)) { + # Guard against CRAN mirror being unset + available <- tryCatch( + available.packages(repos = default_cran_mirror()), + error = function(e) NULL + ) + if (is.null(available)) { + return(NULL) + } + } + idx <- available[, "Package"] == package if (any(idx)) { as.package_version(available[package, "Version"]) @@ -533,7 +548,18 @@ pkg_minimum_r_version <- function() { deps <- proj_desc()$get_deps() r_dep <- deps[deps$package == "R" & deps$type == "Depends", "version"] if (length(r_dep) == 0) { - return(numeric_version(0)) + return(numeric_version("0")) } numeric_version(gsub("[^0-9.]", "", r_dep)) } + +# Borrowed from pak, but modified also retain user's non-cran repos: +# https://github.com/r-lib/pak/blob/168ab5d58fc244e5084c2800c87b8a574d66c3ba/R/default-cran-mirror.R +default_cran_mirror <- function() { + repos <- getOption("repos") + cran <- repos["CRAN"] + if (is.null(cran) || is.na(cran) || cran == "@CRAN@") { + repos["CRAN"] <- "https://cloud.r-project.org" + } + repos +} diff --git a/R/upkeep.R b/R/upkeep.R index 97cb71bce..8c4171e1f 100644 --- a/R/upkeep.R +++ b/R/upkeep.R @@ -38,15 +38,20 @@ make_upkeep_issue <- function(year, tidy) { } } - checklist <- if (tidy) tidy_upkeep_checklist(year) else upkeep_checklist() + gh <- gh_tr(tr) + if (tidy) { + checklist <- tidy_upkeep_checklist(year, repo_spec = tr$repo_spec) + } else { + checklist <- upkeep_checklist() + } title_year <- year %||% format(Sys.Date(), "%Y") - gh <- gh_tr(tr) issue <- gh( "POST /repos/{owner}/{repo}/issues", title = glue("Upkeep for {project_name()} ({title_year})"), - body = paste0(checklist, "\n", collapse = "") + body = paste0(checklist, "\n", collapse = ""), + labels = if (tidy) list("upkeep") ) Sys.sleep(1) view_url(issue$html_url) @@ -118,7 +123,8 @@ use_tidy_upkeep_issue <- function(year = NULL) { tidy_upkeep_checklist <- function(year = NULL, posit_pkg = is_posit_pkg(), - posit_person_ok = is_posit_person_canonical()) { + posit_person_ok = is_posit_person_canonical(), + repo_spec = "OWNER/REPO") { year <- year %||% 2000 bullets <- c() @@ -126,7 +132,7 @@ tidy_upkeep_checklist <- function(year = NULL, if (year <= 2000) { bullets <- c( bullets, - "Pre-history", + "### Pre-history", "", todo("`usethis::use_readme_rmd()`"), todo("`usethis::use_roxygen_md()`"), @@ -134,7 +140,6 @@ tidy_upkeep_checklist <- function(year = NULL, todo("`usethis::use_pkgdown_github_pages()`"), todo("`usethis::use_tidy_github_labels()`"), todo("`usethis::use_tidy_style()`"), - todo("`usethis::use_tidy_description()`"), todo("`urlchecker::url_check()`"), "" ) @@ -142,62 +147,32 @@ tidy_upkeep_checklist <- function(year = NULL, if (year <= 2020) { bullets <- c( bullets, - "2020", + "### 2020", "", - todo(" - `usethis::use_package_doc()` - Consider letting usethis manage your `@importFrom` directives here. - `usethis::use_import_from()` is handy for this."), - todo(" - `usethis::use_testthat(3)` and upgrade to 3e, \\ - [testthat 3e vignette](https://testthat.r-lib.org/articles/third-edition.html)"), - todo(" - Align the names of `R/` files and `test/` files for workflow happiness. - The docs for `usethis::use_r()` include a helpful script. - `usethis::rename_files()` may be be useful."), + todo("`usethis::use_package_doc()`"), + todo("`usethis::use_testthat(3)`"), + todo("Align the names of `R/` files and `test/` files"), "" ) } if (year <= 2021) { bullets <- c( bullets, - "2021", + "### 2021", "", - todo("`usethis::use_tidy_description()`", year > 2000), - todo("`usethis::use_tidy_dependencies()`"), - todo(" - `usethis::use_tidy_github_actions()` and update artisanal actions to \\ - use `setup-r-dependencies`"), todo("Remove check environments section from `cran-comments.md`"), - todo("Bump required R version in DESCRIPTION to {tidy_minimum_r_version()}"), - todo(" - Use lifecycle instead of artisanal deprecation messages, as described \\ - in [Communicate lifecycle changes in your functions](https://lifecycle.r-lib.org/articles/communicate.html)"), - todo( - ' - Make sure RStudio appears in `Authors@R` of DESCRIPTION like so, if appropriate: - `person("RStudio", role = c("cph", "fnd"))`', - posit_pkg && !posit_person_ok - ), + todo("Use lifecycle instead of artisanal deprecation messages"), "" ) } if (year <= 2022) { bullets <- c( bullets, - "2022", + "### 2022", "", - todo("`usethis::use_tidy_coc()`"), todo("Handle and close any still-open `master` --> `main` issues"), - todo("Update README badges, instructions in [r-lib/usethis#1594](https://github.com/r-lib/usethis/issues/1594)"), - todo(" - Update errors to rlang 1.0.0. Helpful guides: - - - "), + todo('`usethis:::use_codecov_badge("{repo_spec}")`'), todo("Update pkgdown site using instructions at "), - todo("Ensure pkgdown `development` is `mode: auto` in pkgdown config"), - todo("Re-publish released site; see [How to update a released site](https://pkgdown.r-lib.org/dev/articles/how-to-update-released-site.html)"), todo("Update lifecycle badges with more accessible SVGs: `usethis::use_lifecycle()`"), "" ) @@ -208,64 +183,66 @@ tidy_upkeep_checklist <- function(year = NULL, bullets <- c( bullets, - "2023", - "", - "Necessary:", + "### 2023", "", todo( - "Update email addresses *@rstudio.com -> *@posit.co", + " + Update email addresses *@rstudio.com -> *@posit.co", author_has_rstudio_email() ), todo( ' Update copyright holder in DESCRIPTION: \\ - `person(given = "Posit Software, PBC", role = c("cph", "fnd"))`', + `person("Posit Software, PBC", role = c("cph", "fnd"))`', posit_pkg && !posit_person_ok ), todo( " - `Run devtools::document()` to re-generate package-level help topic \\ + Run `devtools::document()` to re-generate package-level help topic \\ with DESCRIPTION changes", author_has_rstudio_email() || (posit_pkg && !posit_person_ok) ), - todo( - " - Double check license file uses '[package] authors' \\ - as copyright holder. Run `use_mit_license()`", - grepl("MIT", desc$get_field("License")) - ), - todo(" - Update logo (https://github.com/rstudio/hex-stickers); \\ - run `use_tidy_logo()`"), + todo("`usethis::use_tidy_logo()`"), todo("`usethis::use_tidy_coc()`"), todo( "Modernize citation files; see updated `use_citation()`", has_citation_file() ), - todo("`usethis::use_tidy_github_actions()`"), - "", - "Optional:", - "", - todo("Review 2022 checklist to see if you completed the pkgdown updates"), - todo('Prefer `pak::pak("org/pkg")` over `devtools::install_github("org/pkg")` in README'), + todo('Use `pak::pak("{repo_spec}")` in README'), todo(" - Consider running `use_tidy_dependencies()` and/or \\ + Consider running `usethis::use_tidy_dependencies()` and/or \\ replace compat files with `use_standalone()`"), + todo("Use cli errors or [file an issue](new) if you don\'t have time to do it now"), todo(' - `use_standalone("r-lib/rlang", "types-check")` \\ - instead of home grown argument checkers'), + `usethis::use_standalone("r-lib/rlang", "types-check")` \\ + instead of home grown argument checkers; + or [file an issue](new) if you don\'t have time to do it now'), todo( " - Change files ending in `.r` to `.R` in R/ and/or tests/testthat/", + Change files ending in `.r` to `.R` in `R/` and/or `tests/testthat/`", lowercase_r() ), todo(" Add alt-text to pictures, plots, etc; see \\ - https://posit.co/blog/knitr-fig-alt/ for examples"), + https://posit.co/blog/knitr-fig-alt/ for examples" + ), "" ) } + bullets <- c( + bullets, + "### Eternal", + "", + todo("`usethis::use_mit_license()`", grepl("MIT", desc$get_field("License"))), + todo('`usethis::use_package("R", "Depends", "{tidy_minimum_r_version()}")`'), + todo("`usethis::use_tidy_description()`"), + todo("`usethis::use_tidy_github_actions()`"), + todo("`devtools::build_readme()`"), + todo("[Re-publish released site](https://pkgdown.r-lib.org/dev/articles/how-to-update-released-site.html) if needed"), + "" + ) + c(bullets, checklist_footer(tidy = TRUE)) } @@ -278,7 +255,7 @@ tidy_minimum_r_version <- function() { # I do not want a failure here to make use_tidy_upkeep_issue() fail json <- tryCatch(readLines(con, warn = FALSE), error = function(e) NULL) if (is.null(json)) { - oldrel_4 <- "3.4" + oldrel_4 <- "3.6" } else { version <- jsonlite::fromJSON(json)$version oldrel_4 <- re_match(version, "[0-9]+[.][0-9]+")$.match diff --git a/R/usethis-package.R b/R/usethis-package.R index 082017ade..fd1b8bb99 100644 --- a/R/usethis-package.R +++ b/R/usethis-package.R @@ -7,6 +7,7 @@ #' @importFrom glue glue glue_collapse glue_data #' @importFrom lifecycle deprecated #' @importFrom purrr map map_chr map_lgl map_int +#' @importFrom utils available.packages ## usethis namespace: end NULL diff --git a/R/write.R b/R/write.R index 833c4979d..494d26092 100644 --- a/R/write.R +++ b/R/write.R @@ -60,7 +60,7 @@ write_union <- function(path, lines, quiet = FALSE) { } if (!quiet) { - ui_done("Adding {ui_value(new)} to {ui_path(proj_rel_path(path))}") + ui_done("Adding {ui_value(new)} to {ui_path(path)}") } all <- c(existing_lines, new) diff --git a/cran-comments.md b/cran-comments.md index 688656213..53628b394 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,35 +1,23 @@ -## R CMD check results - -0 errors | 0 warnings | 1 note +This is a patch release in response to a 2023-06-28 email from Kurt Hornik about +inputs to numeric_version() and package_version(). -Maintainer's email address is changing from jenny@rstudio.com to jenny@posit.co. - -## revdepcheck results +In this case, the problematic inputs came from implicit usage via `>` in some +tests and these have been changed to comparison to character or removed +entirely. -We checked 178 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. +I did NOT rerun reverse dependency checks because usethis's last patch release +was less than 2 weeks ago, also in response to a request from Kurt Hornik about +numeric versions. - * We saw 2 new problems - * We failed to check 0 packages +## R CMD check results -Issues with CRAN packages are summarised below. +0 errors | 0 warnings | 0 notes -### New problems +## revdepcheck results -* exampletestr - This package has been using usethis to create a path for a message that goes - through an intermediate stage where the path doesn't make sense. - Basically `/path/to/whatever` briefly becomes `/path/to/path/to/whatever`. - This worked in the past, because the path was then re-processed in a way that - cancelled out the mistake, i.e. `/path/to/path/to/whatever` was restored to - `/path/to/whatever`. - However, usethis now errors for nonsensical paths, like - `/path/to/path/to/whatever`. - We've made a pull request to eliminate the unnecessary maneuver. - This only affects a message, not the functionality of the package. - https://github.com/rorynolan/exampletestr/pull/12 +From the previous patch release on 2023-06-23: -* fusen - This package was making use of an unexported function that has been removed. - We've made a pull request with a more robust way to achieve the intent: - https://github.com/ThinkR-open/fusen/pull/205 +We checked 181 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. + * We saw no new problems + * We failed to check 0 packages diff --git a/inst/templates/tidy-support.md b/inst/templates/tidy-support.md index e0a5c04ca..1f27a9121 100644 --- a/inst/templates/tidy-support.md +++ b/inst/templates/tidy-support.md @@ -7,7 +7,7 @@ Before filing an issue, there are a few places to explore and pieces to put toge Start by making a minimal **repr**oducible **ex**ample using the [reprex](https://reprex.tidyverse.org/) package. If you haven't heard of or used reprex before, you're in for a treat! -Seriously, reprex will make all of your R-question-asking endeavors easier (which is a pretty insane ROI for the five to ten minutes it'll take you to learn what it's all about). +Seriously, reprex will make all of your R-question-asking endeavors easier (which is a pretty incredible ROI for the five to ten minutes it'll take you to learn what it's all about). For additional reprex pointers, check out the [Get help!](https://www.tidyverse.org/help/) section of the tidyverse site. ## Where to ask? diff --git a/man/git_vaccinate.Rd b/man/git_vaccinate.Rd index 507a74378..79f938a36 100644 --- a/man/git_vaccinate.Rd +++ b/man/git_vaccinate.Rd @@ -7,7 +7,7 @@ git_vaccinate() } \description{ -Adds \code{.DS_Store}, \code{.Rproj.user}, \code{.Rdata}, \code{.Rhistory}, and \code{.httr-oauth} to +Adds \code{.Rproj.user}, \code{.Rhistory}, \code{.Rdata}, \code{.httr-oauth}, \code{.DS_Store}, and \code{.quarto} to your global (a.k.a. user-level) \code{.gitignore}. This is good practice as it decreases the chance that you will accidentally leak credentials to GitHub. \code{git_vaccinate()} also tries to detect and fix the situation where you have a diff --git a/man/use_package_doc.Rd b/man/use_package_doc.Rd index 264ff4676..6eaa0d6a5 100644 --- a/man/use_package_doc.Rd +++ b/man/use_package_doc.Rd @@ -11,14 +11,27 @@ use_package_doc(open = rlang::is_interactive()) applicable, or via \code{\link[utils:file.edit]{utils::file.edit()}} otherwise.} } \description{ -Adds a dummy \code{.R} file that will prompt roxygen to generate basic +Adds a dummy \code{.R} file that will cause roxygen2 to generate basic package-level documentation. If your package is named "foo", this will make help available to the user via \code{?foo} or \code{package?foo}. Once you call -\code{devtools::document()}, roxygen will flesh out the \code{.Rd} file using data from -the \code{DESCRIPTION}. That ensures you don't need to repeat the same information -in multiple places. This \code{.R} file is also a good place for roxygen -directives that apply to the whole package (vs. a specific function), such as -global namespace tags like \verb{@importFrom}. +\code{devtools::document()}, roxygen2 will flesh out the \code{.Rd} file using data +from the \code{DESCRIPTION}. That ensures you don't need to repeat (and remember +to update!) the same information in multiple places. This \code{.R} file is also a +good place for roxygen directives that apply to the whole package (vs. a +specific function), such as global namespace tags like \verb{@importFrom}. +} +\details{ +There is one tricky case: when a \strong{package} named "foo" also has a +\strong{function} named \code{foo()}. In this case, after running \code{use_package_doc()}, +there will be an \verb{R CMD check} warning. The solution is to set the \verb{@aliases} +for the package-level help topic by modifying the dummy \code{.R} file (e.g., +\code{foo-package.R}) as shown below (but substitute the name of your package / +function for "foo"): + +\if{html}{\out{
}}\preformatted{#' @keywords internal +#' @aliases foo-package +#' "_PACKAGE" +}\if{html}{\out{
}} } \seealso{ The \href{https://r-pkgs.org/man.html}{documentation chapter} of \href{https://r-pkgs.org}{R Packages} diff --git a/revdep/README.md b/revdep/README.md index caa5ff93b..1ecf9100a 100644 --- a/revdep/README.md +++ b/revdep/README.md @@ -1,12 +1,8 @@ # Revdeps -## New problems (5) +## New problems (1) -|package |version |error |warning |note | -|:------------|:-------|:--------|:-------|:----| -|[altdoc](problems.md#altdoc)|0.2.0 |__+1__ | | | -|[cffr](problems.md#cffr)|0.5.0 |__+1__ | | | -|[exampletestr](problems.md#exampletestr)|1.7.0 |__+1__ | | | -|[fledge](problems.md#fledge)|0.1.0 |__+2__ | | | -|[fusen](problems.md#fusen)|0.4.1 |1 __+1__ | | | +|package |version |error |warning |note | +|:-------|:-------|:------|:-------|:----| +|[cffr](problems.md#cffr)|0.5.0 |__+1__ | | | diff --git a/revdep/cran.md b/revdep/cran.md index 88c60685e..633030f13 100644 --- a/revdep/cran.md +++ b/revdep/cran.md @@ -1,8 +1,8 @@ ## revdepcheck results -We checked 178 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. +We checked 181 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. - * We saw 5 new problems + * We saw 1 new problems * We failed to check 0 packages Issues with CRAN packages are summarised below. @@ -10,19 +10,6 @@ Issues with CRAN packages are summarised below. ### New problems (This reports the first line of each new failure) -* altdoc - checking tests ... ERROR - * cffr checking tests ... ERROR -* exampletestr - checking tests ... ERROR - -* fledge - checking examples ... ERROR - checking tests ... ERROR - -* fusen - checking examples ... ERROR - diff --git a/revdep/problems.md b/revdep/problems.md index 4097612dc..d9ef6a546 100644 --- a/revdep/problems.md +++ b/revdep/problems.md @@ -1,42 +1,3 @@ -# altdoc - -
- -* Version: 0.2.0 -* GitHub: https://github.com/etiennebacher/altdoc -* Source code: https://github.com/cran/altdoc -* Date/Publication: 2023-05-26 18:50:08 UTC -* Number of recursive dependencies: 82 - -Run `revdepcheck::cloud_details(, "altdoc")` for more info - -
- -## Newly broken - -* checking tests ... ERROR - ``` - Running ‘spelling.R’ - Running ‘testthat.R’ - Running the tests in ‘tests/testthat.R’ failed. - Last 13 lines of output: - 2. └─usethis:::cran_version() - 3. └─utils::available.packages() - 4. └─utils::contrib.url(repos, type) - ── Error ('test-utils.R:48:3'): import_* functions work ──────────────────────── - Error in `contrib.url(repos, type)`: trying to use CRAN without setting a mirror - Backtrace: - ▆ - 1. └─usethis::use_news_md() at test-utils.R:48:2 - 2. └─usethis:::cran_version() - 3. └─utils::available.packages() - 4. └─utils::contrib.url(repos, type) - - [ FAIL 5 | WARN 0 | SKIP 13 | PASS 86 ] - Error: Test failures - Execution halted - ``` - # cffr
@@ -58,7 +19,7 @@ Run `revdepcheck::cloud_details(, "cffr")` for more info Running ‘testthat.R’ Running the tests in ‘tests/testthat.R’ failed. Last 13 lines of output: - • On CRAN (110) + 'test-write_citation.R:46:3', 'test-write_citation.R:111:3' ══ Failed tests ════════════════════════════════════════════════════════════════ ── Failure ('test-cff_to_bibtex.R:416:3'): Errors ────────────────────────────── @@ -75,170 +36,3 @@ Run `revdepcheck::cloud_details(, "cffr")` for more info Execution halted ``` -# exampletestr - -
- -* Version: 1.7.0 -* GitHub: https://github.com/rorynolan/exampletestr -* Source code: https://github.com/cran/exampletestr -* Date/Publication: 2022-12-06 19:20:02 UTC -* Number of recursive dependencies: 97 - -Run `revdepcheck::cloud_details(, "exampletestr")` for more info - -
- -## Newly broken - -* checking tests ... ERROR - ``` - Running ‘spelling.R’ - Running ‘testthat.R’ - Running the tests in ‘tests/testthat.R’ failed. - Last 13 lines of output: - 7. │ ├─usethis::ui_path(usethis::proj_path(test_file_name), usethis::proj_path()) - 8. │ │ └─fs::is_dir(x) - 9. │ │ └─fs::file_info(path, follow = follow) - 10. │ │ └─fs::path_expand(path) - 11. │ └─usethis::proj_path(test_file_name) - 12. │ └─usethis::ui_stop("Paths must be relative to the active project") - 13. └─glue (local) ``("usethis::ui_path(usethis::proj_path(test_file_name),\nusethis::proj_path())") - 14. ├─.transformer(expr, env) %||% .null - 15. └─glue (local) .transformer(expr, env) - 16. └─base::eval(parse(text = text, keep.source = FALSE), envir) - 17. └─base::eval(parse(text = text, keep.source = FALSE), envir) - - [ FAIL 2 | WARN 4 | SKIP 0 | PASS 16 ] - Error: Test failures - Execution halted - ``` - -# fledge - -
- -* Version: 0.1.0 -* GitHub: https://github.com/cynkra/fledge -* Source code: https://github.com/cran/fledge -* Date/Publication: 2021-12-07 20:20:02 UTC -* Number of recursive dependencies: 74 - -Run `revdepcheck::cloud_details(, "fledge")` for more info - -
- -## Newly broken - -* checking examples ... ERROR - ``` - Running examples in ‘fledge-Ex.R’ failed - The error most likely occurred in: - - > ### Name: bump_version - > ### Title: Bump package version - > ### Aliases: bump_version bump_version_impl - > - > ### ** Examples - > - > # Create mock package in a temporary directory. - ... - + fledge::bump_version() - + }) - sh: 1: git: not found - sh: 1: git: not found - sh: 1: git: not found - sh: 1: git: not found - Error in contrib.url(repos, type) : - trying to use CRAN without setting a mirror - Calls: with_demo_project ... -> cran_version -> -> contrib.url - Execution halted - ``` - -* checking tests ... ERROR - ``` - Running ‘testthat.R’ - Running the tests in ‘tests/testthat.R’ failed. - Last 13 lines of output: - 6. └─usethis:::cran_version() - 7. └─utils::available.packages() - 8. └─utils::contrib.url(repos, type) - - [ FAIL 8 | WARN 0 | SKIP 5 | PASS 0 ] - Deleting unused snapshots: - • bump_version/NEWS-nondev.md - • bump_version/NEWS.md - • finalize-version/NEWS-push-false.md - • finalize-version/NEWS-push-true.md - • unbump_version/NEWS.md - • update-news/NEWS-empty.md - • update-news/NEWS-new.md - Error: Test failures - Execution halted - ``` - -# fusen - -
- -* Version: 0.4.1 -* GitHub: https://github.com/Thinkr-open/fusen -* Source code: https://github.com/cran/fusen -* Date/Publication: 2022-09-29 14:50:06 UTC -* Number of recursive dependencies: 113 - -Run `revdepcheck::cloud_details(, "fusen")` for more info - -
- -## Newly broken - -* checking examples ... ERROR - ``` - Running examples in ‘fusen-Ex.R’ failed - The error most likely occurred in: - - > ### Name: inflate - > ### Title: Inflate Rmd to package - > ### Aliases: inflate - > - > ### ** Examples - > - > # Create a new project - ... - + ) - ✔ Setting active project to '/tmp/Rtmpu0fqny/dummypackage1eb4449d5950' - ℹ Loading dummypackage1eb4449d5950 - Writing 'NAMESPACE' - Loading required namespace: testthat - ✔ Adding 'knitr' to Suggests field in DESCRIPTION - Error in get(x, envir = ns, inherits = FALSE) : - object 'use_description_field' not found - Calls: inflate -> create_vignette -> getFromNamespace -> get - Execution halted - ``` - -## In both - -* checking tests ... ERROR - ``` - Running ‘testthat.R’ - Running the tests in ‘tests/testthat.R’ failed. - Last 13 lines of output: - Error in `get(x, envir = ns, inherits = FALSE)`: object 'use_description_field' not found - Backtrace: - ▆ - 1. ├─usethis::with_project(...) at test-inflate_utils.R:36:0 - 2. │ └─base::force(code) - 3. ├─usethis::with_project(...) at test-inflate_utils.R:48:2 - 4. │ └─base::force(code) - 5. └─fusen::inflate(...) at test-inflate_utils.R:49:4 - 6. └─fusen:::create_vignette(...) - 7. └─utils::getFromNamespace("use_description_field", "usethis") - 8. └─base::get(x, envir = ns, inherits = FALSE) - - [ FAIL 18 | WARN 6 | SKIP 7 | PASS 212 ] - Error: Test failures - Execution halted - ``` - diff --git a/tests/testthat/_snaps/lifecycle.md b/tests/testthat/_snaps/lifecycle.md index f34f74a2e..b19b30936 100644 --- a/tests/testthat/_snaps/lifecycle.md +++ b/tests/testthat/_snaps/lifecycle.md @@ -5,7 +5,7 @@ Message v Adding 'lifecycle' to Imports field in DESCRIPTION * Refer to functions with `lifecycle::fun()` - v Adding '@importFrom lifecycle deprecated' to 'R/test_lifecycle-package.R' + v Adding '@importFrom lifecycle deprecated' to 'R/{TESTPKG}-package.R' v Writing 'NAMESPACE' v Creating 'man/figures/' v Copied SVG badges to 'man/figures/' diff --git a/tests/testthat/_snaps/pkgdown.md b/tests/testthat/_snaps/pkgdown.md new file mode 100644 index 000000000..d1ff23874 --- /dev/null +++ b/tests/testthat/_snaps/pkgdown.md @@ -0,0 +1,10 @@ +# use_pkgdown() creates and ignores the promised file/dir + + Code + use_pkgdown() + Message + v Adding '^_pkgdown\\.yml$', '^docs$', '^pkgdown$' to '.Rbuildignore' + v Adding 'docs' to '.gitignore' + v Writing '_pkgdown.yml' + * Edit '_pkgdown.yml' + diff --git a/tests/testthat/_snaps/release.md b/tests/testthat/_snaps/release.md index 33b2e29ce..b6b712efb 100644 --- a/tests/testthat/_snaps/release.md +++ b/tests/testthat/_snaps/release.md @@ -33,11 +33,11 @@ Wait for CRAN... * [ ] Accepted :tada: - * [ ] Add preemptive link to blog post in pkgdown news menu + * [ ] Finish & publish blog post + * [ ] Add link to blog post in pkgdown news menu * [ ] `usethis::use_github_release()` * [ ] `usethis::use_dev_version(push = TRUE)` * [ ] `usethis::use_news_md()` - * [ ] Finish blog post * [ ] Tweet --- @@ -101,11 +101,11 @@ Wait for CRAN... * [ ] Accepted :tada: - * [ ] Add preemptive link to blog post in pkgdown news menu + * [ ] Finish & publish blog post + * [ ] Add link to blog post in pkgdown news menu * [ ] `usethis::use_github_release()` * [ ] `usethis::use_dev_version(push = TRUE)` * [ ] `usethis::use_news_md()` - * [ ] Finish blog post * [ ] Tweet # construct correct revdep bullet @@ -158,10 +158,10 @@ Wait for CRAN... * [ ] Accepted :tada: - * [ ] Add preemptive link to blog post in pkgdown news menu + * [ ] Finish & publish blog post + * [ ] Add link to blog post in pkgdown news menu * [ ] `usethis::use_github_release()` * [ ] `usethis::use_dev_version(push = TRUE)` * [ ] `usethis::use_news_md()` - * [ ] Finish blog post * [ ] Tweet diff --git a/tests/testthat/_snaps/tibble.md b/tests/testthat/_snaps/tibble.md index 80f5600e6..ac0695750 100644 --- a/tests/testthat/_snaps/tibble.md +++ b/tests/testthat/_snaps/tibble.md @@ -4,7 +4,7 @@ use_tibble() Message v Adding 'tibble' to Imports field in DESCRIPTION - v Adding '@importFrom tibble tibble' to 'R/mypackage-package.R' + v Adding '@importFrom tibble tibble' to 'R/{TESTPKG}-package.R' * Document a returned tibble like so: #' @return a [tibble][tibble::tibble-package] diff --git a/tests/testthat/_snaps/tidyverse.md b/tests/testthat/_snaps/tidyverse.md index 33f017c87..b70cd5aa3 100644 --- a/tests/testthat/_snaps/tidyverse.md +++ b/tests/testthat/_snaps/tidyverse.md @@ -8,9 +8,9 @@ v Adding 'cli' to Imports field in DESCRIPTION v Adding 'glue' to Imports field in DESCRIPTION v Adding 'withr' to Imports field in DESCRIPTION - v Adding '@import rlang' to 'R/tidydeps-package.R' - v Adding '@importFrom glue glue' to 'R/tidydeps-package.R' - v Adding '@importFrom lifecycle deprecated' to 'R/tidydeps-package.R' + v Adding '@import rlang' to 'R/{TESTPKG}-package.R' + v Adding '@importFrom glue glue' to 'R/{TESTPKG}-package.R' + v Adding '@importFrom lifecycle deprecated' to 'R/{TESTPKG}-package.R' v Writing 'NAMESPACE' v Writing 'R/import-standalone-purrr.R' diff --git a/tests/testthat/_snaps/upkeep.md b/tests/testthat/_snaps/upkeep.md index 476ef8dfb..f4a6d6a8d 100644 --- a/tests/testthat/_snaps/upkeep.md +++ b/tests/testthat/_snaps/upkeep.md @@ -3,7 +3,7 @@ Code writeLines(tidy_upkeep_checklist(posit_pkg = TRUE, posit_person_ok = FALSE)) Output - Pre-history + ### Pre-history * [ ] `usethis::use_readme_rmd()` * [ ] `usethis::use_roxygen_md()` @@ -11,62 +11,48 @@ * [ ] `usethis::use_pkgdown_github_pages()` * [ ] `usethis::use_tidy_github_labels()` * [ ] `usethis::use_tidy_style()` - * [ ] `usethis::use_tidy_description()` * [ ] `urlchecker::url_check()` - 2020 + ### 2020 * [ ] `usethis::use_package_doc()` - Consider letting usethis manage your `@importFrom` directives here. - `usethis::use_import_from()` is handy for this. - * [ ] `usethis::use_testthat(3)` and upgrade to 3e, [testthat 3e vignette](https://testthat.r-lib.org/articles/third-edition.html) - * [ ] Align the names of `R/` files and `test/` files for workflow happiness. - The docs for `usethis::use_r()` include a helpful script. - `usethis::rename_files()` may be be useful. + * [ ] `usethis::use_testthat(3)` + * [ ] Align the names of `R/` files and `test/` files - 2021 + ### 2021 - * [ ] `usethis::use_tidy_dependencies()` - * [ ] `usethis::use_tidy_github_actions()` and update artisanal actions to use `setup-r-dependencies` * [ ] Remove check environments section from `cran-comments.md` - * [ ] Bump required R version in DESCRIPTION to 3.6 - * [ ] Use lifecycle instead of artisanal deprecation messages, as described in [Communicate lifecycle changes in your functions](https://lifecycle.r-lib.org/articles/communicate.html) - * [ ] Make sure RStudio appears in `Authors@R` of DESCRIPTION like so, if appropriate: - `person("RStudio", role = c("cph", "fnd"))` + * [ ] Use lifecycle instead of artisanal deprecation messages - 2022 + ### 2022 - * [ ] `usethis::use_tidy_coc()` * [ ] Handle and close any still-open `master` --> `main` issues - * [ ] Update README badges, instructions in [r-lib/usethis#1594](https://github.com/r-lib/usethis/issues/1594) - * [ ] Update errors to rlang 1.0.0. Helpful guides: - - - + * [ ] `usethis:::use_codecov_badge("OWNER/REPO")` * [ ] Update pkgdown site using instructions at - * [ ] Ensure pkgdown `development` is `mode: auto` in pkgdown config - * [ ] Re-publish released site; see [How to update a released site](https://pkgdown.r-lib.org/dev/articles/how-to-update-released-site.html) * [ ] Update lifecycle badges with more accessible SVGs: `usethis::use_lifecycle()` - 2023 - - Necessary: + ### 2023 * [ ] Update email addresses *@rstudio.com -> *@posit.co - * [ ] Update copyright holder in DESCRIPTION: `person(given = "Posit Software, PBC", role = c("cph", "fnd"))` - * [ ] `Run devtools::document()` to re-generate package-level help topic with DESCRIPTION changes - * [ ] Double check license file uses '[package] authors' as copyright holder. Run `use_mit_license()` - * [ ] Update logo (https://github.com/rstudio/hex-stickers); run `use_tidy_logo()` + * [ ] Update copyright holder in DESCRIPTION: `person("Posit Software, PBC", role = c("cph", "fnd"))` + * [ ] Run `devtools::document()` to re-generate package-level help topic with DESCRIPTION changes + * [ ] `usethis::use_tidy_logo()` * [ ] `usethis::use_tidy_coc()` - * [ ] `usethis::use_tidy_github_actions()` + * [ ] Use `pak::pak("OWNER/REPO")` in README + * [ ] Consider running `usethis::use_tidy_dependencies()` and/or replace compat files with `use_standalone()` + * [ ] Use cli errors or [file an issue](new) if you don't have time to do it now + * [ ] `usethis::use_standalone("r-lib/rlang", "types-check")` instead of home grown argument checkers; + or [file an issue](new) if you don't have time to do it now + * [ ] Add alt-text to pictures, plots, etc; see https://posit.co/blog/knitr-fig-alt/ for examples - Optional: + ### Eternal - * [ ] Review 2022 checklist to see if you completed the pkgdown updates - * [ ] Prefer `pak::pak("org/pkg")` over `devtools::install_github("org/pkg")` in README - * [ ] Consider running `use_tidy_dependencies()` and/or replace compat files with `use_standalone()` - * [ ] `use_standalone("r-lib/rlang", "types-check")` instead of home grown argument checkers - * [ ] Add alt-text to pictures, plots, etc; see https://posit.co/blog/knitr-fig-alt/ for examples + * [ ] `usethis::use_mit_license()` + * [ ] `usethis::use_package("R", "Depends", "3.6")` + * [ ] `usethis::use_tidy_description()` + * [ ] `usethis::use_tidy_github_actions()` + * [ ] `devtools::build_readme()` + * [ ] [Re-publish released site](https://pkgdown.r-lib.org/dev/articles/how-to-update-released-site.html) if needed Created on DATE with `usethis::use_tidy_upkeep_issue()`, using [usethis vVERSION](https://usethis.r-lib.org) diff --git a/tests/testthat/_snaps/write.md b/tests/testthat/_snaps/write.md new file mode 100644 index 000000000..2b3e8a910 --- /dev/null +++ b/tests/testthat/_snaps/write.md @@ -0,0 +1,7 @@ +# write_union() messaging is correct with weird working directory + + Code + write_union(proj_path("somefile"), letters[4:6]) + Message + v Adding 'd', 'e', 'f' to 'somefile' + diff --git a/tests/testthat/test-author.R b/tests/testthat/test-author.R index d336ebdab..987961334 100644 --- a/tests/testthat/test-author.R +++ b/tests/testthat/test-author.R @@ -73,7 +73,7 @@ test_that("Decline to tweak an existing author", { test_that("Placeholder author is challenged", { # apparently the format method for `person` used to handle ORCIDs differently - skip_if(getRversion() < 4.0) + skip_if(getRversion() < "4.0") withr::local_options(usethis.description = NULL) create_local_package() diff --git a/tests/testthat/test-latest-dependencies.R b/tests/testthat/test-latest-dependencies.R index 71b465ee8..60bfa473f 100644 --- a/tests/testthat/test-latest-dependencies.R +++ b/tests/testthat/test-latest-dependencies.R @@ -1,5 +1,5 @@ test_that("sets version for imports & depends dependencies", { - skip_on_cran() + skip_if_offline() withr::local_options(list(repos = c(CRAN = "https://cloud.r-project.org"))) create_local_package() @@ -15,7 +15,7 @@ test_that("sets version for imports & depends dependencies", { }) test_that("doesn't affect suggests", { - skip_on_cran() + skip_if_offline() withr::local_options(list(repos = c(CRAN = "https://cloud.r-project.org"))) create_local_package() @@ -27,7 +27,7 @@ test_that("doesn't affect suggests", { }) test_that("does nothing for a base package", { - skip_on_cran() + skip_if_offline() withr::local_options(list(repos = c(CRAN = "https://cloud.r-project.org"))) create_local_package() diff --git a/tests/testthat/test-lifecycle.R b/tests/testthat/test-lifecycle.R index f18812e11..ae7a6ec5d 100644 --- a/tests/testthat/test-lifecycle.R +++ b/tests/testthat/test-lifecycle.R @@ -1,11 +1,12 @@ test_that("use_lifecycle() imports badges", { - create_local_package(fs::path_temp("test_lifecycle")) + create_local_package() use_package_doc() withr::local_options(usethis.quiet = FALSE) - expect_snapshot({ - use_lifecycle() - }) + expect_snapshot( + use_lifecycle(), + transform = scrub_testpkg + ) expect_proj_file("man", "figures", "lifecycle-stable.svg") expect_equal(roxygen_ns_show(), "#' @importFrom lifecycle deprecated") diff --git a/tests/testthat/test-pkgdown.R b/tests/testthat/test-pkgdown.R index 79794808d..7344c0eea 100644 --- a/tests/testthat/test-pkgdown.R +++ b/tests/testthat/test-pkgdown.R @@ -8,8 +8,11 @@ test_that("use_pkgdown() creates and ignores the promised file/dir", { local_interactive(FALSE) local_check_installed() local_mocked_bindings(pkgdown_version = function() "1.9000") + withr::local_options(usethis.quiet = FALSE) - use_pkgdown() + expect_snapshot( + use_pkgdown() + ) expect_true(uses_pkgdown()) expect_true(is_build_ignored("^_pkgdown\\.yml$")) diff --git a/tests/testthat/test-r.R b/tests/testthat/test-r.R index a9eccf6d6..b24bbaca3 100644 --- a/tests/testthat/test-r.R +++ b/tests/testthat/test-r.R @@ -65,5 +65,9 @@ test_that("compute_active_name() standardises name", { compute_active_name(path(dir, "R/data.frame.R"), "R"), "data.frame.R" ) +}) +# https://github.com/r-lib/usethis/issues/1863 +test_that("compute_name() accepts the declared extension", { + expect_equal(compute_name("foo.cpp", ext = "cpp"), "foo.cpp") }) diff --git a/tests/testthat/test-rcpp.R b/tests/testthat/test-rcpp.R index 6d3de6f3f..3b89af997 100644 --- a/tests/testthat/test-rcpp.R +++ b/tests/testthat/test-rcpp.R @@ -7,6 +7,9 @@ test_that("use_rcpp() creates files/dirs, edits DESCRIPTION and .gitignore", { create_local_package() use_roxygen_md() + # pretend Rcpp is installed + local_check_installed() + use_rcpp("test") expect_match(desc::desc_get("LinkingTo"), "Rcpp") expect_match(desc::desc_get("Imports"), "Rcpp") diff --git a/tests/testthat/test-release.R b/tests/testthat/test-release.R index d041a50ce..d9644ada1 100644 --- a/tests/testthat/test-release.R +++ b/tests/testthat/test-release.R @@ -29,6 +29,8 @@ test_that("non-patch + lifecycle = advanced deprecation process", { create_local_package() use_package("lifecycle") + local_mocked_bindings(tidy_minimum_r_version = function() "3.6") + has_deprecation <- function(x) any(grepl("deprecation processes", x)) expect_true(has_deprecation(release_checklist("1.0.0", on_cran = TRUE))) expect_true(has_deprecation(release_checklist("1.1.0", on_cran = TRUE))) @@ -199,3 +201,29 @@ test_that("get_release_data() works for new-style CRAN-RELEASE", { expect_equal(res$SHA, HEAD) expect_equal(path_file(res$file), "CRAN-SUBMISSION") }) + +test_that("cran_version() returns package version if package found", { + local_mocked_bindings(available.packages = function(...) { + # simulate minimal available.packages entry + as.matrix(data.frame(Package = c(usethis = "usethis"), Version = "1.0.0")) + }) + + expect_null(cran_version("doesntexist")) + expect_equal(cran_version("usethis"), package_version("1.0.0")) +}) + +test_that("cran_version() returns NULL if no available packages", { + local_mocked_bindings(available.packages = function(...) NULL) + expect_null(cran_version("doesntexist")) +}) + +test_that("default_cran_mirror() is respects set value but falls back to cloud", { + withr::local_options(repos = c(CRAN = "https://example.com")) + expect_equal(default_cran_mirror(), c(CRAN = "https://example.com")) + + withr::local_options(repos = c(CRAN = "@CRAN@")) + expect_equal(default_cran_mirror(), c(CRAN = "https://cloud.r-project.org")) + + withr::local_options(repos = c()) + expect_equal(default_cran_mirror(), c(CRAN = "https://cloud.r-project.org")) +}) diff --git a/tests/testthat/test-tibble.R b/tests/testthat/test-tibble.R index f594aeb6a..f76efbc22 100644 --- a/tests/testthat/test-tibble.R +++ b/tests/testthat/test-tibble.R @@ -4,7 +4,7 @@ test_that("use_tibble() requires a package", { }) test_that("use_tibble() Imports tibble", { - create_local_package(path_temp("mypackage")) + create_local_package() withr::local_options(list(usethis.quiet = FALSE)) local_roxygen_update_ns() @@ -12,7 +12,10 @@ test_that("use_tibble() Imports tibble", { ui_silence(use_package_doc()) local_check_fun_exists() - expect_snapshot(use_tibble()) + expect_snapshot( + use_tibble(), + transform = scrub_testpkg + ) expect_match(proj_desc()$get("Imports"), "tibble") }) diff --git a/tests/testthat/test-tidyverse.R b/tests/testthat/test-tidyverse.R index f9b319747..45246cd97 100644 --- a/tests/testthat/test-tidyverse.R +++ b/tests/testthat/test-tidyverse.R @@ -15,11 +15,14 @@ test_that("use_tidy_description() alphabetises dependencies and remotes", { test_that("use_tidy_dependencies() isn't overly informative", { skip_if_offline("github.com") - create_local_package(fs::path_temp("tidydeps")) + create_local_package() use_package_doc() withr::local_options(usethis.quiet = FALSE) - expect_snapshot(use_tidy_dependencies()) + expect_snapshot( + use_tidy_dependencies(), + transform = scrub_testpkg + ) }) test_that("use_tidy_GITHUB-STUFF() adds and Rbuildignores files", { @@ -54,7 +57,6 @@ test_that("use_tidy_github() adds and Rbuildignores files", { }) test_that("styling the package works", { - skip_if(getRversion() < 3.2) skip_if_no_git_user() skip_if_not_installed("styler") @@ -69,7 +71,6 @@ test_that("styling the package works", { test_that("styling of non-packages works", { - skip_if(getRversion() < 3.2) skip_if_no_git_user() skip_if_not_installed("styler") diff --git a/tests/testthat/test-write.R b/tests/testthat/test-write.R index f601b374e..049769ec3 100644 --- a/tests/testthat/test-write.R +++ b/tests/testthat/test-write.R @@ -166,13 +166,6 @@ test_that("same_contents() detects if contents are / are not same", { expect_false(same_contents(tmp, letters[4:6])) }) -test_that("write_over() writes a de novo file", { - tmp <- file_temp() - expect_false(file_exists(tmp)) - write_over(tmp, letters[1:3], quiet = TRUE) - expect_identical(read_utf8(tmp), letters[1:3]) -}) - test_that("write_over() leaves file 'as is' (outside of a project)", { local_interactive(FALSE) tmp <- withr::local_file(file_temp()) @@ -247,3 +240,14 @@ test_that("write_over() works for a file in a project that is not active", { ) expect_false(proj_active()) }) + +test_that("write_union() messaging is correct with weird working directory", { + create_local_project() + use_directory("aaa/bbb") + setwd("aaa/bbb") + + withr::local_options(usethis.quiet = FALSE) + expect_snapshot( + write_union(proj_path("somefile"), letters[4:6]) + ) +}) diff --git a/vignettes/articles/usethis-setup.Rmd b/vignettes/articles/usethis-setup.Rmd index b0c0a3d6d..5e8132619 100644 --- a/vignettes/articles/usethis-setup.Rmd +++ b/vignettes/articles/usethis-setup.Rmd @@ -170,7 +170,7 @@ Substitute your preferred editor for emacs here. A popular choice is [nano](http As stated above, usethis doesn't actually use the Git you install and has no absolute requirement that you use GitHub or use RStudio. But use of usethis is highly correlated with the desire to do all of these things, in a pleasant way. -If you plan to use GitHub, you need to make sure your local Git can pull from and push to GitHub.com. That is beyond the scope of this article, but see the [Connect to GitHub](https://happygitwithr.com/push-pull-github.html) section in Happy Git. You probably don't want to enter your username and password all the time, so either [cache credentials for HTTPS](https://happygitwithr.com/credential-caching.html) or [set up SSH keys](https://happygitwithr.com/ssh-keys.html). If you are an SSH person, set the `usethis.protocol` option to "ssh" (as of v2.0.0, "https" is the usethis default). +If you plan to use GitHub, you need to make sure your local Git can pull from and push to GitHub.com. That is beyond the scope of this article, but see the [Connect to GitHub](https://happygitwithr.com/push-pull-github.html) section in Happy Git. You probably don't want to enter your username and password all the time, so either [cache credentials for HTTPS](https://happygitwithr.com/https-pat) or [set up SSH keys](https://happygitwithr.com/ssh-keys.html). If you are an SSH person, set the `usethis.protocol` option to "ssh" (as of v2.0.0, "https" is the usethis default). If you want to use RStudio to work with Git (and therefore GitHub, see previous paragraph), you need to make sure RStudio can find your Git executable. This usually "just works". The [Connect RStudio to Git and GitHub](https://happygitwithr.com/rstudio-git-github.html) section of Happy Git helps you confirm that all is well. If all is not well, there are also [troubleshooting tips](https://happygitwithr.com/rstudio-see-git.html).