Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a script for generating many roxygen-examples-complete tests, apply it #1111

Merged
merged 10 commits into from
Dec 3, 2023
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
^README-.*\.png$
^README\.Rmd$
^\.Rproj\.user$
^\.dev$
^\.github$
^\.gitsum$
^\.lintr$
Expand Down
28 changes: 28 additions & 0 deletions tests/dev/gen_roxygen_tests.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/Rscript
# execute from package TLD: ./tests/dev/gen_roxygen_tests.R
roxygen_stub <- "roxygen-examples-complete"
all_examples <- list.files(file.path("tests", "testthat", roxygen_stub))
unique_tests <- unique(sub("-.*", "", all_examples))

# tests using 'scope = "spaces"' in test_collection()
tests_scope_spaces <- "15"

condition_map <- list(`23` = c("error", '"issues/1242"'))

for (test in unique_tests) {
out_file <- file.path("tests", "testthat", paste0("test-", roxygen_stub, "-", test, ".R"))
extras <- if (test %in% tests_scope_spaces) ', scope = "spaces"' else ""
condition <- condition_map[[test]]
if (is.null(condition)) condition <- c("warning", "NA")
writeLines(con = out_file, c(
"# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.",
"",
sprintf('test_that("analogous to test-%s: %s", {', roxygen_stub, test),
sprintf(
' expect_%s(test_collection("%s", "^%s-", transformer = style_text%s), %s)',
condition[1L], roxygen_stub, test, extras, condition[2L]
),
"})",
NULL
))
}
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-01.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 01", {
expect_warning(test_collection("roxygen-examples-complete", "^01-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-02.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 02", {
expect_warning(test_collection("roxygen-examples-complete", "^02-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-03.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 03", {
expect_warning(test_collection("roxygen-examples-complete", "^03-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-04.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 04", {
expect_warning(test_collection("roxygen-examples-complete", "^04-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-05.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 05", {
expect_warning(test_collection("roxygen-examples-complete", "^05-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-06.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 06", {
expect_warning(test_collection("roxygen-examples-complete", "^06-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-07.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 07", {
expect_warning(test_collection("roxygen-examples-complete", "^07-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-08.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 08", {
expect_warning(test_collection("roxygen-examples-complete", "^08-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-09.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 09", {
expect_warning(test_collection("roxygen-examples-complete", "^09-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-10.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 10", {
expect_warning(test_collection("roxygen-examples-complete", "^10-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-11.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 11", {
expect_warning(test_collection("roxygen-examples-complete", "^11-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-12.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 12", {
expect_warning(test_collection("roxygen-examples-complete", "^12-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-13.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 13", {
expect_warning(test_collection("roxygen-examples-complete", "^13-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-14.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 14", {
expect_warning(test_collection("roxygen-examples-complete", "^14-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-15.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 15", {
expect_warning(test_collection("roxygen-examples-complete", "^15-", transformer = style_text, scope = "spaces"), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-16.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 16", {
expect_warning(test_collection("roxygen-examples-complete", "^16-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-17.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 17", {
expect_warning(test_collection("roxygen-examples-complete", "^17-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-18.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 18", {
expect_warning(test_collection("roxygen-examples-complete", "^18-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-19.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 19", {
expect_warning(test_collection("roxygen-examples-complete", "^19-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-20.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 20", {
expect_warning(test_collection("roxygen-examples-complete", "^20-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-21.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 21", {
expect_warning(test_collection("roxygen-examples-complete", "^21-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-22.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 22", {
expect_warning(test_collection("roxygen-examples-complete", "^22-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-23.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 23", {
expect_error(test_collection("roxygen-examples-complete", "^23-", transformer = style_text), "issues/1242")
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-24.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 24", {
expect_warning(test_collection("roxygen-examples-complete", "^24-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-25.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 25", {
expect_warning(test_collection("roxygen-examples-complete", "^25-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-26.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 26", {
expect_warning(test_collection("roxygen-examples-complete", "^26-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-27.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 27", {
expect_warning(test_collection("roxygen-examples-complete", "^27-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-28.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 28", {
expect_warning(test_collection("roxygen-examples-complete", "^28-", transformer = style_text), NA)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-roxygen-examples-complete-29.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.

test_that("analogous to test-roxygen-examples-complete: 29", {
expect_warning(test_collection("roxygen-examples-complete", "^29-", transformer = style_text), NA)
})
152 changes: 0 additions & 152 deletions tests/testthat/test-roxygen-examples-complete.R

This file was deleted.

Loading