generate_coverage.sh 764 B

123456789101112131415
  1. #!/bin/bash
  2. # inspired by https://doc.rust-lang.org/rustc/instrument-coverage.html#tips-for-listing-the-binaries-automatically
  3. TEST_OBJECTS=$( \
  4. for file in $(cargo test --no-run 2>&1 | grep "target/debug/deps/pgcat-[[:alnum:]]\+" -o); \
  5. do \
  6. printf "%s %s " --object $file; \
  7. done \
  8. )
  9. rust-profdata merge -sparse /tmp/pgcat-*.profraw -o /tmp/pgcat.profdata
  10. bash -c "rust-cov export -ignore-filename-regex='rustc|registry' -Xdemangler=rustfilt -instr-profile=/tmp/pgcat.profdata $TEST_OBJECTS --object ./target/debug/pgcat --format lcov > ./lcov.info"
  11. genhtml lcov.info --title "PgCat Code Coverage" --css-file ./cov-style.css --no-function-coverage --highlight --ignore-errors source --legend --output-directory /tmp/cov --prefix $(pwd)