create_coverage_skip_stf: Run Coverage While Skipping Failing Tests

View source: R/run_covr_skip_stf.R

create_coverage_skip_stfR Documentation

Run Coverage While Skipping Failing Tests

Description

This function runs coverage analysis using 'covr' while temporarily commenting out known failing tests. It is intended for situations where specific tests must be skipped (e.g., due to upstream bugs or known failures) so that coverage can still be computed on remaining tests.

Usage

create_coverage_skip_stf(
  pkg_source_path,
  pkg,
  test_path = "tests/testthat",
  test_skip,
  test_map,
  cov_env
)

Arguments

pkg_source_path

Character. Path to the root of the package source.

pkg

Character. Name of the package being tested.

test_path

Character. Path to the test directory. Defaults to ''tests/testthat''.

test_skip

Data frame. Mapping of failing tests, typically containing columns 'file', 'line1', and 'line2'. Each row describes a span of lines that should be commented out before running coverage.

test_map

Data frame. Mapping of all tests within the package (used for diagnostic messaging and consistency checks).

cov_env

Environment that holds the temporary coverage workspace and shared state for the run.

Details

The function:

  • sets up a temporary coverage environment,

  • identifies lines to skip based on 'test_skip',

  • comments out those test lines,

  • runs 'covr::environment_coverage()', and

  • restores the original test files on exit.

If 'test_skip' is 'NULL', failing tests must be detected elsewhere before calling this function. This function does not perform test detection; it only applies the skip mappings supplied in 'test_skip'.

Value

A coverage object (a list) returned by 'covr::environment_coverage()', filtered to remove problematic entries. If coverage fails, the function returns 'NULL'.

The returned structure typically contains:

filename

Name of the file being measured.

functions

Function-level coverage information.

linecoverage

Line-by-line execution counts.

srcref

Source references extracted for coverage.

See Also

test_dir, package_coverage, environment_coverage

Other stf_utility: map_test(), map_tests_stf(), nest_test(), run_covr_skip_stf()


test.assessr documentation built on March 3, 2026, 1:06 a.m.