Skip to content

Commit

Permalink
Ensure that extra args generate a warning, not an error
Browse files Browse the repository at this point in the history
And re-run revdeps
  • Loading branch information
hadley committed Nov 30, 2023
1 parent 9ca52b1 commit 932989c
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 5 deletions.
7 changes: 5 additions & 2 deletions R/expect-condition.R
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,11 @@ expect_condition_matching <- function(base_class,
inherit = TRUE,
info = NULL,
label = NULL,
trace_env = caller_env()) {
check_dots_used(error = warning)
trace_env = caller_env(),
error_call = caller_env()) {
check_dots_used(error = function(cnd) {
warn(conditionMessage(cnd), call = error_call)
})

matcher <- cnd_matcher(
base_class,
Expand Down
6 changes: 6 additions & 0 deletions revdep/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# Revdeps

## New problems (1)

|package |version |error |warning |note |
|:--------|:-------|:------|:-------|:----|
|[APCalign](problems.md#apcalign)|0.1.3 |__+1__ | |1 |

12 changes: 10 additions & 2 deletions revdep/cran.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
## revdepcheck results

We checked 15 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.
We checked 10 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.

* We saw 0 new problems
* We saw 1 new problems
* We failed to check 0 packages

Issues with CRAN packages are summarised below.

### New problems
(This reports the first line of each new failure)

* APCalign
checking tests ... ERROR

49 changes: 48 additions & 1 deletion revdep/problems.md
Original file line number Diff line number Diff line change
@@ -1 +1,48 @@
*Wow, no problems at all. :)*
# APCalign

<details>

* Version: 0.1.3
* GitHub: https://github.com/traitecoevo/APCalign
* Source code: https://github.com/cran/APCalign
* Date/Publication: 2023-11-16 22:43:53 UTC
* Number of recursive dependencies: 97

Run `revdepcheck::cloud_details(, "APCalign")` for more info

</details>

## Newly broken

* checking tests ... ERROR
```
Running ‘testthat.R’
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
> # This file is part of the standard setup for testthat.
> # It is recommended that you do not modify it.
> #
> # Where should you do additional test configuration?
> # Learn more about the roles of various files in:
> # * https://r-pkgs.org/tests.html
> # * https://testthat.r-lib.org/reference/test_package.html#special-files
...
6. │ └─dplyr:::check_nth_default(default, x = x)
7. │ └─vctrs::vec_init(x)
8. └─vctrs:::stop_scalar_type(`<fn>`(NULL), "x", `<fn>`(vec_init()))
9. └─vctrs:::stop_vctrs(...)
10. └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = call)
[ FAIL 1 | WARN 0 | SKIP 0 | PASS 85 ]
Error: Test failures
In addition: There were 18 warnings (use warnings() to see them)
Execution halted
```

## In both

* checking data for non-ASCII characters ... NOTE
```
Note: found 4 marked UTF-8 strings
```

11 changes: 11 additions & 0 deletions tests/testthat/_snaps/expect-condition.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@
Message: dispatched!
Class: foobar/rlang_error/error/condition

# unused arguments generate a warning

Code
expect_condition(stop("Hi!"), foo = "bar")
Condition
Warning in `expect_condition()`:
Arguments in `...` must be used.
x Problematic argument:
* foo = "bar"
i Did you misspell an argument name?

4 changes: 4 additions & 0 deletions tests/testthat/test-expect-condition.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ test_that("can match parent conditions (#1493)", {
expect_error(expect_error(f(), "Parent message.", inherit = FALSE))
})

test_that("unused arguments generate a warning", {
expect_snapshot(expect_condition(stop("Hi!"), foo = "bar"))
})


# second edition ----------------------------------------------------------

Expand Down

0 comments on commit 932989c

Please sign in to comment.