Skip to content

port runit tests to a minimal in-package test harness - #264

Merged
kevinushey merged 1 commit into
masterfrom
port-runit-to-minimal-tests
Jul 24, 2026
Merged

port runit tests to a minimal in-package test harness#264
kevinushey merged 1 commit into
masterfrom
port-runit-to-minimal-tests

Conversation

@kevinushey

Copy link
Copy Markdown
Contributor

Replaces the RUnit-based test suite with plain tests/test-*.R scripts backed by a small set of helpers shipped in the package (R/test.R).

Motivation

Drop the RUnit dependency in favour of our own minimal test infrastructure, using base-R tools for assertions.

What's here

New helpers in R/test.R:

  • test_init() — the single entry point each test script calls. Clears R_TESTS (the startup.Rs value R CMD check sets breaks R sub-processes run from a different working directory), seeds the RNG for reproducibility, and picks a default backend (tinythread, always available) unless one is set. It finishes by summoning the namespace into the calling script.
  • summon() — copies the RcppParallel namespace into an environment so tests can reference internal functions (TBB_ENABLED, etc.) without the RcppParallel::: prefix. Modelled on renv:::summon().
  • assert(cond) — a single-condition check that throws unless every element is TRUE. It also understands the all.equal() idiom: since all.equal() returns a character description on mismatch, a character result is treated as a failure and its diff is surfaced.

Tests:

  • Ported the five inst/tests/runit.*.R files to tests/test-*.R, using assert() / all.equal() in place of checkEquals(). The C++ sources stay in inst/tests/cpp/ (still sourced via system.file()).
  • Renamed the existing plain-R tests (scalable-allocator.R, testInstallLibs.R) to the test-*.R convention and routed them through test_init().

Removed: tests/doRUnit.R, the old inst/tests/runit.*.R files, and RUnit from DESCRIPTION Suggests.

Replace the RUnit-based test suite with plain 'tests/test-*.R' scripts and
a small helper set shipped in the package (R/test.R):

- test_init() does the shared setup (clears R_TESTS, seeds the RNG, picks a
  default backend) and summons the RcppParallel namespace into the calling
  script so internal functions are referenceable without the ':::' prefix
- summon() copies the namespace into an environment, modelled on renv:::summon()
- assert() is a single-condition check that also understands the all.equal()
  idiom, surfacing the reported difference on failure

Port the five inst/tests/runit.*.R files to tests/test-*.R using these
helpers and base-R assertions, and rename the existing plain-R tests to the
same 'test-*.R' convention. Remove tests/doRUnit.R, the old RUnit tests, and
the RUnit dependency from DESCRIPTION.
@kevinushey
kevinushey merged commit 2ff3695 into master Jul 24, 2026
5 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.

1 participant