Skip to content

Unit tests (coverage round 6) and the bugs they found; remove dead code - #251

Merged
eliotmcintire merged 1 commit into
developmentfrom
test/coverage-round6
Dec 4, 2026
Merged

eliotmcintire merged 1 commit into
developmentfrom
test/coverage-round6

Conversation

@eliotmcintire

Copy link
Copy Markdown
Contributor

More unit tests, mostly for error-handling paths, and fixes for the bugs they found. The most visible one: when Require downloads an archived package, it now uses the user's own CRAN mirror; before, it never did. Unreachable code is also removed.

Affects: Archived-package downloads now go to the user's CRAN mirror. A failed internet check no longer leaves a stray option set. Several rarely-hit error paths now behave as documented, not erroring or looping.

Technical details

New tests/testthat/test-31coverage7_testthat.R (~500 expectations, ~12 s). It covers error branches by injecting the expected error and checking that it is caught. 14 of its tests fail on the old R/ code.

Fixes:

  • R/pak.R:851: isCRAN was unlist(whIsOfficialCRANrepo(repos)) %in% TRUE, which is always FALSE because that function returns URL strings. It is now lengths(...) > 0.
  • R/Require-helpers.R:298: the warning handler set options(Require.checkInternet = TRUE) and leaked it. It now calls setOfflineModeTRUE(verbose, force = TRUE).
  • dlArchiveVersionsAvailable and available.packagesCached: create pkgDepEnv() if it is missing.
  • getSHAfromGitHub: handles a missing br.
  • types(): returns its value.
  • substitutePackages: fixed for multiple packages.
  • setupOff: no longer errors when rprojroot::find_root fails.
  • pkgDep: handles a NULL stRequireEnv.
  • modifyList2: the later duplicate now wins.
  • pakErrorHandling: stops after the archive-type branch.
  • pakPkgDep: a guard stops an infinite retry loop, and it uses ifelse() for vectors.
  • rpackageFolder and updatePackages: use isInteractive() in place of the primitive interactive().
  • zzz.R:89: the fallback .RequireDependencies uses <<-.
  • Removed ~145 lines of unreachable branches (old "Error NNN" checks, isOldMac, "no Package column" guards) and two unused globalVariables entries.
  • test-29 runInstall passed the pakGetArchive mock twice, and the second copy leaked. It now passes one.

Verification: a full local devtools::test() gave 557 tests and 2460 passing expectations, with 0 failures, errors, warnings or skips. R CMD check --no-tests was clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Lx3DXgG6hSA1CRAMhvKajR

New test-31coverage7 covers error branches by injecting the expected error.
Fixes: CRAN-mirror archive URLs never used (pak.R isCRAN), offline-mode
warning handler leaked Require.checkInternet, pkgDepEnv not created in
dlArchiveVersionsAvailable/available.packagesCached, getSHAfromGitHub missing
br, types() return, substitutePackages, setupOff find_root, modifyList2
duplicate order, pakErrorHandling/pakPkgDep loops, isInteractive() seam,
zzz.R fallback .RequireDependencies assignment. Removes ~145 lines of
unreachable code. test-29 runInstall passes one pakGetArchive mock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lx3DXgG6hSA1CRAMhvKajR
@eliotmcintire eliotmcintire added the bug Something isn't working label Dec 4, 2026
@eliotmcintire
eliotmcintire merged commit 188ceec into development Dec 4, 2026
21 checks passed
@eliotmcintire
eliotmcintire deleted the test/coverage-round6 branch December 4, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant