From c938c5937792f7c1eb513984e24f16962ca72933 Mon Sep 17 00:00:00 2001 From: Paul Lietar Date: Thu, 18 Jan 2024 15:32:08 +0000 Subject: [PATCH] Fix CI issue caused by new cli package. Recent versions of the cli package have added a new `vec-sep2` style option for `cli_vec`, in an effort to improve their handling of Oxford commas. This means `vec-last` is now ignored for any list of length two, and the value of `vec-sep2` is used instead. We only used that feature in one place, with "or" as the value for `vec-last`. The new cli package broke a test by making that code print the default `vec-sep2` value, i.e. "and", when there are only two elements. After looking at the context of that message however, I think "and" actually makes more sense than "or". It is printing a list of paths that haven't been found. We would want all of the paths in the list to be present, not just one of them. The simplest fix is therefore to remove the call to `cli_vec` and let cli use the default settings. Finally, remove a call to `squote` on the missing paths and use a `.path` tag in the message. The end result is the same. --- R/outpack_root.R | 3 +-- tests/testthat/test-outpack-helpers.R | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/R/outpack_root.R b/R/outpack_root.R index 0c96ffe2..c676f116 100644 --- a/R/outpack_root.R +++ b/R/outpack_root.R @@ -174,9 +174,8 @@ validate_packet_has_file <- function(root, id, path, call = NULL) { } } - vmsg <- cli::cli_vec(squote(msg), list("vec-last" = " or ")) err <- paste("Packet '{id}' does not contain the requested", - "{cli::qty(vmsg)} path{?s} {vmsg}") + "{cli::qty(msg)} path{?s} {.path {msg}}") cli::cli_abort(c(err, set_names(hint, "i")), call = call) } diff --git a/tests/testthat/test-outpack-helpers.R b/tests/testthat/test-outpack-helpers.R index 568423f9..191cd13b 100644 --- a/tests/testthat/test-outpack-helpers.R +++ b/tests/testthat/test-outpack-helpers.R @@ -150,7 +150,7 @@ test_that("good error message if file not found in packet", { err <- expect_error( validate_packet_has_file(root, id, c("a.txt", "a.TXT", "d.txt")), - "Packet '.+' does not contain the requested paths\\s*'a.TXT' or 'd.txt'") + "Packet '.+' does not contain the requested paths\\s*'a.TXT' and 'd.txt'") expect_equal( err$body, c(i = "For 'a.TXT' did you mean 'a.txt'",