Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc982aba

Browse files
committed
Switch to expect_snapshot(error = TRUE)
1 parent8bd8d7a commitc982aba

15 files changed

+242
-64
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#find_package_root errors
2+
3+
Code
4+
find_package_root("file1716b354e464b")
5+
Condition
6+
Error:
7+
! Path does not exist: file1716b354e464b
8+
9+
---
10+
11+
Code
12+
find_package_root("/")
13+
Condition
14+
Error:
15+
! Could not find R package in `/` or its parent directories.
16+

‎tests/testthat/_snaps/git-protocol.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626

2727
#git_list_files
2828

29+
Code
30+
git_list_files(fake_git$url("/pak-test.git"), "foobar")
31+
Condition
32+
Error:
33+
! Unknown git ref: "foobar".
34+
35+
---
36+
2937
Code
3038
git_list_files(fake_git$url("/pak-test.git"),
3139
"cefdc0eebcd7f757efb9a80652fd8aaf1a87508e")

‎tests/testthat/_snaps/install-plan-parts.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,24 @@
7575
Error:
7676
! Failed to install binary package R6.
7777

78+
#start_task
79+
80+
Code
81+
start_task(list(), task("foobar"))
82+
Condition
83+
Error:
84+
! Unknown task: "foobar".
85+
i This is an internal error in pkgdepends, please report an issue at <https://github.com/r-lib/pkgdepends/issues>.
86+
87+
#stop_task
88+
89+
Code
90+
stop_task(list(), list(task = task("foobar")))
91+
Condition
92+
Error:
93+
! Unknown task: "foobar".
94+
i This is an internal error in pkgdepends, please report an issue at <https://github.com/r-lib/pkgdepends/issues>.
95+
7896
#deadlock detection
7997

8098
Code

‎tests/testthat/_snaps/pkg-lockfile.md‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,32 @@
1313
(use `$draw()` to draw the dependency tree)
1414
(use `$download()` to download packages)
1515

16+
---
17+
18+
Code
19+
plan$resolve()
20+
Condition
21+
Error:
22+
! Cannot resolve an installation plan, it is already resolved.
23+
Code
24+
plan$async_resolve()
25+
Condition
26+
Error:
27+
! Cannot resolve an installation plan, it is already resolved.
28+
29+
---
30+
31+
Code
32+
plan$set_solve_policy()
33+
Condition
34+
Error:
35+
! Cannot solve an installation plan, it is already solved.
36+
Code
37+
plan$solve()
38+
Condition
39+
Error:
40+
! Cannot solve an installation plan, it is already solved.
41+
1642
#sysreqs
1743

1844
Code
@@ -28,6 +54,32 @@
2854
(use `$draw()` to draw the dependency tree)
2955
(use `$download()` to download packages)
3056

57+
---
58+
59+
Code
60+
plan$resolve()
61+
Condition
62+
Error:
63+
! Cannot resolve an installation plan, it is already resolved.
64+
Code
65+
plan$async_resolve()
66+
Condition
67+
Error:
68+
! Cannot resolve an installation plan, it is already resolved.
69+
70+
---
71+
72+
Code
73+
plan$set_solve_policy()
74+
Condition
75+
Error:
76+
! Cannot solve an installation plan, it is already solved.
77+
Code
78+
plan$solve()
79+
Condition
80+
Error:
81+
! Cannot solve an installation plan, it is already solved.
82+
3183
#install_sysreqs
3284

3385
Code

‎tests/testthat/_snaps/pkg-name-check.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
#async_pkg_name_check
2+
3+
Code
4+
sy(async_pkg_name_check(11))
5+
Condition
6+
Error:
7+
! `name` must be a string (character scalar), but it is a number.
8+
Code
9+
sy(async_pkg_name_check(c("a", "b")))
10+
Condition
11+
Error:
12+
! `name` must be a string (character scalar), but it is a character vector.
13+
Code
14+
sy(async_pkg_name_check(NA_character_))
15+
Condition
16+
Error:
17+
! `name` must not be `NA`.
18+
Code
19+
sy(async_pkg_name_check("x", 11))
20+
Condition
21+
Error:
22+
! One of `is.null(dictionaries)` and `is_character(dictionaries)` must be true.
23+
Code
24+
sy(async_pkg_name_check("x", NA_character_))
25+
Condition
26+
Error:
27+
! One of `is.null(dictionaries)` and `is_character(dictionaries)` must be true.
28+
129
#print.pkg_name_check
230

331
Code

‎tests/testthat/_snaps/scan-deps-queries.md‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,24 @@
5151
# A data frame: 18 x 11
5252
id pattern match start_byte end_byte start_row start_column end_row end_column name code
5353
<int> <int> <int> <int> <int> <int> <int> <int> <int> <chr> <chr>
54-
1 2 1 11121 22 213 dep-code "import(\"A\")"
55-
2 1 1 11116 22 28 fn-name "import"
56-
3 2 1 22432 32 311 dep-code "import(B)"
57-
4 1 1 22429 32 38 fn-name "import"
58-
5 2 1 33552 42 420 dep-code "import(from = \"C\")"
59-
6 1 1 33540 42 48 fn-name "import"
60-
7 2 1 45578 52 526 dep-code "import(symbol, from = D)"
61-
8 1 1 45560 52 58 fn-name "import"
62-
9 2 1 5163173 10 1 10 12 dep-code "import(\"e\")"
63-
10 1 1 5163168 10 1 10 7 fn-name "import"
64-
11 2 1 6175183 11 1 11 10 dep-code "import(f)"
65-
12 1 1 6175180 11 1 11 7 fn-name "import"
66-
13 2 2 7263282 15 1 15 21 dep-code "modules::import(\"G\")"
67-
14 3 2 7263269 15 1 15 8 ns-name "modules"
68-
15 1 2 7272277 15 10 15 16 fn-name "import"
69-
16 2 2 8284301 16 1 16 19 dep-code "modules::import(H)"
70-
17 3 2 8284290 16 1 16 8 ns-name "modules"
71-
18 1 2 8293298 16 10 16 16 fn-name "import"
54+
1 2 1 11222 23 214 dep-code "import(\"A\")"
55+
2 1 1 11217 23 29 fn-name "import"
56+
3 2 1 22634 33 312 dep-code "import(B)"
57+
4 1 1 22631 33 39 fn-name "import"
58+
5 2 1 33855 43 421 dep-code "import(from = \"C\")"
59+
6 1 1 33843 43 49 fn-name "import"
60+
7 2 1 45982 53 527 dep-code "import(symbol, from = D)"
61+
8 1 1 45964 53 59 fn-name "import"
62+
9 2 1 5167177 10 1 10 12 dep-code "import(\"e\")"
63+
10 1 1 5167172 10 1 10 7 fn-name "import"
64+
11 2 1 6179187 11 1 11 10 dep-code "import(f)"
65+
12 1 1 6179184 11 1 11 7 fn-name "import"
66+
13 2 2 7267286 15 1 15 21 dep-code "modules::import(\"G\")"
67+
14 3 2 7267273 15 1 15 8 ns-name "modules"
68+
15 1 2 7276281 15 10 15 16 fn-name "import"
69+
16 2 2 8288305 16 1 16 19 dep-code "modules::import(H)"
70+
17 3 2 8288294 16 1 16 8 ns-name "modules"
71+
18 1 2 8297302 16 10 16 16 fn-name "import"
7272
Code
7373
do("fixtures/scan/modules-empty.R")
7474
Output

