Skip to content

Cleanup and unification for covr 4.0 - #758

Merged
jimhester merged 8 commits into
mainfrom
uniform-cleanup
Nov 12, 2026
Merged

jimhester merged 8 commits into
mainfrom
uniform-cleanup

Conversation

@jimhester

Copy link
Copy Markdown
Member

Upkeep pass based on reviews of the whole package and the usethis::use_tidy_upkeep_issue() checklist.

Breaking changes

  • Remove azure() (use cobertura(x, file = "coverage.xml")) and package_coverage(pre_clean =).
  • display_name() is no longer exported.
  • cobertura(), sonarqube(), lcov() and badge() take x and file, like report(); to_cobertura()/to_sonarqube() keep their old arguments and still warn.
  • One reader for settings given as options or COVR_* environment variables: the option always wins (this flips COVR_FIX_PARALLEL_MCEXIT), and true/t/yes/1, false/f/no/0 are accepted in any case.
  • covr.gcov is no longer set at load; gcov is looked up when needed with the build tools on the PATH.
  • coveralls() returns its response invisibly and errors (covr_coveralls_error) on non-200 or non-JSON responses.

Improvements and fixes

  • httr -> httr2 for uploads, via one mockable http_request() in R/http.R (no imports, Running covr for httr/R6 lead to cyclic namespace dependency failure #623); retries connection failures, 429 and 5xx.
  • sonarqube() includes compiled code and branch data; highlight.js 11 in reports.
  • Fix coverage of files whose names start with tests/branches, restoring Vectorize()/memoise() wrapped functions, braces in names in print(), filesystem roots, unanchored package path matching, stale .gcov files, C++23 instrumentation, Coveralls temp file and COVERALLS_REPO_TOKEN, current Drone variables, compiled-session cache invalidation.

Structure, docs and tests

  • Split R/covr.R into trace.R, merge.R, function_coverage.R, file_coverage.R, with_coverage.R, package_coverage.R, covr_error.R; every test-X.R matches an R/X.R.
  • Remove help pages of internal functions, document all options, explicit pkgdown reference index, updated how_it_works vignette.
  • No code outside test_that(), snapshots instead of unclassed expect_error(), temp files cleaned up, no writes into fixtures, fix an order-dependent test.
  • Upkeep: tidy DESCRIPTION, prune .Rbuildignore, air instead of styler in PR workflows, workflows updated to current r-lib templates, pak::pak() in README, new logo/favicons; remove performance-audit/, revdep/, unused TestUseTry fixture and testthat-problems.rds.

Upkeep pass based on reviews of the whole package and the `usethis::use_tidy_upkeep_issue()` checklist.

## Breaking changes

- Remove `azure()` (use `cobertura(x, file = "coverage.xml")`) and `package_coverage(pre_clean =)`.
- `display_name()` is no longer exported.
- `cobertura()`, `sonarqube()`, `lcov()` and `badge()` take `x` and `file`, like `report()`; `to_cobertura()`/`to_sonarqube()` keep their old arguments and still warn.
- One reader for settings given as options or `COVR_*` environment variables: the option always wins (this flips `COVR_FIX_PARALLEL_MCEXIT`), and `true/t/yes/1`, `false/f/no/0` are accepted in any case.
- `covr.gcov` is no longer set at load; gcov is looked up when needed with the build tools on the `PATH`.
- `coveralls()` returns its response invisibly and errors (`covr_coveralls_error`) on non-200 or non-JSON responses.

## Improvements and fixes

- httr -> httr2 for uploads, via one mockable `http_request()` in `R/http.R` (no imports, #623); retries connection failures, 429 and 5xx.
- `sonarqube()` includes compiled code and branch data; highlight.js 11 in reports.
- Fix coverage of files whose names start with `tests`/`branches`, restoring `Vectorize()`/`memoise()` wrapped functions, braces in names in `print()`, filesystem roots, unanchored package path matching, stale `.gcov` files, C++23 instrumentation, Coveralls temp file and `COVERALLS_REPO_TOKEN`, current Drone variables, compiled-session cache invalidation.

## Structure, docs and tests

- Split `R/covr.R` into `trace.R`, `merge.R`, `function_coverage.R`, `file_coverage.R`, `with_coverage.R`, `package_coverage.R`, `covr_error.R`; every `test-X.R` matches an `R/X.R`.
- Remove help pages of internal functions, document all options, explicit pkgdown reference index, updated `how_it_works` vignette.
- No code outside `test_that()`, snapshots instead of unclassed `expect_error()`, temp files cleaned up, no writes into fixtures, fix an order-dependent test.
- Upkeep: tidy DESCRIPTION, prune `.Rbuildignore`, air instead of styler in PR workflows, workflows updated to current r-lib templates, `pak::pak()` in README, new logo/favicons; remove `performance-audit/`, `revdep/`, unused `TestUseTry` fixture and `testthat-problems.rds`.
# Conflicts:
#	R/cobertura.R
#	R/compiled_session.R
#	R/covr.R
#	R/rust.R
#	R/sonarqube.R
#	tests/testthat/_snaps/compiled_session.md
#	tests/testthat/test-sonarqube.R
- Add tests for `annotate_coverage()` sources read from the package and lines past the end of a file, `instrument_installed_package()` failing midway, `has_sysdata_functions()` with data only and with full traversal, `restore_counters()` without counters, `add_hooks()` with an unrecognised loader script, `write_llvm_profile()` with an unloaded DLL, an uninstrumented Rust build in the session, and `format_messages()` and `range_pieces()` with no lines.
- Remove the unused `count()` and the unreachable non-call guard in `has_count_call()`, as instrumented code calls `covr_count()`.
- Exclude the out of memory path of the C counter table with `# nocov`.
The self-coverage run warns that 2 R processes loaded covrShim and did not save a trace, not 1. The second one is the child of the "package_coverage reports killed code shown while it runs" test: `run_r_live()` starts `R --vanilla --quiet -f TestS4-commands.Rout`, which loads `library(TestS4)` (registering a pending marker for the outer, instrumented covrShim) and then kills itself with SIGKILL. Found by logging the pid and `commandArgs()` of every `register_trace()` and `save_trace_and_clear()` call in a throwaway copy and listing the pids that registered but never saved.
httr2 >= 1.2.0 needs R >= 4.1, so the R 4.0 job couldn't resolve `httr2 (>= 1.0.4)` from its CRAN snapshot.
…tion**

- Tests no longer hardcode Unix roots where covr normalizes paths (`/` is `C:/` on Windows), and compare paths after normalizing them (short vs long temp paths, mixed slashes).
- The `system_output()` snapshot ignores the quote style of `shQuote()`, which differs on Windows.
- The R 4.0 job ignores `paws.common`, which the pinned httr2 only suggests but needs R >= 4.1.
…testthat versions**

- Read the request headers with `httr2::req_dry_run()` rather than `req_get_headers()`, which httr2 1.1.2 (the last version for R 4.0) lacks.
- Ignore the trailing period of testthat's "Test failures" error in the snapshot, which older testthat versions leave out.
`httr2::req_dry_run()` of httr2 1.1.2 returns the headers unredacted, and only redacts them when printing.
@jimhester
jimhester merged commit de2f6b3 into main Nov 12, 2026
15 checks passed
@jimhester jimhester mentioned this pull request Nov 13, 2026
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