xd009642 / tarpaulin

A code coverage tool for Rust projects
https://crates.io/crates/cargo-tarpaulin
Apache License 2.0
2.5k stars 180 forks source link

#[cfg(not(tarpaulin_include))] Does not work on Crate Level #846

Closed nimanch closed 3 years ago

nimanch commented 3 years ago

Describe the bug When trying to Exclude certain Libraries from code coverage, I tried adding #[cfg(not(tarpaulin_include))] to my lib.rs file and I expected tarpaulin to parse the inner attributes from this file and apply to all other files within the crate as rustc would. Otherwise I would have to include this line in every file in my project ( And I am trying to avoid using --exclude-files flag) Example

Contents of lib.rs inside my project

![cfg(not(tarpaulin_include))]

![deny(rust_2018_idioms, warnings)]

![allow(

dead_code,
non_snake_case,
renamed_and_removed_lints,
unused_imports,
unused_mut

)]

![allow(clippy::all, clippy::pedantic)]

pub mod apis; pub mod models; pub mod utils;

pub use apis::{DockerApi, DockerApiClient};

Expected behavior The Config Attribute should have been applied to all files within the cargo project.

xd009642 commented 3 years ago

Ah yeah good catch, I've added the logic to handle this in https://github.com/xd009642/tarpaulin/pull/851 and a test to ensure there's no future regressions.

After this is done, I need to sort out some stuff to fix docker image publishing but once that's sorted I'll probably drop a new release but until then once the PR is merged you can always use it by installing via the git dependency