coverage: Add CLI support for -Zcoverage-options=condition
This commit is contained in:
parent
caa187f3bc
commit
fa563c1384
6 changed files with 34 additions and 6 deletions
|
@ -159,7 +159,23 @@ pub enum CoverageLevel {
|
|||
Block,
|
||||
/// Also instrument branch points (includes block coverage).
|
||||
Branch,
|
||||
/// Instrument for MC/DC. Mostly a superset of branch coverage, but might
|
||||
/// Same as branch coverage, but also adds branch instrumentation for
|
||||
/// certain boolean expressions that are not directly used for branching.
|
||||
///
|
||||
/// For example, in the following code, `b` does not directly participate
|
||||
/// in a branch, but condition coverage will instrument it as its own
|
||||
/// artificial branch:
|
||||
/// ```
|
||||
/// # let (a, b) = (false, true);
|
||||
/// let x = a && b;
|
||||
/// // ^ last operand
|
||||
/// ```
|
||||
///
|
||||
/// This level is mainly intended to be a stepping-stone towards full MC/DC
|
||||
/// instrumentation, so it might be removed in the future when MC/DC is
|
||||
/// sufficiently complete, or if it is making MC/DC changes difficult.
|
||||
Condition,
|
||||
/// Instrument for MC/DC. Mostly a superset of condition coverage, but might
|
||||
/// differ in some corner cases.
|
||||
Mcdc,
|
||||
}
|
||||
|
|
|
@ -395,7 +395,7 @@ mod desc {
|
|||
pub const parse_optimization_fuel: &str = "crate=integer";
|
||||
pub const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
|
||||
pub const parse_instrument_coverage: &str = parse_bool;
|
||||
pub const parse_coverage_options: &str = "`block` | `branch` | `mcdc`";
|
||||
pub const parse_coverage_options: &str = "`block` | `branch` | `condition` | `mcdc`";
|
||||
pub const parse_instrument_xray: &str = "either a boolean (`yes`, `no`, `on`, `off`, etc), or a comma separated list of settings: `always` or `never` (mutually exclusive), `ignore-loops`, `instruction-threshold=N`, `skip-entry`, `skip-exit`";
|
||||
pub const parse_unpretty: &str = "`string` or `string=string`";
|
||||
pub const parse_treat_err_as_bug: &str = "either no value or a non-negative number";
|
||||
|
@ -961,6 +961,7 @@ mod parse {
|
|||
match option {
|
||||
"block" => slot.level = CoverageLevel::Block,
|
||||
"branch" => slot.level = CoverageLevel::Branch,
|
||||
"condition" => slot.level = CoverageLevel::Condition,
|
||||
"mcdc" => slot.level = CoverageLevel::Mcdc,
|
||||
_ => return false,
|
||||
}
|
||||
|
|
|
@ -353,6 +353,11 @@ impl Session {
|
|||
&& self.opts.unstable_opts.coverage_options.level >= CoverageLevel::Branch
|
||||
}
|
||||
|
||||
pub fn instrument_coverage_condition(&self) -> bool {
|
||||
self.instrument_coverage()
|
||||
&& self.opts.unstable_opts.coverage_options.level >= CoverageLevel::Condition
|
||||
}
|
||||
|
||||
pub fn instrument_coverage_mcdc(&self) -> bool {
|
||||
self.instrument_coverage()
|
||||
&& self.opts.unstable_opts.coverage_options.level >= CoverageLevel::Mcdc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue