From 0f6b13a4ec3cfb0496668d3e654cb0c3253c7014 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Thu, 11 Apr 2024 01:32:07 -0700 Subject: [PATCH] Test coverage (#4596) * update .gitignore * add test-with-coverage.sh * coverage gutters extension comment * move lcov.info to target folder --------- Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> --- scripts/test-with-coverage.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 scripts/test-with-coverage.sh diff --git a/scripts/test-with-coverage.sh b/scripts/test-with-coverage.sh new file mode 100755 index 000000000..e4dfcddf8 --- /dev/null +++ b/scripts/test-with-coverage.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -e + +CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" + +cd $CWD/../ + +PACKAGE="$1" +echo "$PACKAGE" + +source scripts/start_dev_db.sh + +# tests are executed in working directory crates/api (or similar), +# so to load the config we need to traverse to the repo root +export LEMMY_CONFIG_LOCATION=../../config/config.hjson +export RUST_BACKTRACE=1 + +cargo install cargo-llvm-cov + +# Create lcov.info file, which is used by things like the Coverage Gutters extension for VS Code +cargo llvm-cov --workspace --all-features --no-fail-fast --lcov --output-path target/lcov.info + +# Add this to do printlns: -- --nocapture + +pg_ctl stop --silent +rm -rf $PGDATA