‎tests/testthat/_snaps/scan-deps.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@
124124
scan_path_deps_do_r(readLines(rfile), rfile)
125125
Output
126126
# A data frame: 2 x 9
127-
path ref package version type code start_row start_column start_byte
128-
<chr> <chr> <chr> <chr> <chr> <chr> <int> <int> <int>
129-
1 fixtures/scan/methods.R methods methods * prod "setClass(\"track\", slots = c(x=\"numeric\", y=\"numeric\"))" 2 10 43
130-
2 fixtures/scan/methods.R methods methods * prod "setGeneric(\"plot\")" 6 1171
127+
path ref package version type codestart_row start_column start_byte
128+
<chr> <chr> <chr> <chr> <chr> <chr><int> <int> <int>
129+
1 fixtures/scan/methods.R methods methods * prod "setClass(\"track\", slots = c(x =\"numeric\", y =\"numeric\"))" 2 10 43
130+
2 fixtures/scan/methods.R methods methods * prod "setGeneric(\"plot\")"6 1175
131131

132132
#scan_path_deps_do_jr_hits
133133

‎tests/testthat/_snaps/utils.md‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,45 @@
77
[6] "KernSmooth" "lattice" "MASS" "Matrix" "mgcv"
88
[11] "nlme" "nnet" "rpart" "spatial" "survival"
99

10+
#vlapply
11+
12+
Code
13+
vlapply(l, identity)
14+
Condition
15+
Error in `vapply()`:
16+
! values must be length 1,
17+
but FUN(X[[1]]) result is length 0
18+
Code
19+
vlapply(1:5, identity)
20+
Condition
21+
Error in `vapply()`:
22+
! values must be type 'logical',
23+
but FUN(X[[1]]) result is type 'integer'
24+
25+
#viapply
26+
27+
Code
28+
viapply(c(a = 1L, b = 2L), function(x) 1)
29+
Condition
30+
Error in `vapply()`:
31+
! values must be type 'integer',
32+
but FUN(X[[1]]) result is type 'double'
33+
34+
#vdapply
35+
36+
Code
37+
vdapply(l, identity)
38+
Condition
39+
Error in `vapply()`:
40+
! values must be length 1,
41+
but FUN(X[[1]]) result is length 0
42+
Code
43+
vdapply(letters, identity)
44+
Condition
45+
Error in `vapply()`:
46+
! values must be type 'double',
47+
but FUN(X[[1]]) result is type 'character'
48+
1049
#cat0
1150

1251
Code
@@ -90,6 +129,19 @@
90129
3 <dbl [1]> <NA> <chr [1]>
91130
4 <dbl [1]> <NA> <chr [1]>
92131

132+
#update_named_vector
133+
134+
Code
135+
update_named_vector(1, c(a = 1))
136+
Condition
137+
Error:
138+
! All elements in `old` must be named.
139+
Code
140+
update_named_vector(c(a = 1), 1)
141+
Condition
142+
Error:
143+
! All elements in `new` must be named.
144+
93145
#once_per_session
94146

95147
Code

‎tests/testthat/test-find-package-root.R‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,9 @@ test_that("find_package_root", {
3636
})
3737

3838
test_that("find_package_root errors", {
39-
expect_error(
40-
find_package_root(basename(tempfile())),
41-
"Path does not exist"
42-
)
39+
expect_snapshot(error=TRUE, find_package_root("file1716b354e464b"))
4340

4441
if (!file.exists("/DESCRIPTION")) {
45-
expect_error(
46-
find_package_root("/"),
47-
"Could not find R package"
48-
)
42+
expect_snapshot(error=TRUE, find_package_root("/"))
4943
}
5044
})

‎tests/testthat/test-git-protocol.R‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ test_that("git_list_refs", {
1717

1818
test_that("git_list_files", {
1919
skip_on_cran()
20-
expect_error(
20+
expect_snapshot(error=TRUE, {
2121
git_list_files(
2222
fake_git$url("/pak-test.git"),
2323
"foobar"
24-
),
25-
"Unknown git ref"
26-
)
24+
)
25+
})
2726
if (!l10n_info()[["UTF-8"]]) skip("UTF-8 snapshot")
2827
expect_snapshot({
2928
git_list_files(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp