Skip to content

Commit

Permalink
also skip all_functions() call on cran tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Apr 1, 2022
1 parent 390e97f commit 7074e2a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 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.0.4.003
Version: 0.0.4.004
Authors@R:
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265"))
Expand Down
24 changes: 23 additions & 1 deletion R/pkgstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pkgstats <- function (path = ".") {

# Running 'ctags_test()' on some CRAN machines takes too long (> 10s), so
# this flag is used to switch off tagging routines on CRAN tests.
if (Sys.getenv ("PKGSTATS_NO_CTAGS") == "true") {
if (Sys.getenv ("PKGSTATS_CRAN_TESTS") == "true") {
tags <- dummy_tags_data ()
} else {
# `s2$package` mucks up local linter
Expand Down Expand Up @@ -99,6 +99,10 @@ pkgstats <- function (path = ".") {
#' @noRd
all_functions <- function (path) {

if (Sys.getenv ("PKGSTATS_CRAN_TESTS") == "true") {
return (all_functions_dummy ())
}

r_files <- normalizePath (list.files (
file.path (path, "R"),
full.names = TRUE,
Expand Down Expand Up @@ -162,6 +166,24 @@ all_functions <- function (path) {
return (ret)
}

#' Dummy return from `all_funcitons()` function, triggered only on CRAN tests
#' which otherwise take too long because of the `parse` calls.
#' @noRd
all_functions_dummy <- function () {

data.frame (
"file_name" = character (0),
"fn_name" = character (0),
"loc" = integer (0),
"npars" = integer (0),
"has_dots" = logical (0),
"exported" = logical (0),
"param_nchars_md" = numeric (0),
"param_nchars_mn" = numeric (0),
"num_doclines" = integer (0)
)
}

#' param src value of tags$stats from tags_data()
#' @noRd
add_src_to_fn_data <- function (fns, src) {
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.0.4.003",
"version": "0.0.4.004",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
5 changes: 3 additions & 2 deletions tests/testthat/test-pkgstats.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") |
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage"))
test_all <- FALSE

test_that ("pkgstats", {

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

path <- system.file ("extdata", "pkgstats_9.9.tar.gz", package = "pkgstats")
Expand All @@ -15,7 +16,7 @@ test_that ("pkgstats", {
s <- pkgstats (path)
# )
if (!test_all) {
Sys.unsetenv ("PKGSTATS_NO_CTAGS")
Sys.unsetenv ("PKGSTATS_CRAN_TESTS")
}

expect_type (s, "list")
Expand Down

0 comments on commit 7074e2a

Please sign in to comment.