Skip to content

Add support for MC/DC coverage - #363

Merged
taiki-e merged 3 commits into
taiki-e:mainfrom
aytey:add_mcdc
Jul 18, 2024
Merged

Add support for MC/DC coverage#363
taiki-e merged 3 commits into
taiki-e:mainfrom
aytey:add_mcdc

Conversation

@aytey

@aytey aytey commented Apr 23, 2024

Copy link
Copy Markdown
Contributor

MC/DC coverage recently landed in rustc:

but cargo-llvm-cov doesn't yet pass the -show-mcdc flag to llvm-cov, so we cannot get reports showing MC/DC coverage.

This PR adds support for -show-mcdc to llvm-cov when working with cargo-llvm-cov.

I checked: if RUSTFLAGS contains -Zcoverage-options=branch (i.e., MC/DC is not enabled) then the reports are the same as if you didn't pass -show-mcdc (i.e., you don't get "empty" MC/DC tables).

@aytey

aytey commented Apr 23, 2024

Copy link
Copy Markdown
Contributor Author

Oh, I hadn't realise it would fail if you used a non-nightly with that flag.

Is there a way to check if the current version of rustc supports MCDC?

@taiki-e

taiki-e commented Apr 23, 2024

Copy link
Copy Markdown
Owner

Is there a way to check if the current version of rustc supports MCDC?

I think you can check rustc version like:

cargo-llvm-cov/src/main.rs

Lines 205 to 211 in 550dc19

// Workaround for https://github.com/rust-lang/rust/issues/91092.
// Unnecessary since https://github.com/rust-lang/rust/pull/111469.
let needs_atomic_counter_workaround = if cx.ws.rustc_version.nightly {
cx.ws.rustc_version.major_minor() <= (1, 71)
} else {
cx.ws.rustc_version.major_minor() < (1, 71)
};

@taiki-e

taiki-e commented Apr 23, 2024

Copy link
Copy Markdown
Owner

The actual error here is due to the version of llvm-cov command (-show-mcdc requires LLVM 18+), so a check like cmd!(&cx.llvm_cov, "show", "--help").read()?.contains("-show-mcdc") might be better.

@taiki-e
taiki-e merged commit 93cee5a into taiki-e:main Jul 18, 2024
@taiki-e

taiki-e commented Jul 18, 2024

Copy link
Copy Markdown
Owner

Published in 0.6.11. Thanks @aytey!

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.

2 participants