Skip to content

Raise test coverage from 18% (Groups A-D)#86

Merged
seandavi merged 10 commits into
develfrom
test-coverage-improvements
Jul 17, 2026
Merged

Raise test coverage from 18% (Groups A-D)#86
seandavi merged 10 commits into
develfrom
test-coverage-improvements

Conversation

@seandavi

Copy link
Copy Markdown
Owner

Summary

Coordinated push to raise unit test coverage per the per-function checklist in #85, starting from 18.0% overall (covr::package_coverage()). Adds/extends 28 test files (~2,344 lines) across four work groups:

  • Group A — download & usage-stats functions (biocDownloadStats.R, condaDownloadStats.R, getData.R, cache.R)
  • Group B — package metadata & dependency graphs (biocPkgList.R, buildPkgDependencyGraph.R, pkgDependencyMetrics.R, pkgBiocDeps.R, classDependencies.R)
  • Group C — build reports, problem pages, maintenance (problemPage.R, biocMaintained.R, biocVIEWSdb.R, utilities.R, biocBuildStatusDB.R, githubUtils.R)
  • Group D — reporting & external integrations (biocExplore.R, biocPkgRanges.R, biocRevDepEmail.R, biocBuildEmail.R, dataciteXMLGenerate.R, use_orcid.R, repositoryStats.R, CRANstatus.R, getYearsInBioc.R)

Testing philosophy: real requests against live Bioconductor/network resources where practical, gated on actual reachability (new skip_if_bioc_offline() helper), rather than mocking.

Two real production bugs were found and fixed while writing tests:

  • .get_all_biocpkgs() called BiocManager:::.repositories_bioc(version = version) where version resolved to the imported BiocManager::version function (not base R's version object) due to NAMESPACE shadowing — this made the helper error unconditionally.
  • checkDeps() subset all_pkg_deps[cond, 1] dropped to an atomic vector, so pkg_deps$Package always threw — problemPage(dependsOn = ...) never actually worked. Fixed with drop = FALSE.

One test-infra bug was also fixed: testthat::skip_if_offline() calls skip_on_cran() internally, so under the plain testthat::test_check() runner used by R CMD check/covr (as opposed to devtools::test()), network tests were silently skipped regardless of real connectivity. Replaced with a skip_if_bioc_offline() helper for bioconductor.org-specific tests.

generateBiocPkgDOI (R/newBiocPkgDOI.R) remains untested — the one unchecked item on the #85 checklist. I evaluated whether this was fixable: the function's docs claim testing = TRUE uses the sandbox apitest/apitest login, but the code always reads DATACITE_USERNAME/DATACITE_PASSWORD from the environment regardless of the testing flag. I confirmed live that apitest/apitest authenticates against api.test.datacite.org but returns 404 when minting a DOI under Bioconductor's reserved test prefix (10.82962) — that prefix isn't associated with the generic sandbox account, only with real Bioconductor-issued credentials. So there's no credential-free way to exercise the live request-construction path, and no separable pure-logic piece to unit test without mocking. The existing test skips cleanly and runs for real whenever a maintainer/CI supplies the real credentials.

Also bumps Version to 1.31.14 and adds a NEWS entry.

Closes #85

Test plan

  • Full testthat suite passes locally with NOT_CRAN=true and live network reachable
  • Per-file covr::file_coverage() spot checks: pkgBiocDeps.R 98.6%, buildPkgDependencyGraph.R 97.4%, pkgDependencyMetrics.R 90.0%, classDependencies.R 94.2%
  • CI (R-CMD-check.yaml) green on this PR

seandavi and others added 10 commits July 17, 2026 10:53
Covers biocDownloadStats.R, condaDownloadStats.R, getData.R, and cache.R
with real network requests against bioconductor.org, anaconda-download-stats,
and the GitHub API (gated on skip_if_bioc_offline()/skip_if_offline()), plus
pure-logic unit tests for the local caching and data-wrangling helpers that
need no network at all.

Also fixes a latent bug in the internal .get_all_biocpkgs() helper: it
passed the *function* BiocManager::version (imported via NAMESPACE, shadowing
base::version) as the `version` argument to BiocManager:::.repositories_bioc()
instead of calling it, which made the helper error unconditionally. Changed
to BiocManager::version(). The helper is currently unused elsewhere in the
package but needed a working implementation to be testable.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
)

