Skip to content

Commit

Permalink
Merge pull request #56 from Merck/file-src
Browse files Browse the repository at this point in the history
Expand `file_src()` file specification scope
  • Loading branch information
nanxstats authored Sep 27, 2024
2 parents 6d40aa9 + cfdb57e commit 3667507
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 33 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: pkglite
Title: Compact Package Representations
Version: 0.2.3
Version: 0.2.3.9000
Authors@R: c(
person("Nan", "Xiao", email = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-0250-5673")),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export(pack)
export(pattern_file_root_all)
export(pattern_file_root_core)
export(pattern_file_sanitize)
export(pattern_file_src)
export(prune)
export(remove_content)
export(sanitize)
Expand Down
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# pkglite 0.2.3.9000

## Enhancements

- Increase the default file specification coverage for `file_src()`.
This helps identifying the correct file collections for R packages
with `src/Makevars` or `src/Makefile`, for example, packages that
interface with Stan via the rstan package (#56).

# pkglite 0.2.3

## Enhancements
Expand Down
20 changes: 18 additions & 2 deletions R/dictionary.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ext_text <- function(flat = FALSE) {
"src" = c(
"c", "h", "cpp", "cc", "ipp", "cxx", "hpp", "hxx", "hh", "cu", "cuh",
"f", "f90", "f95", "f03",
"win", "in", "ucrt", "ac", "mk", "guess"
"win", "ucrt", "in", "ac", "mk", "guess", "def"
),
"vignette" = c(
"Rmd", "qmd", "orig", "md", "tex", "csl", "Rnw", "Snw", "Rtex", "Stex",
Expand Down Expand Up @@ -165,10 +165,12 @@ pattern_file_root_core <- function() {
"\\.Rinstignore$",
"^configure$",
"^configure\\.win$",
"^configure\\.ucrt$",
"^configure\\.ac$",
"^configure\\.in$",
"^cleanup$",
"^cleanup\\.win$"
"^cleanup\\.win$",
"^cleanup\\.ucrt$"
)
}

Expand All @@ -188,6 +190,20 @@ pattern_file_root_all <- function() {
)
}

#' @rdname file_name_patterns
#' @export pattern_file_src
pattern_file_src <- function() {
c(
"^Makevars$",
"^Makevars\\.win$",
"^Makevars\\.ucrt$",
"^Makefile$",
"^Makefile\\.win$",
"^Makefile\\.ucrt$",
"^CMakeLists\\.txt$"
)
}

#' @rdname file_name_patterns
#' @export pattern_file_sanitize
pattern_file_sanitize <- function() {
Expand Down
9 changes: 8 additions & 1 deletion R/templates.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,17 @@ file_man <- function() {
#' @rdname file_spec_templates
#' @export file_src
file_src <- function() {
file_spec(
spec_make <- file_spec(
path = "src/", pattern = cat_patterns(pattern_file_src()),
format = c("text"), recursive = TRUE, ignore_case = FALSE, all_files = FALSE
)

spec_src <- file_spec(
path = "src/", pattern = cat_patterns(ends_with(ext_text()$"src")),
format = c("text"), recursive = TRUE, ignore_case = TRUE, all_files = FALSE
)

list(spec_make, spec_src)
}

#' @rdname file_spec_templates
Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ reference:
- ext_binary
- pattern_file_root_core
- pattern_file_root_all
- pattern_file_src
- pattern_file_sanitize
- title: "Deprecated"
desc: "Deprecated functions that will be removed"
Expand Down
3 changes: 3 additions & 0 deletions man/file_name_patterns.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions tests/testthat/test-independent-test_dictionary.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_that("Test ext_text() generate the right string list", {
"src" = c(
"c", "h", "cpp", "cc", "ipp", "cxx", "hpp", "hxx", "hh", "cu", "cuh",
"f", "f90", "f95", "f03",
"win", "in", "ucrt", "ac", "mk", "guess"
"win", "ucrt", "in", "ac", "mk", "guess", "def"
),
"vignette" = c(
"Rmd", "qmd", "orig", "md", "tex", "csl", "Rnw", "Snw", "Rtex", "Stex",
Expand Down Expand Up @@ -109,10 +109,12 @@ test_that("Test pattern_file_root_core() generate the right string list", {
"\\.Rinstignore$",
"^configure$",
"^configure\\.win$",
"^configure\\.ucrt$",
"^configure\\.ac$",
"^configure\\.in$",
"^cleanup$",
"^cleanup\\.win$"
"^cleanup\\.win$",
"^cleanup\\.ucrt$"
)

ls_target <- str_ls
Expand Down
84 changes: 61 additions & 23 deletions tests/testthat/test-independent-test_templates.R

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/testthat/test-independent_test_collate.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test_that("fs_to_df returns 0-row data when the file spec is not in the right fo
pkg <- "pkg1"
files <- pkg %>%
find_package() %>%
fs_to_df(file_src())
fs_to_df(file_src()[[2]])
expect_equal(nrow(files), 0L)
})

Expand Down
5 changes: 2 additions & 3 deletions tests/testthat/test-independent_test_collection.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
test_that("is_file_collection detects whether an object is of class
file collection", {
test_that("is_file_collection detects whether an object is of class file collection", {
pkg <- "pkg1"
expect_false(
pkg %>%
find_package() %>%
fs_to_df(file_spec = file_src()) %>%
fs_to_df(file_spec = file_src()[[2]]) %>%
is_file_collection()
)
})
Expand Down

0 comments on commit 3667507

Please sign in to comment.