Skip to content

Commit 01f0384

Browse files
authored
Test upkeep (#2647)
* Prevent output from escaping by switching to `expect_snapshot()` * Run tests in parallel
1 parent 119c46f commit 01f0384

5 files changed

Lines changed: 38 additions & 33 deletions

File tree

‎DESCRIPTION‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ VignetteBuilder:
6565
knitr
6666
Config/Needs/website: tidyverse/tidytemplate
6767
Config/testthat/edition: 3
68+
Config/testthat/parallel: true
6869
Encoding: UTF-8
6970
Language: en-US
7071
Roxygen: list(markdown = TRUE)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Package pkgdown site can be built
2+
3+
Code
4+
build_site(path = "testPkgdown", override = list(destination = destination))
5+
Message
6+
-- Installing package testPkgdown into temporary library -----------------------
7+
-- Finished building pkgdown site for package testPkgdown ----------------------
8+

‎tests/testthat/_snaps/check-doc.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# check_man works
2+
3+
Code
4+
check_man(pkg)
5+
Message
6+
i Updating {package} documentation
7+
i Loading {package}
8+
i Checking documentation...
9+
Output
10+
Rd files without \alias:
11+
'foo.Rd'
12+
Rd files without \description:
13+
'foo.Rd'
14+
Argument items with no description in Rd file 'foo.Rd':
15+
'foo'
16+
Undocumented arguments in Rd file 'foo.Rd'
17+
'x'
18+
19+

‎tests/testthat/test-build-site.R‎

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,13 @@ test_that("Package pkgdown site can be built ", {
55

66
destination <- path(tempdir(), "testPkgdown", "docs")
77

8-
build_output <- capture.output(
9-
{
10-
build_site(
11-
path = "testPkgdown",
12-
override = list(destination = destination)
13-
)
14-
},
15-
type = c("output")
16-
)
8+
expect_snapshot(build_site(
9+
path = "testPkgdown",
10+
override = list(destination = destination)
11+
))
1712

18-
build_output <- paste(build_output, collapse = "\n")
19-
20-
expect_true(
21-
file_exists(path(destination, "index.html")),
22-
info = build_output,
23-
label = "created site index"
24-
)
25-
expect_true(
26-
file_exists(path(destination, "reference", "index.html")),
27-
info = build_output,
28-
label = "created reference index"
29-
)
30-
expect_true(
31-
file_exists(path(destination, "articles", "index.html")),
32-
info = build_output,
33-
label = "created articles index"
34-
)
35-
expect_true(
36-
file_exists(path(destination, "articles", "test.html")),
37-
info = build_output,
38-
label = "created articles index"
39-
)
13+
expect_true(file_exists(path(destination, "index.html")))
14+
expect_true(file_exists(path(destination, "reference", "index.html")))
15+
expect_true(file_exists(path(destination, "articles", "index.html")))
16+
expect_true(file_exists(path(destination, "articles", "test.html")))
4017
})

‎tests/testthat/test-check-doc.R‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ foo(x)
2121
file.path(pkg, "man", "foo.Rd")
2222
)
2323

24-
expect_output(
24+
expect_snapshot(
2525
check_man(pkg),
26-
"Undocumented arguments"
26+
transform = \(x) gsub(basename(pkg), "{package}", x, fixed = TRUE)
2727
)
2828
})

0 commit comments

Comments
 (0)