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

Exclude build script by default #163

Merged
merged 1 commit into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
## [Unreleased]

- cargo-llvm-cov no longer changes the current directory when running cargo. ([#161](https://github.com/taiki-e/cargo-llvm-cov/pull/161))
- Exclude build script from report by default. ([#163](https://github.com/taiki-e/cargo-llvm-cov/pull/163))
You can use `--include-build-script` flag to include build script in report.

## [0.3.3] - 2022-05-06

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ OPTIONS:
--show-missing-lines
Show lines with no coverage

--include-build-script
Include build script in coverage report

--doctests
Including doc tests (unstable)

Expand Down
3 changes: 3 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ pub(crate) struct LlvmCovOptions {
/// Show lines with no coverage.
#[clap(long)]
pub(crate) show_missing_lines: bool,
/// Include build script in coverage report.
#[clap(long)]
pub(crate) include_build_script: bool,
}

impl LlvmCovOptions {
Expand Down
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,12 @@ fn object_files(cx: &Context) -> Result<Vec<OsString>> {
if stem == "build-script-build" || stem.starts_with("build_script_build-") {
let p = p.parent().unwrap();
if p.parent().unwrap().file_name().unwrap() == "build" {
let dir = p.file_name().unwrap().to_string_lossy();
if !cx.build_script_re.is_match(&dir) {
if cx.cov.include_build_script {
let dir = p.file_name().unwrap().to_string_lossy();
if !cx.build_script_re.is_match(&dir) {
return false;
}
} else {
return false;
}
}
Expand Down
3 changes: 3 additions & 0 deletions tests/long-help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ OPTIONS:
--show-missing-lines
Show lines with no coverage

--include-build-script
Include build script in coverage report

--doctests
Including doc tests (unstable)

Expand Down
3 changes: 3 additions & 0 deletions tests/short-help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ OPTIONS:
--show-missing-lines
Show lines with no coverage

--include-build-script
Include build script in coverage report

--doctests
Including doc tests (unstable)

Expand Down