Covers biocExplore, biocPkgRanges, biocRevDepEmail (+ link-building
helpers), biocBuildEmail (+ mail-log/user-info/template helpers),
dataciteXMLGenerate, generateBiocPkgDOI, use_orcid.R, repositoryStats,
CRANstatus, and getYearsInBioc.R.

Per the tracking issue's testing philosophy, these prefer real requests
against live Bioconductor/CRAN/ORCID resources (gated on
skip_if_bioc_offline()/skip_if_offline()) over mocking. Functions with
unsafe side effects (sending real email, minting real DOIs) are only
exercised via their dry-run/text-only/sandbox-safe paths, or skipped
with a clear explanation when credentials are unavailable
(DATACITE_USERNAME/DATACITE_PASSWORD). getYearsInBioc.R tests use
fabricated tiny manifests and single-version slices to avoid scanning
the full multi-decade Bioconductor release history.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Covers R/biocPkgList.R CRAN-comparison helpers (CRAN_pkg_rds_url,
get_CRAN_pkg_rds, read_CRAN_url, stripVersionString),
R/buildPkgDependencyGraph.R, R/pkgDependencyMetrics.R, R/pkgBiocDeps.R,
and R/classDependencies.R per the checklist in issue #85.

Fixes the pkgBiocRevDeps() zero-coverage mystery: skip_if_offline()
calls skip_on_cran() internally, which skips whenever NOT_CRAN isn't
"true" -- true under devtools::test() but not under the standard
tests/testthat.R runner used by R CMD check / covr, so the test was
always skipped under coverage runs regardless of connectivity. Switched
to skip_if_bioc_offline() (bioconductor.org reachability only, no
skip_on_cran side effect). Applied the same reasoning to new CRAN-network
tests in test_biocPkgList.R, using a direct curl::has_internet() check
instead of skip_if_offline().

All dependency-graph/metrics tests use small, explicit package sets
(e.g. GEOquery, Rarr, BiocPkgTools itself) rather than full-repository
scans to keep runtime low; classDependencies.R tests need no network,
exercising installed S4 classes (SummarizedExperiment, Biobase,
S4Vectors) instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…githubUtils, utilities, biocBuildStatusDB

Adds real-Bioconductor-data tests for problemPage()/checkMe()/checkDeps()/
chkURL() (issue #21 highest priority: checkMe() output is confirmed to
include a real non-software (data-experiment) package with a live build
problem, and that same real result is reused to validate problemPage()'s
link-building/DT output, locking in the biocBuildReport() inner-join fix
at this layer), biocMaintained()/hasBiocMaint(), the .read_VIEWS_url()
error branch, .gh_pkg_info()/githubDetails() (gated on a working GitHub
token via gh::gh_whoami(), skipping gracefully otherwise), remaining
utilities.R gaps (.import_dcf_stage_node, .read_summary_dcfs,
get_deprecated_status_df, .cache_url_file, .needs_update), and
biocBuildStatusDB().

Also fixes a real bug in checkDeps() (R/problemPage.R) found while writing
its test: `all_pkg_deps[cond, 1]` drops to an atomic vector, so the
following `pkg_deps$Package` always threw "$ operator is invalid for
atomic vectors" -- checkDeps()/problemPage(dependsOn = ...) has never
actually worked. Fixed with `drop = FALSE`.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Closes #85 (Group A-D test coverage push). generateBiocPkgDOI is left
untested: the documented apitest/apitest sandbox login does not have
write access to Bioconductor's reserved DataCite test prefix, so there
is no credential-free way to exercise the live request path.
…y cache test

R CMD check flagged undeclared 'tests' dependencies on withr (used via
withr::) and Biobase (used via library()) on all platforms. Separately,
write_to_cache()'s "errors when cache location unavailable" test assumes
writing to filesystem root is denied, which doesn't hold on Windows CI
runners that run elevated.
@seandavi
seandavi merged commit ceae38a into devel Jul 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raise test coverage from 18% — per-function checklist

1 participant