From 61bf5247f1a3242e55ac9605c8a8505b609db689 Mon Sep 17 00:00:00 2001 From: Nan Xiao Date: Thu, 26 Sep 2024 16:48:17 -0400 Subject: [PATCH 1/5] Increment version number to 0.2.3.9000 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 276a1cd..bd7b802 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "nan.xiao1@merck.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-0250-5673")), From 590b73cdb7b980b2c2163b6fd5e8670f50979095 Mon Sep 17 00:00:00 2001 From: Nan Xiao Date: Thu, 26 Sep 2024 16:51:02 -0400 Subject: [PATCH 2/5] Expand `file_src()` coverage for Makefile --- NAMESPACE | 1 + R/dictionary.R | 20 ++++++++++++++++++-- R/templates.R | 9 ++++++++- man/file_name_patterns.Rd | 3 +++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 1a36827..245a40c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/R/dictionary.R b/R/dictionary.R index 8b9bb1d..8855c88 100644 --- a/R/dictionary.R +++ b/R/dictionary.R @@ -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", @@ -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$" ) } @@ -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() { diff --git a/R/templates.R b/R/templates.R index f2a0b57..e2010c6 100644 --- a/R/templates.R +++ b/R/templates.R @@ -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 diff --git a/man/file_name_patterns.Rd b/man/file_name_patterns.Rd index 81cdb63..a2d1ab4 100644 --- a/man/file_name_patterns.Rd +++ b/man/file_name_patterns.Rd @@ -4,6 +4,7 @@ \alias{file_name_patterns} \alias{pattern_file_root_core} \alias{pattern_file_root_all} +\alias{pattern_file_src} \alias{pattern_file_sanitize} \title{Common File name patterns} \usage{ @@ -11,6 +12,8 @@ pattern_file_root_core() pattern_file_root_all() +pattern_file_src() + pattern_file_sanitize() } \value{ From b42ca0a556698c5d6103af6b1b6e656ae164fa82 Mon Sep 17 00:00:00 2001 From: Nan Xiao Date: Thu, 26 Sep 2024 16:51:48 -0400 Subject: [PATCH 3/5] Update tests to reflect `file_src()` changes --- .../test-independent-test_dictionary.R | 6 +- .../test-independent-test_templates.R | 84 ++++++++++++++----- .../testthat/test-independent_test_collate.R | 2 +- .../test-independent_test_collection.R | 5 +- 4 files changed, 68 insertions(+), 29 deletions(-) diff --git a/tests/testthat/test-independent-test_dictionary.R b/tests/testthat/test-independent-test_dictionary.R index 4ef5fcc..a699ad5 100644 --- a/tests/testthat/test-independent-test_dictionary.R +++ b/tests/testthat/test-independent-test_dictionary.R @@ -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", @@ -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 diff --git a/tests/testthat/test-independent-test_templates.R b/tests/testthat/test-independent-test_templates.R index e5ba662..6a723c3 100644 --- a/tests/testthat/test-independent-test_templates.R +++ b/tests/testthat/test-independent-test_templates.R @@ -2,7 +2,7 @@ test_that("file_root_core() creates the correct 'file_spec' object", { is_root_core <- is_file_spec_type( fs_source = file_root_core(), path = "", - pattern = "^DESCRIPTION$|^NAMESPACE$|^README$|^README\\.Rmd$|^README\\.md$|^NEWS$|^NEWS\\.md$|^LICENSE$|^LICENCE$|^LICENSE\\.note$|^LICENCE\\.note$|\\.Rbuildignore$|\\.Rinstignore$|^configure$|^configure\\.win$|^configure\\.ac$|^configure\\.in$|^cleanup$|^cleanup\\.win$", + pattern = "^DESCRIPTION$|^NAMESPACE$|^README$|^README\\.Rmd$|^README\\.md$|^NEWS$|^NEWS\\.md$|^LICENSE$|^LICENCE$|^LICENSE\\.note$|^LICENCE\\.note$|\\.Rbuildignore$|\\.Rinstignore$|^configure$|^configure\\.win$|^configure\\.ucrt$|^configure\\.ac$|^configure\\.in$|^cleanup$|^cleanup\\.win$|^cleanup\\.ucrt$", format = "text", recursive = FALSE, ignore_case = FALSE, @@ -124,17 +124,28 @@ test_that("file_man() creates the correct 'file_spec' objects", { }) test_that("file_src() creates the correct 'file_spec' object", { - is_src <- is_file_spec_type( - fs_source = file_src(), + is_spec_src_make <- is_file_spec_type( + fs_source = file_src()[[1]], path = "src/", - pattern = "\\.c$|\\.h$|\\.cpp$|\\.cc$|\\.ipp$|\\.cxx$|\\.hpp$|\\.hxx$|\\.hh$|\\.cu$|\\.cuh$|\\.f$|\\.f90$|\\.f95$|\\.f03$|\\.win$|\\.in$|\\.ucrt$|\\.ac$|\\.mk$|\\.guess$", + pattern = "^Makevars$|^Makevars\\.win$|^Makevars\\.ucrt$|^Makefile$|^Makefile\\.win$|^Makefile\\.ucrt$|^CMakeLists\\.txt$", + format = "text", + recursive = TRUE, + ignore_case = FALSE, + all_files = FALSE + ) + + is_spec_src_src <- is_file_spec_type( + fs_source = file_src()[[2]], + path = "src/", + pattern = "\\.c$|\\.h$|\\.cpp$|\\.cc$|\\.ipp$|\\.cxx$|\\.hpp$|\\.hxx$|\\.hh$|\\.cu$|\\.cuh$|\\.f$|\\.f90$|\\.f95$|\\.f03$|\\.win$|\\.ucrt$|\\.in$|\\.ac$|\\.mk$|\\.guess$|\\.def$", format = "text", recursive = TRUE, ignore_case = TRUE, all_files = FALSE ) - expect_equal(is_src, TRUE) + expect_equal(is_spec_src_make, TRUE) + expect_equal(is_spec_src_src, TRUE) }) test_that("file_data() creates the correct 'file_spec' object", { @@ -164,7 +175,7 @@ test_that("file_vignettes() creates the correct 'file_spec' objects", { if (!is_spec_text & is_file_spec_type( fs_source = fs, path = "vignettes/", - pattern = "\\.R$|\\.r$|\\.s$|\\.q$|\\.Rd$|\\.rd$|\\.svg$|\\.c$|\\.h$|\\.cpp$|\\.cc$|\\.ipp$|\\.cxx$|\\.hpp$|\\.hxx$|\\.hh$|\\.cu$|\\.cuh$|\\.f$|\\.f90$|\\.f95$|\\.f03$|\\.win$|\\.in$|\\.ucrt$|\\.ac$|\\.mk$|\\.guess$|\\.Rmd$|\\.qmd$|\\.orig$|\\.md$|\\.tex$|\\.csl$|\\.Rnw$|\\.Snw$|\\.Rtex$|\\.Stex$|\\.rsp$|\\.Rasciidoc$|\\.Rhtml$|\\.lyx$|\\.ltx$|\\.dtx$|\\.cls$|\\.sty$|\\.aux$|\\.bib$|\\.bibtex$|\\.bst$|\\.bbl$|\\.asis$|\\.el$|\\.Rproj$|\\.dcf$|\\.yml$|\\.yaml$|\\.toml$|\\.note$|\\.csv$|\\.tsv$|\\.txt$|\\.ps$|\\.dot$|\\.drawio$|\\.html$|\\.htm$|\\.shtml$|\\.css$|\\.scss$|\\.sass$|\\.less$|\\.js$|\\.cjs$|\\.mjs$|\\.jsx$|\\.wasm$|\\.json$|\\.ndjson$|\\.jsonl$|\\.jsonld$|\\.json5$|\\.topojson$|\\.xml$|\\.xsd$|\\.xsl$|\\.xslt$|\\.dtd$|\\.rtf$|\\.save$|\\.Rout$|\\.log$|\\.stan$|\\.bug$|\\.jags$|\\.py$|\\.ipynb$|\\.sh$|\\.java$|\\.bat$|\\.m4$|\\.cmake$|\\.sql$|\\.graphql$|\\.lua$|\\.rs$|\\.lock$|\\.jl$|\\.pl$|\\.pm$|\\.brew$|\\.scala$|\\.awk$|\\.rb$|\\.sas$|\\.m$|\\.asm$|\\.po$|\\.pot$|\\.geojson$|\\.kml$|\\.prj$|\\.cpg$|\\.qpj$|\\.fasta$|\\.fas$|\\.fa$|\\.faa$|\\.fai$|\\.fastq$|\\.vcf$|\\.ped$|\\.bim$|\\.fam$|\\.gff$|\\.gff3$|\\.gtf$|\\.markdown$|\\.rst$|\\.typ$|\\.ini$|\\.conf$|\\.slurm$|\\.ris$|\\.cff$|\\.fwf$|\\.arff$|\\.graphml$|\\.gexf$", + pattern = "\\.R$|\\.r$|\\.s$|\\.q$|\\.Rd$|\\.rd$|\\.svg$|\\.c$|\\.h$|\\.cpp$|\\.cc$|\\.ipp$|\\.cxx$|\\.hpp$|\\.hxx$|\\.hh$|\\.cu$|\\.cuh$|\\.f$|\\.f90$|\\.f95$|\\.f03$|\\.win$|\\.ucrt$|\\.in$|\\.ac$|\\.mk$|\\.guess$|\\.def$|\\.Rmd$|\\.qmd$|\\.orig$|\\.md$|\\.tex$|\\.csl$|\\.Rnw$|\\.Snw$|\\.Rtex$|\\.Stex$|\\.rsp$|\\.Rasciidoc$|\\.Rhtml$|\\.lyx$|\\.ltx$|\\.dtx$|\\.cls$|\\.sty$|\\.aux$|\\.bib$|\\.bibtex$|\\.bst$|\\.bbl$|\\.asis$|\\.el$|\\.Rproj$|\\.dcf$|\\.yml$|\\.yaml$|\\.toml$|\\.note$|\\.csv$|\\.tsv$|\\.txt$|\\.ps$|\\.dot$|\\.drawio$|\\.html$|\\.htm$|\\.shtml$|\\.css$|\\.scss$|\\.sass$|\\.less$|\\.js$|\\.cjs$|\\.mjs$|\\.jsx$|\\.wasm$|\\.json$|\\.ndjson$|\\.jsonl$|\\.jsonld$|\\.json5$|\\.topojson$|\\.xml$|\\.xsd$|\\.xsl$|\\.xslt$|\\.dtd$|\\.rtf$|\\.save$|\\.Rout$|\\.log$|\\.stan$|\\.bug$|\\.jags$|\\.py$|\\.ipynb$|\\.sh$|\\.java$|\\.bat$|\\.m4$|\\.cmake$|\\.sql$|\\.graphql$|\\.lua$|\\.rs$|\\.lock$|\\.jl$|\\.pl$|\\.pm$|\\.brew$|\\.scala$|\\.awk$|\\.rb$|\\.sas$|\\.m$|\\.asm$|\\.po$|\\.pot$|\\.geojson$|\\.kml$|\\.prj$|\\.cpg$|\\.qpj$|\\.fasta$|\\.fas$|\\.fa$|\\.faa$|\\.fai$|\\.fastq$|\\.vcf$|\\.ped$|\\.bim$|\\.fam$|\\.gff$|\\.gff3$|\\.gtf$|\\.markdown$|\\.rst$|\\.typ$|\\.ini$|\\.conf$|\\.slurm$|\\.ris$|\\.cff$|\\.fwf$|\\.arff$|\\.graphml$|\\.gexf$", format = "text", recursive = TRUE, ignore_case = TRUE, @@ -202,20 +213,21 @@ test_that("file_default() creates the correct 'file_spec' objects", { is_spec_rd <- FALSE is_spec_fig_binary <- FALSE is_spec_fig_text <- FALSE - is_src <- FALSE + is_spec_src_make <- FALSE + is_spec_src_src <- FALSE is_spec_text <- FALSE is_spec_binary <- FALSE is_data <- FALSE fs_len <- length(fs_ls) - if (fs_len == 10) { + if (fs_len == 11) { for (i in seq_len(fs_len)) { fs <- fs_ls[[i]] if (!is_root_core & is_file_spec_type( fs_source = fs, path = "", - pattern = "^DESCRIPTION$|^NAMESPACE$|^README$|^README\\.Rmd$|^README\\.md$|^NEWS$|^NEWS\\.md$|^LICENSE$|^LICENCE$|^LICENSE\\.note$|^LICENCE\\.note$|\\.Rbuildignore$|\\.Rinstignore$|^configure$|^configure\\.win$|^configure\\.ac$|^configure\\.in$|^cleanup$|^cleanup\\.win$", + pattern = "^DESCRIPTION$|^NAMESPACE$|^README$|^README\\.Rmd$|^README\\.md$|^NEWS$|^NEWS\\.md$|^LICENSE$|^LICENCE$|^LICENSE\\.note$|^LICENCE\\.note$|\\.Rbuildignore$|\\.Rinstignore$|^configure$|^configure\\.win$|^configure\\.ucrt$|^configure\\.ac$|^configure\\.in$|^cleanup$|^cleanup\\.win$|^cleanup\\.ucrt$", format = "text", recursive = FALSE, ignore_case = FALSE, @@ -282,21 +294,33 @@ test_that("file_default() creates the correct 'file_spec' objects", { ) { is_spec_fig_text <- TRUE } else if - (!is_src & is_file_spec_type( + (!is_spec_src_make & is_file_spec_type( + fs_source = fs, + path = "src/", + pattern = "^Makevars$|^Makevars\\.win$|^Makevars\\.ucrt$|^Makefile$|^Makefile\\.win$|^Makefile\\.ucrt$|^CMakeLists\\.txt$", + format = "text", + recursive = TRUE, + ignore_case = FALSE, + all_files = FALSE + ) + ) { + is_spec_src_make <- TRUE + } else if + (!is_spec_src_src & is_file_spec_type( fs_source = fs, path = "src/", - pattern = "\\.c$|\\.h$|\\.cpp$|\\.cc$|\\.ipp$|\\.cxx$|\\.hpp$|\\.hxx$|\\.hh$|\\.cu$|\\.cuh$|\\.f$|\\.f90$|\\.f95$|\\.f03$|\\.win$|\\.in$|\\.ucrt$|\\.ac$|\\.mk$|\\.guess$", + pattern = "\\.c$|\\.h$|\\.cpp$|\\.cc$|\\.ipp$|\\.cxx$|\\.hpp$|\\.hxx$|\\.hh$|\\.cu$|\\.cuh$|\\.f$|\\.f90$|\\.f95$|\\.f03$|\\.win$|\\.ucrt$|\\.in$|\\.ac$|\\.mk$|\\.guess$|\\.def$", format = "text", recursive = TRUE, ignore_case = TRUE, all_files = FALSE ) ) { - is_src <- TRUE + is_spec_src_src <- TRUE } else if (!is_spec_text & is_file_spec_type( fs_source = fs, path = "vignettes/", - pattern = "\\.R$|\\.r$|\\.s$|\\.q$|\\.Rd$|\\.rd$|\\.svg$|\\.c$|\\.h$|\\.cpp$|\\.cc$|\\.ipp$|\\.cxx$|\\.hpp$|\\.hxx$|\\.hh$|\\.cu$|\\.cuh$|\\.f$|\\.f90$|\\.f95$|\\.f03$|\\.win$|\\.in$|\\.ucrt$|\\.ac$|\\.mk$|\\.guess$|\\.Rmd$|\\.qmd$|\\.orig$|\\.md$|\\.tex$|\\.csl$|\\.Rnw$|\\.Snw$|\\.Rtex$|\\.Stex$|\\.rsp$|\\.Rasciidoc$|\\.Rhtml$|\\.lyx$|\\.ltx$|\\.dtx$|\\.cls$|\\.sty$|\\.aux$|\\.bib$|\\.bibtex$|\\.bst$|\\.bbl$|\\.asis$|\\.el$|\\.Rproj$|\\.dcf$|\\.yml$|\\.yaml$|\\.toml$|\\.note$|\\.csv$|\\.tsv$|\\.txt$|\\.ps$|\\.dot$|\\.drawio$|\\.html$|\\.htm$|\\.shtml$|\\.css$|\\.scss$|\\.sass$|\\.less$|\\.js$|\\.cjs$|\\.mjs$|\\.jsx$|\\.wasm$|\\.json$|\\.ndjson$|\\.jsonl$|\\.jsonld$|\\.json5$|\\.topojson$|\\.xml$|\\.xsd$|\\.xsl$|\\.xslt$|\\.dtd$|\\.rtf$|\\.save$|\\.Rout$|\\.log$|\\.stan$|\\.bug$|\\.jags$|\\.py$|\\.ipynb$|\\.sh$|\\.java$|\\.bat$|\\.m4$|\\.cmake$|\\.sql$|\\.graphql$|\\.lua$|\\.rs$|\\.lock$|\\.jl$|\\.pl$|\\.pm$|\\.brew$|\\.scala$|\\.awk$|\\.rb$|\\.sas$|\\.m$|\\.asm$|\\.po$|\\.pot$|\\.geojson$|\\.kml$|\\.prj$|\\.cpg$|\\.qpj$|\\.fasta$|\\.fas$|\\.fa$|\\.faa$|\\.fai$|\\.fastq$|\\.vcf$|\\.ped$|\\.bim$|\\.fam$|\\.gff$|\\.gff3$|\\.gtf$|\\.markdown$|\\.rst$|\\.typ$|\\.ini$|\\.conf$|\\.slurm$|\\.ris$|\\.cff$|\\.fwf$|\\.arff$|\\.graphml$|\\.gexf$", + pattern = "\\.R$|\\.r$|\\.s$|\\.q$|\\.Rd$|\\.rd$|\\.svg$|\\.c$|\\.h$|\\.cpp$|\\.cc$|\\.ipp$|\\.cxx$|\\.hpp$|\\.hxx$|\\.hh$|\\.cu$|\\.cuh$|\\.f$|\\.f90$|\\.f95$|\\.f03$|\\.win$|\\.ucrt$|\\.in$|\\.ac$|\\.mk$|\\.guess$|\\.def$|\\.Rmd$|\\.qmd$|\\.orig$|\\.md$|\\.tex$|\\.csl$|\\.Rnw$|\\.Snw$|\\.Rtex$|\\.Stex$|\\.rsp$|\\.Rasciidoc$|\\.Rhtml$|\\.lyx$|\\.ltx$|\\.dtx$|\\.cls$|\\.sty$|\\.aux$|\\.bib$|\\.bibtex$|\\.bst$|\\.bbl$|\\.asis$|\\.el$|\\.Rproj$|\\.dcf$|\\.yml$|\\.yaml$|\\.toml$|\\.note$|\\.csv$|\\.tsv$|\\.txt$|\\.ps$|\\.dot$|\\.drawio$|\\.html$|\\.htm$|\\.shtml$|\\.css$|\\.scss$|\\.sass$|\\.less$|\\.js$|\\.cjs$|\\.mjs$|\\.jsx$|\\.wasm$|\\.json$|\\.ndjson$|\\.jsonl$|\\.jsonld$|\\.json5$|\\.topojson$|\\.xml$|\\.xsd$|\\.xsl$|\\.xslt$|\\.dtd$|\\.rtf$|\\.save$|\\.Rout$|\\.log$|\\.stan$|\\.bug$|\\.jags$|\\.py$|\\.ipynb$|\\.sh$|\\.java$|\\.bat$|\\.m4$|\\.cmake$|\\.sql$|\\.graphql$|\\.lua$|\\.rs$|\\.lock$|\\.jl$|\\.pl$|\\.pm$|\\.brew$|\\.scala$|\\.awk$|\\.rb$|\\.sas$|\\.m$|\\.asm$|\\.po$|\\.pot$|\\.geojson$|\\.kml$|\\.prj$|\\.cpg$|\\.qpj$|\\.fasta$|\\.fas$|\\.fa$|\\.faa$|\\.fai$|\\.fastq$|\\.vcf$|\\.ped$|\\.bim$|\\.fam$|\\.gff$|\\.gff3$|\\.gtf$|\\.markdown$|\\.rst$|\\.typ$|\\.ini$|\\.conf$|\\.slurm$|\\.ris$|\\.cff$|\\.fwf$|\\.arff$|\\.graphml$|\\.gexf$", format = "text", recursive = TRUE, ignore_case = TRUE, @@ -332,14 +356,14 @@ test_that("file_default() creates the correct 'file_spec' objects", { } } - expect_equal(is_root_core, TRUE) expect_equal(is_spec_code, TRUE) expect_equal(is_spec_data, TRUE) expect_equal(is_spec_rd, TRUE) expect_equal(is_spec_fig_binary, TRUE) expect_equal(is_spec_fig_text, TRUE) - expect_equal(is_src, TRUE) + expect_equal(is_spec_src_make, TRUE) + expect_equal(is_spec_src_src, TRUE) expect_equal(is_spec_text, TRUE) expect_equal(is_spec_binary, TRUE) expect_equal(is_data, TRUE) @@ -356,18 +380,19 @@ test_that("file_ectd() creates the correct 'file_spec' objects", { is_spec_rd <- FALSE is_spec_fig_binary <- FALSE is_spec_fig_text <- FALSE - is_src <- FALSE + is_spec_src_make <- FALSE + is_spec_src_src <- FALSE is_data <- FALSE fs_len <- length(fs_ls) - if (fs_len == 8) { + if (fs_len == 9) { for (i in seq_len(fs_len)) { fs <- fs_ls[[i]] if (!is_root_core & is_file_spec_type( fs_source = fs, path = "", - pattern = "^DESCRIPTION$|^NAMESPACE$|^README$|^README\\.Rmd$|^README\\.md$|^NEWS$|^NEWS\\.md$|^LICENSE$|^LICENCE$|^LICENSE\\.note$|^LICENCE\\.note$|\\.Rbuildignore$|\\.Rinstignore$|^configure$|^configure\\.win$|^configure\\.ac$|^configure\\.in$|^cleanup$|^cleanup\\.win$", + pattern = "^DESCRIPTION$|^NAMESPACE$|^README$|^README\\.Rmd$|^README\\.md$|^NEWS$|^NEWS\\.md$|^LICENSE$|^LICENCE$|^LICENSE\\.note$|^LICENCE\\.note$|\\.Rbuildignore$|\\.Rinstignore$|^configure$|^configure\\.win$|^configure\\.ucrt$|^configure\\.ac$|^configure\\.in$|^cleanup$|^cleanup\\.win$|^cleanup\\.ucrt$", format = "text", recursive = FALSE, ignore_case = FALSE, @@ -434,17 +459,29 @@ test_that("file_ectd() creates the correct 'file_spec' objects", { ) { is_spec_fig_text <- TRUE } else if - (!is_src & is_file_spec_type( + (!is_spec_src_make & is_file_spec_type( + fs_source = fs, + path = "src/", + pattern = "^Makevars$|^Makevars\\.win$|^Makevars\\.ucrt$|^Makefile$|^Makefile\\.win$|^Makefile\\.ucrt$|^CMakeLists\\.txt$", + format = "text", + recursive = TRUE, + ignore_case = FALSE, + all_files = FALSE + ) + ) { + is_spec_src_make <- TRUE + } else if + (!is_spec_src_src & is_file_spec_type( fs_source = fs, path = "src/", - pattern = "\\.c$|\\.h$|\\.cpp$|\\.cc$|\\.ipp$|\\.cxx$|\\.hpp$|\\.hxx$|\\.hh$|\\.cu$|\\.cuh$|\\.f$|\\.f90$|\\.f95$|\\.f03$|\\.win$|\\.in$|\\.ucrt$|\\.ac$|\\.mk$|\\.guess$", + pattern = "\\.c$|\\.h$|\\.cpp$|\\.cc$|\\.ipp$|\\.cxx$|\\.hpp$|\\.hxx$|\\.hh$|\\.cu$|\\.cuh$|\\.f$|\\.f90$|\\.f95$|\\.f03$|\\.win$|\\.ucrt$|\\.in$|\\.ac$|\\.mk$|\\.guess$|\\.def$", format = "text", recursive = TRUE, ignore_case = TRUE, all_files = FALSE ) ) { - is_src <- TRUE + is_spec_src_src <- TRUE } else if (!is_data & is_file_spec_type( fs_source = fs, @@ -467,7 +504,8 @@ test_that("file_ectd() creates the correct 'file_spec' objects", { expect_equal(is_spec_rd, TRUE) expect_equal(is_spec_fig_binary, TRUE) expect_equal(is_spec_fig_text, TRUE) - expect_equal(is_src, TRUE) + expect_equal(is_spec_src_make, TRUE) + expect_equal(is_spec_src_src, TRUE) expect_equal(is_data, TRUE) }) @@ -484,7 +522,7 @@ test_that("file_auto() creates the correct 'file_spec' objects", { if (!is_spec_text & is_file_spec_type( fs_source = fs, path = "inst/", - pattern = "\\.R$|\\.r$|\\.s$|\\.q$|\\.Rd$|\\.rd$|\\.svg$|\\.c$|\\.h$|\\.cpp$|\\.cc$|\\.ipp$|\\.cxx$|\\.hpp$|\\.hxx$|\\.hh$|\\.cu$|\\.cuh$|\\.f$|\\.f90$|\\.f95$|\\.f03$|\\.win$|\\.in$|\\.ucrt$|\\.ac$|\\.mk$|\\.guess$|\\.Rmd$|\\.qmd$|\\.orig$|\\.md$|\\.tex$|\\.csl$|\\.Rnw$|\\.Snw$|\\.Rtex$|\\.Stex$|\\.rsp$|\\.Rasciidoc$|\\.Rhtml$|\\.lyx$|\\.ltx$|\\.dtx$|\\.cls$|\\.sty$|\\.aux$|\\.bib$|\\.bibtex$|\\.bst$|\\.bbl$|\\.asis$|\\.el$|\\.Rproj$|\\.dcf$|\\.yml$|\\.yaml$|\\.toml$|\\.note$|\\.csv$|\\.tsv$|\\.txt$|\\.ps$|\\.dot$|\\.drawio$|\\.html$|\\.htm$|\\.shtml$|\\.css$|\\.scss$|\\.sass$|\\.less$|\\.js$|\\.cjs$|\\.mjs$|\\.jsx$|\\.wasm$|\\.json$|\\.ndjson$|\\.jsonl$|\\.jsonld$|\\.json5$|\\.topojson$|\\.xml$|\\.xsd$|\\.xsl$|\\.xslt$|\\.dtd$|\\.rtf$|\\.save$|\\.Rout$|\\.log$|\\.stan$|\\.bug$|\\.jags$|\\.py$|\\.ipynb$|\\.sh$|\\.java$|\\.bat$|\\.m4$|\\.cmake$|\\.sql$|\\.graphql$|\\.lua$|\\.rs$|\\.lock$|\\.jl$|\\.pl$|\\.pm$|\\.brew$|\\.scala$|\\.awk$|\\.rb$|\\.sas$|\\.m$|\\.asm$|\\.po$|\\.pot$|\\.geojson$|\\.kml$|\\.prj$|\\.cpg$|\\.qpj$|\\.fasta$|\\.fas$|\\.fa$|\\.faa$|\\.fai$|\\.fastq$|\\.vcf$|\\.ped$|\\.bim$|\\.fam$|\\.gff$|\\.gff3$|\\.gtf$|\\.markdown$|\\.rst$|\\.typ$|\\.ini$|\\.conf$|\\.slurm$|\\.ris$|\\.cff$|\\.fwf$|\\.arff$|\\.graphml$|\\.gexf$", + pattern = "\\.R$|\\.r$|\\.s$|\\.q$|\\.Rd$|\\.rd$|\\.svg$|\\.c$|\\.h$|\\.cpp$|\\.cc$|\\.ipp$|\\.cxx$|\\.hpp$|\\.hxx$|\\.hh$|\\.cu$|\\.cuh$|\\.f$|\\.f90$|\\.f95$|\\.f03$|\\.win$|\\.ucrt$|\\.in$|\\.ac$|\\.mk$|\\.guess$|\\.def$|\\.Rmd$|\\.qmd$|\\.orig$|\\.md$|\\.tex$|\\.csl$|\\.Rnw$|\\.Snw$|\\.Rtex$|\\.Stex$|\\.rsp$|\\.Rasciidoc$|\\.Rhtml$|\\.lyx$|\\.ltx$|\\.dtx$|\\.cls$|\\.sty$|\\.aux$|\\.bib$|\\.bibtex$|\\.bst$|\\.bbl$|\\.asis$|\\.el$|\\.Rproj$|\\.dcf$|\\.yml$|\\.yaml$|\\.toml$|\\.note$|\\.csv$|\\.tsv$|\\.txt$|\\.ps$|\\.dot$|\\.drawio$|\\.html$|\\.htm$|\\.shtml$|\\.css$|\\.scss$|\\.sass$|\\.less$|\\.js$|\\.cjs$|\\.mjs$|\\.jsx$|\\.wasm$|\\.json$|\\.ndjson$|\\.jsonl$|\\.jsonld$|\\.json5$|\\.topojson$|\\.xml$|\\.xsd$|\\.xsl$|\\.xslt$|\\.dtd$|\\.rtf$|\\.save$|\\.Rout$|\\.log$|\\.stan$|\\.bug$|\\.jags$|\\.py$|\\.ipynb$|\\.sh$|\\.java$|\\.bat$|\\.m4$|\\.cmake$|\\.sql$|\\.graphql$|\\.lua$|\\.rs$|\\.lock$|\\.jl$|\\.pl$|\\.pm$|\\.brew$|\\.scala$|\\.awk$|\\.rb$|\\.sas$|\\.m$|\\.asm$|\\.po$|\\.pot$|\\.geojson$|\\.kml$|\\.prj$|\\.cpg$|\\.qpj$|\\.fasta$|\\.fas$|\\.fa$|\\.faa$|\\.fai$|\\.fastq$|\\.vcf$|\\.ped$|\\.bim$|\\.fam$|\\.gff$|\\.gff3$|\\.gtf$|\\.markdown$|\\.rst$|\\.typ$|\\.ini$|\\.conf$|\\.slurm$|\\.ris$|\\.cff$|\\.fwf$|\\.arff$|\\.graphml$|\\.gexf$", format = "text", recursive = TRUE, ignore_case = TRUE, diff --git a/tests/testthat/test-independent_test_collate.R b/tests/testthat/test-independent_test_collate.R index 0873a39..33c6815 100644 --- a/tests/testthat/test-independent_test_collate.R +++ b/tests/testthat/test-independent_test_collate.R @@ -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) }) diff --git a/tests/testthat/test-independent_test_collection.R b/tests/testthat/test-independent_test_collection.R index 665aaab..dce632c 100644 --- a/tests/testthat/test-independent_test_collection.R +++ b/tests/testthat/test-independent_test_collection.R @@ -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() ) }) From 95cfbaac0b77ace167f18cfaa164a8088ec649c0 Mon Sep 17 00:00:00 2001 From: Nan Xiao Date: Thu, 26 Sep 2024 16:52:01 -0400 Subject: [PATCH 4/5] Add `pattern_file_src()` --- _pkgdown.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/_pkgdown.yml b/_pkgdown.yml index 32cbb60..9163420 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -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" From cfdb57ed43c8ff2615fb7693a59cf19d57234638 Mon Sep 17 00:00:00 2001 From: Nan Xiao Date: Thu, 26 Sep 2024 16:52:11 -0400 Subject: [PATCH 5/5] Update news for `file_src()` --- NEWS.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/NEWS.md b/NEWS.md index 8bab17f..59aba01 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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