run.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. rm -rf /app/target/ || true
  3. rm /app/*.profraw || true
  4. rm /app/pgcat.profdata || true
  5. rm -rf /app/cov || true
  6. export LLVM_PROFILE_FILE="/app/pgcat-%m-%p.profraw"
  7. export RUSTC_BOOTSTRAP=1
  8. export CARGO_INCREMENTAL=0
  9. export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort -Cinstrument-coverage"
  10. export RUSTDOCFLAGS="-Cpanic=abort"
  11. cd /app/
  12. cargo clean
  13. cargo build
  14. cargo test --tests
  15. bash .circleci/run_tests.sh
  16. TEST_OBJECTS=$( \
  17. for file in $(cargo test --no-run 2>&1 | grep "target/debug/deps/pgcat-[[:alnum:]]\+" -o); \
  18. do \
  19. printf "%s %s " --object $file; \
  20. done \
  21. )
  22. echo "Generating coverage report"
  23. rust-profdata merge -sparse /app/pgcat-*.profraw -o /app/pgcat.profdata
  24. bash -c "rust-cov export -ignore-filename-regex='rustc|registry' -Xdemangler=rustfilt -instr-profile=/app/pgcat.profdata $TEST_OBJECTS --object ./target/debug/pgcat --format lcov > ./lcov.info"
  25. genhtml lcov.info --title "PgCat Code Coverage" --css-file ./cov-style.css --highlight --no-function-coverage --ignore-errors source --legend --output-directory cov --prefix $(pwd)
  26. rm /app/*.profraw
  27. rm /app/pgcat.profdata