Kogia-sima / rust-covfix

Fix Rust coverage data based on source code
MIT License
14 stars 3 forks source link

Panicked at 'called `Result::unwrap()` on an `Err` value: StripPrefixError(())' #4

Open xnuter opened 4 years ago

xnuter commented 4 years ago

Hi,

I integrated rust-covfix using github-actions and it works fine, but then panics like this:

Run rust-covfix lcov.info -o lcov.info
Coverages are fixed successfully!
  line:   84.11% (2425 of 2883 lines)    => 88.62% (864 of 975 lines)
  branch: NaN% (0 of 0 branches) => NaN% (0 of 0 branches)

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: StripPrefixError(())', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rust-covfix-0.2.1/src/lcov.rs:202:57
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
##[error]Process completed with exit code 101.

(absence of branch coverage doesn't cause it, the same happens with --branch enabled).

https://github.com/aws/http-desync-guardian/runs/996432238?check_suite_focus=true

(Fix-coverage-data)

Also it seems to miss two source files:

https://coveralls.io/builds/32819498

metrics.rs
http_token_utils.rs

Thanks!

Kogia-sima commented 4 years ago

Hello, @xnuter. Thanks for reporting this bug.

Whether branch coverage is included should not be related with this error. This error is related to the path to source file specified in lcov.info.

Could you provide an full output with --verbose flag?

xnuter commented 4 years ago

It turns out grcov was including dependencies, like this:

../../../../../usr/share/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-1.4.2/src/lib.rs

In grcov I added configuration to ignore these dependencies:

ignore:
  - "*smallvec*"
  - "*lazy_static*"

And now it works beautifully: https://coveralls.io/builds/32874887

Probably rust-covfix can remove such files automatically as well. See an example of the all build including those: https://coveralls.io/builds/32811772