Skip to content

Commit 932989c

Browse files
committed
Ensure that extra args generate a warning, not an error
And re-run revdeps
1 parent 9ca52b1 commit 932989c

File tree

6 files changed

+84
-5
lines changed

6 files changed

+84
-5
lines changed

R/expect-condition.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,11 @@ expect_condition_matching <- function(base_class,
254254
inherit = TRUE,
255255
info = NULL,
256256
label = NULL,
257-
trace_env = caller_env()) {
258-
check_dots_used(error = warning)
257+
trace_env = caller_env(),
258+
error_call = caller_env()) {
259+
check_dots_used(error = function(cnd) {
260+
warn(conditionMessage(cnd), call = error_call)
261+
})
259262

260263
matcher <- cnd_matcher(
261264
base_class,

revdep/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
# Revdeps
22

3+
## New problems (1)
4+
5+
|package |version |error |warning |note |
6+
|:--------|:-------|:------|:-------|:----|
7+
|[APCalign](problems.md#apcalign)|0.1.3 |__+1__ | |1 |
8+

revdep/cran.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
## revdepcheck results
22

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

5-
* We saw 0 new problems
5+
* We saw 1 new problems
66
* We failed to check 0 packages
77

8+
Issues with CRAN packages are summarised below.
9+
10+
### New problems
11+
(This reports the first line of each new failure)
12+
13+
* APCalign
14+
checking tests ... ERROR
15+

revdep/problems.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,48 @@
1-
*Wow, no problems at all. :)*
1+
# APCalign
2+
3+
<details>
4+
5+
* Version: 0.1.3
6+
* GitHub: https://github.com/traitecoevo/APCalign
7+
* Source code: https://github.com/cran/APCalign
8+
* Date/Publication: 2023-11-16 22:43:53 UTC
9+
* Number of recursive dependencies: 97
10+
11+
Run `revdepcheck::cloud_details(, "APCalign")` for more info
12+
13+
</details>
14+
15+
## Newly broken
16+
17+
* checking tests ... ERROR
18+
```
19+
Running ‘testthat.R’
20+
Running the tests in ‘tests/testthat.R’ failed.
21+
Complete output:
22+
> # This file is part of the standard setup for testthat.
23+
> # It is recommended that you do not modify it.
24+
> #
25+
> # Where should you do additional test configuration?
26+
> # Learn more about the roles of various files in:
27+
> # * https://r-pkgs.org/tests.html
28+
> # * https://testthat.r-lib.org/reference/test_package.html#special-files
29+
...
30+
6. │ └─dplyr:::check_nth_default(default, x = x)
31+
7. │ └─vctrs::vec_init(x)
32+
8. └─vctrs:::stop_scalar_type(`<fn>`(NULL), "x", `<fn>`(vec_init()))
33+
9. └─vctrs:::stop_vctrs(...)
34+
10. └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = call)
35+
36+
[ FAIL 1 | WARN 0 | SKIP 0 | PASS 85 ]
37+
Error: Test failures
38+
In addition: There were 18 warnings (use warnings() to see them)
39+
Execution halted
40+
```
41+
42+
## In both
43+
44+
* checking data for non-ASCII characters ... NOTE
45+
```
46+
Note: found 4 marked UTF-8 strings
47+
```
48+

tests/testthat/_snaps/expect-condition.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,14 @@
2525
Message: dispatched!
2626
Class: foobar/rlang_error/error/condition
2727

28+
# unused arguments generate a warning
29+
30+
Code
31+
expect_condition(stop("Hi!"), foo = "bar")
32+
Condition
33+
Warning in `expect_condition()`:
34+
Arguments in `...` must be used.
35+
x Problematic argument:
36+
* foo = "bar"
37+
i Did you misspell an argument name?
38+

tests/testthat/test-expect-condition.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ test_that("can match parent conditions (#1493)", {
212212
expect_error(expect_error(f(), "Parent message.", inherit = FALSE))
213213
})
214214

215+
test_that("unused arguments generate a warning", {
216+
expect_snapshot(expect_condition(stop("Hi!"), foo = "bar"))
217+
})
218+
215219

216220
# second edition ----------------------------------------------------------
217221

0 commit comments

Comments
 (0)