Here are some tips on aligning file names across R/
and tests/testthat/
in an existing package that did not necessarily follow this convention
before.
This script generates a data frame of R/
and test files that can help you
identify missed opportunities for pairing:
library(fs)
library(tidyverse)bind_rows(
tibble(
type = "R",
path = dir_ls("R/", regexp = "\\.[Rr]$"),
name = as.character(path_ext_remove(path_file(path))),
),
tibble(
type = "test",
path = dir_ls("tests/testthat/", regexp = "/test[^/]+\\.[Rr]$"),
name = as.character(path_ext_remove(str_remove(path_file(path), "^test[-_]"))),
)
) %>%
pivot_wider(names_from = type, values_from = path) %>%
print(n = Inf)
The rename_files()
function can also be helpful.