Skip to content

Commit

Permalink
test pkgstats on pkg with tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Oct 24, 2024
1 parent 8125c43 commit 868f70c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: pkgstats
Title: Metrics of R Packages
Version: 0.2.0.045
Version: 0.2.0.046
Authors@R:
person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265"))
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/ropensci-review-tools/pkgstats",
"issueTracker": "https://github.com/ropensci-review-tools/pkgstats/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.2.0.045",
"version": "0.2.0.046",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
33 changes: 33 additions & 0 deletions tests/testthat/test-pkgstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,36 @@ test_that ("pkgstats", {
expect_true ("stats" %in% ext$package)
expect_true (length (unique (ext$package)) > 15L)
})

skip_if (!test_all)

test_that ("pkgstats with tabs", {

if (!test_all) {
Sys.setenv ("PKGSTATS_CRAN_TESTS" = "true")
}

path <- system.file ("extdata", "pkgstats_9.9.tar.gz", package = "pkgstats")
path <- extract_tarball (path)
flist <- fs::dir_ls (fs::path (path, "R"), type = "file", recurse = TRUE)
f <- flist [which (basename (flist) == "loc.R")]
x <- readLines (f)
x <- gsub ("^\\s{12}", "\\\t\\\t\\\t", x)
x <- gsub ("^\\s{8}", "\\\t\\\t", x)
x <- gsub ("^\\s{4}", "\\\t", x)
writeLines (x, f)

# message is now produced once per session by readr, but can only be
# suppressed by Suggesting yet another package, `tidyselect`.
# expect_message (
s <- pkgstats (path)

if (!test_all) {
Sys.unsetenv ("PKGSTATS_CRAN_TESTS")
}

expect_s3_class (s$loc, "tbl_df")
expect_true (s$loc$ntabs [s$loc$dir == "R"] > 0L)

fs::dir_delete (path)
})

0 comments on commit 868f70c

Please sign in to comment.