test!: migrate custom check() suite to testthat 3e - #64
Open
davidbudzynski wants to merge 1 commit into
Open
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
davidbudzynski
marked this pull request as ready for review
September 8, 2026 19:34
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.
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).What this PR does
DESCRIPTION: addConfig/testthat/edition: 3+Suggests: testthat (>= 3.0.0)tests/testthat.R(test_check("kit"))tests/testthat/:test-topn.R,test-iif-nif.R,test-parallel.R(psum/pprod/fpmin/fpmax/prange/pall/pany/pmean),test-share.R(as requested in test!: custom check() never fails - migrate to testthat3 #54), 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()identical()is FALSE but legacyall.equal()+typeof()is TRUE (complex NA imaginaryNAvs0, C-vs-R floating-point order inpmean/pprod/vswitch) ->expect_kit_equal()helper (mirrors legacy logic viaexpect())check(..., error=)->expect_error(regexp=, fixed=TRUE)(mirrors legacygrep fixed=TRUEsubstring match)0001.068,0020.001) ->expect_warning(..., fixed=TRUE)+ value comparisontest_that()labels, function-prefixed for uniqueness (topn-0001.001,vswitch-0008.001vsfpmin-0008.001, etc.). Duplicate legacy IDs (0002.101,0016.065) get-2suffix.x/y/out_vec, so setup is not hoisted).tests/test_kit.R(replaced by runner). 17 commented-outpsortchecks from legacy file are omitted (were commented).test-coverage.yaml: no change needed — verifiedremotes::install_deps(dependencies=TRUE)already picks upSuggests: testthatandcovr::codecov()auto-detectstests/testthat.Verification
test_dir("tests/testthat"): 1271 expectations, 0 failures (1268test_thatblocks covering 1269 legacy checks).R CMD check --no-manual --no-vignettes:Running 'testthat.R' ... OK(only pre-existing vignetteinst/docwarnings from--no-build-vignettes).topn-0001.001expected to999L-> suite fails as expected (Expected topn(...) to be identical to 999L / actual: 5), then restored. Old suite would onlycat()and exit 0.Notes for reviewers
expect_kit_equal()is intentionally narrow (31 cases). If we prefer strict waldo for those too, we would need to update expected values (e.g. complex NA imaginary) — left as legacy-tolerant for a green baseline.