pub struct CoverageRun { /* private fields */ }Expand description
Configuration for a coverage run.
Wraps cargo llvm-cov --json --summary-only. Use the builder methods
to scope the run (working directory, workspace toggle, excludes,
features), then call execute to invoke the
subprocess and parse the result.
§Example
use dev_coverage::CoverageRun;
let run = CoverageRun::new("my-crate", "0.1.0")
.workspace()
.exclude("tests/*")
.all_features();
let _result = run.execute().unwrap();Implementations§
Source§impl CoverageRun
impl CoverageRun
Sourcepub fn new(name: impl Into<String>, version: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, version: impl Into<String>) -> Self
Begin a coverage run for the given crate name and version.
name and version are descriptive — they identify the subject
in the produced dev-report::Report. They do NOT need to match
the package being measured (that is determined by cargo’s own
resolution from the working directory).
Sourcepub fn in_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn in_dir(self, dir: impl Into<PathBuf>) -> Self
Run cargo llvm-cov from dir instead of the current directory.
Sourcepub fn subject_version(&self) -> &str
pub fn subject_version(&self) -> &str
Descriptive subject version passed in via new.
Sourcepub fn exclude(self, pattern: impl Into<String>) -> Self
pub fn exclude(self, pattern: impl Into<String>) -> Self
Pass --exclude <pattern>. May be called multiple times.
Sourcepub fn feature(self, name: impl Into<String>) -> Self
pub fn feature(self, name: impl Into<String>) -> Self
Add a specific feature to enable. May be called multiple times.
Sourcepub fn all_features(self) -> Self
pub fn all_features(self) -> Self
Pass --all-features.
Sourcepub fn no_default_features(self) -> Self
pub fn no_default_features(self) -> Self
Pass --no-default-features.
Sourcepub fn per_file(self) -> Self
pub fn per_file(self) -> Self
Request a per-file breakdown (drops --summary-only).
Default is summary-only — much smaller JSON, faster parse. Enable
this when you need CoverageResult::files populated.
Sourcepub fn execute(&self) -> Result<CoverageResult, CoverageError>
pub fn execute(&self) -> Result<CoverageResult, CoverageError>
Execute the run.
Returns a CoverageResult on success, or a CoverageError
describing what went wrong (missing tool, subprocess failure,
parse failure).
Trait Implementations§
Source§impl Clone for CoverageRun
impl Clone for CoverageRun
Source§fn clone(&self) -> CoverageRun
fn clone(&self) -> CoverageRun
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more