Repository navigation
Unit tests (coverage round 6) and the bugs they found; remove dead code - #251
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:isCRANwasunlist(whIsOfficialCRANrepo(repos)) %in% TRUE, which is always FALSE because that function returns URL strings. It is nowlengths(...) > 0.R/Require-helpers.R:298: the warning handler setoptions(Require.checkInternet = TRUE)and leaked it. It now callssetOfflineModeTRUE(verbose, force = TRUE).dlArchiveVersionsAvailableandavailable.packagesCached: createpkgDepEnv()if it is missing.getSHAfromGitHub: handles a missingbr.types(): returns its value.substitutePackages: fixed for multiple packages.setupOff: no longer errors whenrprojroot::find_rootfails.pkgDep: handles a NULLstRequireEnv.modifyList2: the later duplicate now wins.pakErrorHandling: stops after the archive-type branch.pakPkgDep: a guard stops an infinite retry loop, and it usesifelse()for vectors.rpackageFolderandupdatePackages: useisInteractive()in place of the primitiveinteractive().zzz.R:89: the fallback.RequireDependenciesuses<<-.globalVariablesentries.runInstallpassed thepakGetArchivemock 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-testswas clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01Lx3DXgG6hSA1CRAMhvKajR