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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add support for MC/DC coverage #363

wants to merge 2 commits into from

Conversation

aytey
Copy link

@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
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.

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.

None yet

2 participants