Skip to content

Commit d6fee24

Browse files
Merge pull request #1111 from MichaelChirico/split-roxygen-exec
Add a script for generating many roxygen-examples-complete tests, apply it
2 parents ce89aef + 05c76f4 commit d6fee24

32 files changed

+174
-152
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
^README-.*\.png$
88
^README\.Rmd$
99
^\.Rproj\.user$
10+
^\.dev$
1011
^\.github$
1112
^\.gitsum$
1213
^\.lintr$

tests/dev/gen_roxygen_tests.R

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/Rscript
2+
# execute from package TLD: ./tests/dev/gen_roxygen_tests.R
3+
roxygen_stub <- "roxygen-examples-complete"
4+
all_examples <- list.files(file.path("tests", "testthat", roxygen_stub))
5+
unique_tests <- unique(sub("-.*", "", all_examples))
6+
7+
# tests using 'scope = "spaces"' in test_collection()
8+
tests_scope_spaces <- "15"
9+
10+
condition_map <- list(`23` = c("error", '"issues/1242"'))
11+
12+
for (test in unique_tests) {
13+
out_file <- file.path("tests", "testthat", paste0("test-", roxygen_stub, "-", test, ".R"))
14+
extras <- if (test %in% tests_scope_spaces) ', scope = "spaces"' else ""
15+
condition <- condition_map[[test]]
16+
if (is.null(condition)) condition <- c("warning", "NA")
17+
writeLines(con = out_file, c(
18+
"# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.",
19+
"",
20+
sprintf('test_that("analogous to test-%s: %s", {', roxygen_stub, test),
21+
sprintf(
22+
' expect_%s(test_collection("%s", "^%s-", transformer = style_text%s), %s)',
23+
condition[1L], roxygen_stub, test, extras, condition[2L]
24+
),
25+
"})",
26+
NULL
27+
))
28+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.
2+
3+
test_that("analogous to test-roxygen-examples-complete: 01", {
4+
expect_warning(test_collection("roxygen-examples-complete", "^01-", transformer = style_text), NA)
5+
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.
2+
3+
test_that("analogous to test-roxygen-examples-complete: 02", {
4+
expect_warning(test_collection("roxygen-examples-complete", "^02-", transformer = style_text), NA)
5+
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.
2+
3+
test_that("analogous to test-roxygen-examples-complete: 03", {
4+
expect_warning(test_collection("roxygen-examples-complete", "^03-", transformer = style_text), NA)
5+
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.
2+
3+
test_that("analogous to test-roxygen-examples-complete: 04", {
4+
expect_warning(test_collection("roxygen-examples-complete", "^04-", transformer = style_text), NA)
5+
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.
2+
3+
test_that("analogous to test-roxygen-examples-complete: 05", {
4+
expect_warning(test_collection("roxygen-examples-complete", "^05-", transformer = style_text), NA)
5+
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.
2+
3+
test_that("analogous to test-roxygen-examples-complete: 06", {
4+
expect_warning(test_collection("roxygen-examples-complete", "^06-", transformer = style_text), NA)
5+
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.
2+
3+
test_that("analogous to test-roxygen-examples-complete: 07", {
4+
expect_warning(test_collection("roxygen-examples-complete", "^07-", transformer = style_text), NA)
5+
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.
2+
3+
test_that("analogous to test-roxygen-examples-complete: 08", {
4+
expect_warning(test_collection("roxygen-examples-complete", "^08-", transformer = style_text), NA)
5+
})

0 commit comments

Comments
 (0)