Skip to content

Commit

Permalink
Merge #163
Browse files Browse the repository at this point in the history
163: Exclude build script by default r=taiki-e a=taiki-e

Closes #159 

Co-authored-by: Taiki Endo <te316e89@gmail.com>
  • Loading branch information
bors[bot] and taiki-e authored May 11, 2022
2 parents 03155b1 + e8d041b commit 3a8b3e1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 2 deletions.
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

0 comments on commit 3a8b3e1

Please sign in to comment.