Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MC/DC coverage #363

Merged
merged 3 commits into from
Jul 18, 2024
Merged

Add support for MC/DC coverage #363

merged 3 commits into from
Jul 18, 2024

Conversation

aytey
Copy link
Contributor

@aytey aytey commented Apr 23, 2024

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
Copy link
Contributor Author

aytey commented Apr 23, 2024

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
Copy link
Owner

taiki-e commented Apr 23, 2024

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
Copy link
Owner

taiki-e commented Apr 23, 2024

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
22 checks passed
@taiki-e
Copy link
Owner

taiki-e commented Jul 18, 2024

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