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

Revert "Use -Clink-dead-code" #28

Merged
merged 2 commits into from
Jun 9, 2021
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
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,19 @@ or
cargo llvm-cov --open
```

With plain text report (if --output-path is not specified, the report will be printed to stdout):
With plain text report (if `--output-path` is not specified, the report will be printed to stdout):

```sh
cargo llvm-cov --text | less -R
```

With json report (if --output-path is not specified, the report will be printed to stdout):
With json report (if `--output-path` is not specified, the report will be printed to stdout):

```sh
cargo llvm-cov --json --output-path cov.json
```

With lcov report (if --output-path is not specified, the report will be printed to stdout):
With lcov report (if `--output-path` is not specified, the report will be printed to stdout):

```sh
cargo llvm-cov --lcov --output-path lcov.info
Expand Down Expand Up @@ -228,10 +228,11 @@ jobs:
fail_ci_if_error: true
```

Note: Currently, only line coverage is available on Codecov. This is because -Zinstrument-coverage does not support branch coverage and Codecov does not support region coverage. See also [#8] and [#12].
Note: Currently, only line coverage is available on Codecov. This is because `-Zinstrument-coverage` does not support branch coverage and Codecov does not support region coverage. See also [#8], [#12], and [#20].

## Known limitations

- Due to a bug of `-Zinstrument-coverage`, some files may be ignored. There is a known workaround for this issue, but note that the workaround is likely to cause another problem. See [rust-lang/rust#86177] and [#26] for more.
- Branch coverage is not supported yet. See [#8] and [rust-lang/rust#79649] for more.
- Support for doc tests is unstable and has known issues. See [#2] and [rust-lang/rust#79417] for more.
- Procedural macros are not supported yet.
Expand All @@ -242,11 +243,14 @@ See also [the code-coverage-related issues reported in rust-lang/rust](https://g
[#2]: https://github.com/taiki-e/cargo-llvm-cov/issues/2
[#8]: https://github.com/taiki-e/cargo-llvm-cov/issues/8
[#12]: https://github.com/taiki-e/cargo-llvm-cov/issues/12
[#20]: https://github.com/taiki-e/cargo-llvm-cov/issues/20
[#26]: https://github.com/taiki-e/cargo-llvm-cov/issues/26
[codecov]: https://codecov.io
[instrument-coverage]: https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/instrument-coverage.html
[rust-lang/rust#79121]: https://github.com/rust-lang/rust/issues/79121
[rust-lang/rust#79417]: https://github.com/rust-lang/rust/issues/79417
[rust-lang/rust#79649]: https://github.com/rust-lang/rust/issues/79649
[rust-lang/rust#86177]: https://github.com/rust-lang/rust/issues/86177

## License

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn run(args: impl IntoIterator<Item = impl Into<OsString> + Clone>) -> Result<()
debug!(RUSTFLAGS = ?rustflags);
// --remap-path-prefix for Sometimes macros are displayed with abs path
rustflags.push(format!(
" -Zinstrument-coverage -Clink-dead-code --remap-path-prefix {}/=",
" -Zinstrument-coverage --remap-path-prefix {}/=",
cx.metadata.workspace_root
));

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/coverage-reports/no_test/no_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"data":[{"files":[{"filename":"src/lib.rs","summary":{"branches":{"count":0,"covered":0,"notcovered":0,"percent":0},"functions":{"count":3,"covered":3,"percent":100},"instantiations":{"count":3,"covered":3,"percent":100},"lines":{"count":3,"covered":3,"percent":100},"regions":{"count":3,"covered":3,"notcovered":0,"percent":100}}},{"filename":"src/module.rs","summary":{"branches":{"count":0,"covered":0,"notcovered":0,"percent":0},"functions":{"count":1,"covered":0,"percent":0},"instantiations":{"count":1,"covered":0,"percent":0},"lines":{"count":7,"covered":0,"percent":0},"regions":{"count":6,"covered":0,"notcovered":6,"percent":0}}}],"totals":{"branches":{"count":0,"covered":0,"notcovered":0,"percent":0},"functions":{"count":4,"covered":3,"percent":75},"instantiations":{"count":4,"covered":3,"percent":75},"lines":{"count":10,"covered":3,"percent":30},"regions":{"count":9,"covered":3,"notcovered":6,"percent":33.333333333333329}}}],"type":"llvm.coverage.json.export","version":"2.0.1"}
{"data":[{"files":[{"filename":"src/lib.rs","summary":{"branches":{"count":0,"covered":0,"notcovered":0,"percent":0},"functions":{"count":3,"covered":3,"percent":100},"instantiations":{"count":3,"covered":3,"percent":100},"lines":{"count":3,"covered":3,"percent":100},"regions":{"count":3,"covered":3,"notcovered":0,"percent":100}}}],"totals":{"branches":{"count":0,"covered":0,"notcovered":0,"percent":0},"functions":{"count":3,"covered":3,"percent":100},"instantiations":{"count":3,"covered":3,"percent":100},"lines":{"count":3,"covered":3,"percent":100},"regions":{"count":3,"covered":3,"notcovered":0,"percent":100}}}],"type":"llvm.coverage.json.export","version":"2.0.1"}
8 changes: 0 additions & 8 deletions tests/fixtures/coverage-reports/no_test/no_test.lcov.info
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,4 @@ BRF:0
BFH:0
LF:3
LH:3
end_of_record
SF:src/module.rs
FNF:1
FNH:0
BRF:0
BFH:0
LF:7
LH:0
end_of_record
5 changes: 2 additions & 3 deletions tests/fixtures/coverage-reports/no_test/no_test.summary.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lib.rs 3 0 100.00% 3 0 100.00% 3 0 100.00% 0 0 -
module.rs 6 6 0.00% 1 1 0.00% 7 7 0.00% 0 0 -
src/lib.rs 3 0 100.00% 3 0 100.00% 3 0 100.00% 0 0 -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL 9 6 33.33% 4 1 75.00% 10 7 30.00% 0 0 -
TOTAL 3 0 100.00% 3 0 100.00% 3 0 100.00% 0 0 -
13 changes: 1 addition & 12 deletions tests/fixtures/coverage-reports/no_test/no_test.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
src/lib.rs:
1| 1|mod module;mod module;
2| |pub use module::*;
3| |
4| 1|#[test]
5| 1|fn f() {}

src/module.rs:
1| 0|pub fn match1(x: u32) {
2| 0| match x {
3| 0| 0 => {}
4| 0| 1 => {}
5| 0| 2 => {}
6| 0| _ => {}
7| | }
8| 0|}
5| 1|fn f() {}