Skip to content

Commit

Permalink
test memoise global assign operator for #167
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Feb 21, 2023
1 parent 780f4df commit bd53505
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: pkgcheck
Title: rOpenSci Package Checks
Version: 0.1.1.012
Version: 0.1.1.013
Authors@R: c(
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/pkgcheck",
"issueTracker": "https://github.com/ropensci-review-tools/pkgcheck/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.1.1.012",
"version": "0.1.1.013",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
9 changes: 7 additions & 2 deletions tests/testthat/_snaps/pkgcheck/checks.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,16 @@ <h3>2. Package Dependencies</h3>
<td align="right">NA</td>
</tr>
<tr class="even">
<td align="left">imports</td>
<td align="left">memoise</td>
<td align="right">NA</td>
</tr>
<tr class="odd">
<td align="left">suggests</td>
<td align="left">testthat</td>
<td align="right">NA</td>
</tr>
<tr class="odd">
<tr class="even">
<td align="left">linking_to</td>
<td align="left">Rcpp</td>
<td align="right">NA</td>
Expand All @@ -201,7 +206,7 @@ <h3>3. Statistical Properties</h3>
<li>1 authors</li>
<li>no vignette</li>
<li>no internal data file</li>
<li>1 imported package</li>
<li>2 imported packages</li>
<li>1 exported function (median 3 lines of code)</li>
<li>2 non-exported functions in R (median 3 lines of code)</li>
<li>2 R functions (median 5 lines of code)</li>
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/_snaps/pkgcheck/checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ The table below tallies all function calls to all packages ('ncalls'), both inte
|type |package | ncalls|
|:----------|:--------|------:|
|imports |Rcpp | NA|
|imports |memoise | NA|
|suggests |testthat | NA|
|linking_to |Rcpp | NA|

Expand Down Expand Up @@ -183,7 +184,7 @@ The package has:
- 1 authors
- no vignette
- no internal data file
- 1 imported package
- 2 imported packages
- 1 exported function (median 3 lines of code)
- 2 non-exported functions in R (median 3 lines of code)
- 2 R functions (median 5 lines of code)
Expand Down
20 changes: 19 additions & 1 deletion tests/testthat/test-pkgcheck.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

test_that ("pkgcheck", {

withr::local_envvar (list ("PKGCHECK_SRR_REPORT_FILE" = "report.html"))
Expand All @@ -12,6 +11,25 @@ test_that ("pkgcheck", {

pkgname <- "testpkgchecknotapkg"
d <- srr::srr_stats_pkg_skeleton (pkg_name = pkgname)
# Add memoise to check global assign in memoised fns:
f_desc <- fs::path (d, "DESCRIPTION")
desc <- readLines (f_desc)
i <- grep ("Rcpp$", desc) [1]
desc <- c (
desc [seq_len (i - 1)],
" Rcpp,",
" memoise",
desc [seq (i + 1, length (desc))]
)
writeLines (desc, f_desc)
# Define memoised fn in new 'zzz.R' file:
f_zzz <- fs::path (d, "zzz.R")
zzz <- c (
".onLoad <- function(libname, pkgname) {",
" test_fn <<- memoise::memoise(test_fn)",
"}"
)
writeLines (zzz, f_zzz)

x <- capture.output (
roxygen2::roxygenise (d),
Expand Down

0 comments on commit bd53505

Please sign in to comment.