test!: migrate custom check() suite to tinytest - #65
Merged
davidbudzynski merged 32 commits intoSep 20, 2026
Merged
Conversation
Legacy tests/test_kit.R defined check() that only cat()ed on failure and never called stop(), so R CMD check stayed green despite regressions (1286 silent checks). - Add Config/testthat/edition: 3 + Suggests testthat (>= 3.0.0) - Split into tests/testthat/test-topn.R, test-iif-nif.R, test-parallel.R, test-share.R, plus per-area files (fpos, setlevels, vswitch-nswitch, count, unique, psort, charToFact, pfirst-plast) with helper-kit.R - Map check(id, expr, expected) -> expect_identical(), 31 tolerant cases (identical FALSE but all.equal+typeof TRUE) -> expect_kit_equal(), check(..., error=) -> expect_error(regexp=, fixed=TRUE), warning cases -> expect_warning() + value comparison - Preserve legacy IDs as test_that labels (function-prefixed for uniqueness) and keep setup interleaved (later sections redefine x/y/out_vec) - Delete legacy tests/test_kit.R (replaced by tests/testthat.R runner) - Verified: test_dir passes (1271 expectations, 0 failures); R CMD check runs testthat.R OK; deliberately mutated topn return fails as expected (topn-0001.001) Closes fastverse#54
Collaborator
Author
|
All 11 checks green now. Note the latest commit ( |
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.
Closes #54. Supersedes #64 (testthat 3e approach pivoted to tinytest — rationale in #54 (comment)).
Problem
tests/test_kit.R:7-34definedcheck(test,x,y,error,warning)that only didcat("Check ... failed.\n")with nostop()/stopifnot(). Result:R CMD checkalways green even with regressions (1286 silent checks).Why tinytest instead of testthat
Imports,R >= 3.1.0. tinytest is zero-dependency,R >= 3.0; testthat 3.x is ~15k lines + 22 deps and needsR >= 4.1.expect_identical/expect_error/ tolerant numeric compares; no snapshots, mocking, or reporters).inst/tinytest/and stay runnable post-install viatinytest::test_package("kit")— useful for a compiled package.covris framework-agnostic, sotest-coverage.yamlneeds no change.What this PR does
DESCRIPTION:Suggests: tinytest(droptestthat+Config/testthat/edition)tests/tinytest.R(tinytest::test_package("kit"))inst/tinytest/(29 atomic commits, 1 file each):test-topn.R,test-iif-nif.R,test-parallel.R(psum/pprod/fpmin/fpmax/prange/pall/pany/pmean),test-share.R, plustest-fpos.R,test-setlevels.R,test-vswitch-nswitch.R,test-count.R,test-unique.R,test-psort.R,test-charToFact.R,test-pfirst-plast.R,helper-kit.Rcheck(id, expr, expected)->expect_identical(..., info="id")(test_thatwrappers unwrapped, legacy IDs asinfo=labels, function-prefixed for uniqueness)identical()is FALSE but legacyall.equal()+typeof()is TRUE (complex NA imaginaryNAvs0, C-vs-R floating-point order inpmean/pprod/vswitch) ->expect_kit_equal(..., info="id")helper (mirrors legacy logic viaexpect_true)check(..., error=)->expect_error(pattern=, fixed=TRUE, info="id")(mirrors legacygrep fixed=TRUEsubstring match)0001.068,0020.001) ->expect_warning(..., fixed=TRUE)+ value comparisonskip_if(shareData) ->exit_filex/y/out_vec, so setup is not hoisted).tests/test_kit.R. 17 commented-outpsortchecks from the legacy file are omitted (were commented).test-coverage.yaml: no change needed —covr::codecov()auto-detectstests/tinytest.R.Verification
Rscript tests/tinytest.R: All ok, 1271 results, 0 failures (parity with the testthat conversion in test!: migrate custom check() suite to testthat 3e #64).cat()and exit 0.R CMD check --no-manual --no-build-vignetteson built tarball:Running 'tinytest.R' ... OK(only pre-existing vignetteinst/docwarnings from--no-build-vignettes/missing pandoc).inst/tinytest/;tinytest::test_package("kit")on the installed package: 1271/1271 pass.Notes for reviewers
helper-kit.Rmust be loaded withsys.source("helper-kit.R", envir = environment()), notsource()— plainsource()evaluates inglobalenv()where tinytest's recordingexpect_*aren't visible (noted in the file).expect_kit_equal()is intentionally narrow (31 cases). If we prefer strict comparison for those too, we would need to update expected values (e.g. complex NA imaginary) — left as legacy-tolerant for a green baseline.