|
1 | 1 | #!/usr/bin/Rscript
|
2 | 2 | # execute from package TLD: ./.dev/gen_roxygen_tests.R
|
3 |
| -all_examples <- list.files("tests/testthat/roxygen-examples-complete", full.names = TRUE) |
4 |
| -unique_tests <- unique(sub("-.*", "", basename(all_examples))) |
| 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" |
5 | 9 |
|
6 | 10 | for (test in unique_tests) {
|
7 |
| - out_file <- file.path("tests", "testthat", paste0("test-roxygen-examples-complete-", test, ".R")) |
8 |
| - extras <- if (test == "15") ', scope = "spaces"' else "" |
| 11 | + out_file <- file.path("tests", "testthat", paste0("test-", roxygen_stub, "-", test, ".R")) |
| 12 | + extras <- if (test %in% tests_scope_spaces) ', scope = "spaces"' else "" |
9 | 13 | writeLines(con = out_file, c(
|
10 | 14 | "# NB: DO NOT EDIT. Auto-generated by .dev/gen_roxygen_tests.R.",
|
11 | 15 | "",
|
12 |
| - sprintf('test_that("analogous to test-roxygen-examples-complete: %s", {', test), |
13 |
| - sprintf(' expect_warning(test_collection("roxygen-examples-complete", "^%s-", transformer = style_text%s), NA)', test, extras), |
| 16 | + sprintf('test_that("analogous to test-%s: %s", {', roxygen_stub, test), |
| 17 | + sprintf( |
| 18 | + ' expect_warning(test_collection("%s", "^%s-", transformer = style_text%s), NA)', |
| 19 | + roxygen_stub, test, extras |
| 20 | + ), |
14 | 21 | "})",
|
15 | 22 | NULL
|
16 | 23 | ))
|
|
0 commit comments