Skip to content

Commit

Permalink
add test-srr
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Aug 27, 2024
1 parent 9470fed commit 033ef00
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ repos:
- id: no-print-statement
- id: no-debug-statement
- id: deps-in-desc
args: [--allow_private_imports]
# - id: pkgdown
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: roreviewapi
Title: Plumber API to report package structure and function
Version: 0.1.0.029
Version: 0.1.0.030
Authors@R:
person("Mark", "Padgham", , "[email protected]", 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/roreviewapi",
"issueTracker": "https://github.com/ropensci-review-tools/roreviewapi/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.1.0.029",
"version": "0.1.0.030",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
51 changes: 51 additions & 0 deletions tests/testthat/test-srr.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
test_all <- identical (Sys.getenv ("MPADGE_LOCAL"), "true") ||
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage")
testthat::skip_if (!test_all)

test_that ("srr", {
path <- srr::srr_stats_pkg_skeleton ()

expect_message (
srr_rep <- srr::srr_report (path, view = FALSE)
)

counts <- srr_counts_from_report (srr_rep)
expect_true (grepl ("^The following standards are missing", counts))

# Fill all standards, leaving single "TODO":
f <- file.path (path, "R", "srr-stats-standards.R")
x <- readLines (f)
x <- c (x [seq_len (grep ("^NULL", x) [1])], "")
s_todo <- x [grep ("srrstatsNA", x)]
s_todo <- regmatches (s_todo, regexpr ("\\{.*\\}", s_todo))
s_todo <- gsub ("\\{|\\}", "", s_todo)

x_g <- srr:::get_standards_checklists ("general")
x_r <- srr:::get_standards_checklists ("regression")
x_r <- x_r [-(grep (s_todo, x_r, fixed = TRUE))]

x_s <- c (x_g, x_r)
ptn <- "- [ ] **"
x_s <- x_s [grep (ptn, x_s, fixed = TRUE)]
x_s <- gsub (ptn, "#' @srrstats {", x_s [grep (ptn, x_s, fixed = TRUE)], fixed = TRUE)
x_s <- gsub ("\\*\\*G", "{G", x_s)
x_s <- gsub ("\\*\\*R", "{R", x_s)
x_s <- gsub ("\\*\\*", "}", x_s)
x_s <- gsub ("^\\s+\\#", "#", x_s)

writeLines (c (x, x_s, "NULL"), f)

# Also need to re-label "TODO"
f <- file.path (path, "R", "test.R")
x <- gsub ("srrstatsTODO", "srrstats", readLines (f))
writeLines (x, f)

srr_rep <- srr::srr_report (path, view = FALSE)
counts <- srr_counts_from_report (srr_rep)
# No errors, so starts with compliance report:
expect_true (grepl ("^\\#\\#\\s+\\'srr\\' standards compliance", counts))
# Should pass count checks, so state that it may be submitted:
expect_true (grepl ("may be submitted", counts, fixed = TRUE))
# But should include non-zero counts of stds not complied with:
expect_true (grepl ("Not complied with", counts, fixed = TRUE))
})

0 comments on commit 033ef00

Please sign in to comment.