Skip to content

feat(r): add test coverage hooks for R testthat convention#529

Closed
sims1253 wants to merge 1 commit into
peteromallet:mainfrom
sims1253:feat/r-test-coverage-hooks-clean
Closed

feat(r): add test coverage hooks for R testthat convention#529
sims1253 wants to merge 1 commit into
peteromallet:mainfrom
sims1253:feat/r-test-coverage-hooks-clean

Conversation

@sims1253
Copy link
Copy Markdown
Contributor

@sims1253 sims1253 commented Apr 4, 2026

Summary

Adds test coverage detection support for R projects following the standard testthat convention.

What this does

  • Maps tests/testthat/test-*.RR/*.R source files
  • Recognizes all expect_* assertion patterns from testthat
  • Handles library()/require() imports in test files for dependency resolution
  • Strips R comments while preserving string literals

Changes

 desloppify/languages/r/__init__.py            |   2 +
 desloppify/languages/r/test_coverage.py       | 167 ++++++++++++++++++++
 desloppify/languages/r/tests/test_r_test_coverage.py | 115 ++++++++++++++
 3 files changed, 284 insertions(+)

Testing

All 19 tests pass. The module follows the same structure as existing R plugins (test coverage modules for Python, JavaScript, etc.).

This is a focused, standalone addition that does not modify any existing behavior — it only adds the test_coverage_module hook to the R language plugin.

Add test_coverage module that maps tests/testthat/test-*.R to R/*.R,
recognizes expect_* assertion patterns, handles library()/require()
imports in test files, and strips R comments while preserving strings.
@peteromallet
Copy link
Copy Markdown
Owner

Thank you @sims1253 for this contribution! Cherry-picked with a small adjustment (fixed strip_test_markers to return the bare basename) as commit 72a2b34. Closing in favor of the merged commit.

peteromallet added a commit that referenced this pull request Apr 6, 2026
…stments)

Adjustments: fixed strip_test_markers to return bare basename instead of R/-prefixed path
Cherry-picked from PR #529 by @sims1253
Co-Authored-By: sims1253 <sims1253@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@peteromallet
Copy link
Copy Markdown
Owner

Thanks for the PR. I accepted the R test coverage hook feature with two conditions around redundant assertion patterns and strip_test_markers() behavior.

Decision: fixed in the current tree. The R test coverage hooks are already present via prior commits 72a2b343 and c1bce81f; I verified that strip_test_markers() now returns the basename form expected by the shared coverage engine. I also simplified the assertion patterns in 3d92333f so the list uses the expect_* catch-all plus verify_output, avoiding redundant specific expect_* entries.

Validation run:

  • PYENV_VERSION=3.11.11 python -m pytest desloppify/languages/r/tests/test_r_test_coverage.py desloppify/languages/r/tests/test_r_air.py desloppify/tests/detectors/coverage/test_test_coverage.py -q

This PR was already closed, so I am leaving this note as the final decision record.

@peteromallet peteromallet added the release:v1.0 Included in v1.0 label May 13, 2026
@peteromallet
Copy link
Copy Markdown
Owner

Thanks for the contribution. This is included in v1.0: https://github.com/peteromallet/desloppify/releases/tag/v1.0

peteromallet added a commit that referenced this pull request May 13, 2026
Record co-author trailers for PR authors included in the v1.0 release cycle so GitHub can associate release-cycle contribution credit with the tag.

Refs: #189, #484, #485, #486, #489, #493, #495, #529, #539, #573, #580, #581, #584, #585, #589, #602, #603

Co-authored-by: R. Desmond <134018026+0-CYBERDYNE-SYSTEMS-0@users.noreply.github.com>
Co-authored-by: AreboursTLS <77301936+AreboursTLS@users.noreply.github.com>
Co-authored-by: AugusteBalas <128148269+AugusteBalas@users.noreply.github.com>
Co-authored-by: Alex Price <2804025+awprice@users.noreply.github.com>
Co-authored-by: Klaus Agnoletti <24544601+klausagnoletti@users.noreply.github.com>
Co-authored-by: Koshi <18751916+koshimazaki@users.noreply.github.com>
Co-authored-by: Pietro <6080662+pietrondo@users.noreply.github.com>
Co-authored-by: raveinid <7130195+raveinid@users.noreply.github.com>
Co-authored-by: Ryan Gerstenkorn <4079939+RyanJarv@users.noreply.github.com>
Co-authored-by: ryexLLC <217349586+ryexLLC@users.noreply.github.com>
Co-authored-by: Maximilian Scholz <6530123+sims1253@users.noreply.github.com>
Co-authored-by: Tristan Manchester <108270628+tristanmanchester@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:v1.0 Included in v1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants