feat(coverage): Add simple coverage (#2067)

* Add test aggregator to all directories.
* Implement coverage script.
This commit is contained in:
Álex Cabeza Romero 2023-09-27 15:53:23 +02:00 committed by GitHub
parent 7797b2cd03
commit d864db3fb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 146 additions and 11 deletions

7
.gitignore vendored
View File

@ -57,3 +57,10 @@ nimbus-build-system.paths
*.sqlite3-wal *.sqlite3-wal
/examples/nodejs/build/ /examples/nodejs/build/
# Coverage
coverage_html_report/
*.info
# Wildcard
*.ignore.*

52
scripts/run_cov.sh Executable file
View File

@ -0,0 +1,52 @@
#!/bin/sh
# Check if env.sh has been loaded, or if this file is being ran from it.
# Using NIMC as a proxy for this, as it's defined in the nimbus-build-system's env.sh.
if [ -z "$NIMC" ]
then
echo "[ERROR] This tool can only be ran from the Nimbus environment. Either:"
echo "- Source env.sh 'source /path/to/env.sh', and then run the script directly '/path/to/scripts/run_cov.sh'."
echo "- Run this script as a parameter to env.sh '/path/to/env.sh /path/to/scripts/run_cov.sh'."
exit 1
fi
# Check for lcov tool
which lcov 1>/dev/null 2>&1
if [ $? != 0 ]
then
echo "[ERROR] You need to have lcov installed in order to generate the test coverage report."
exit 2
fi
SCRIPT_PATH=$(dirname "$(realpath -s "$0")")
REPO_ROOT=$(dirname $SCRIPT_PATH)
generated_not_to_break_here="$REPO_ROOT/generated_not_to_break_here"
if [ -f $generated_not_to_break_here ]
then
echo "The file '$generated_not_to_break_here' already exists. Do you want to continue? (y/n)"
read -r response
if [ "$response" != "y" ]
then
exit 3
fi
fi
output_directory="$REPO_ROOT/coverage_html_report"
base_filepath="$REPO_ROOT/tests/test_all"
nim_filepath=$base_filepath.nim
info_filepath=$base_filepath.info
# Workaround a nim bug. See https://github.com/nim-lang/Nim/issues/12376
touch $generated_not_to_break_here
# Generate the coverage report
nim --debugger:native --passC:--coverage --passL:--coverage --passL:librln_v0.3.4.a --passL:-lm c $nim_filepath
lcov --base-directory . --directory . --zerocounters -q
$base_filepath
lcov --base-directory . --directory . --include "*/waku/**" --include "*/apps/**" --exclude "*/vendor/**" -c -o $info_filepath
genhtml -o $output_directory $info_filepath
# Cleanup
rm -rf $info_filepath $base_filepath nimcache
rm $generated_not_to_break_here

View File

@ -1,9 +1,3 @@
{.used.} {.used.}
# Waku common test suite import ./common/test_all
import
./common/test_envvar_serialization,
./common/test_confutils_envvar,
./common/test_protobuf_validation,
./common/test_enr_builder,
./common/test_sqlite_migrations

View File

@ -1,6 +1,3 @@
## Wakunode2 ## Wakunode2
import import ./wakunode2/test_all
./wakunode2/test_app,
./wakunode2/test_validators

View File

@ -0,0 +1,7 @@
import
./test_base64_codec,
./test_confutils_envvar,
./test_enr_builder,
./test_envvar_serialization,
./test_protobuf_validation,
./test_sqlite_migrations

6
tests/test_all.nim Normal file
View File

@ -0,0 +1,6 @@
{.used.}
import
./all_tests_common,
./all_tests_waku,
./all_tests_wakunode2

View File

@ -0,0 +1,13 @@
{.used.}
import
./test_driver_postgres_query,
./test_driver_postgres,
./test_driver_queue_index,
./test_driver_queue_pagination,
./test_driver_queue_query,
./test_driver_queue,
./test_driver_sqlite_query,
./test_driver_sqlite,
./test_retention_policy,
./test_waku_archive

View File

@ -0,0 +1,9 @@
{.used.}
import
./test_message_digest,
./test_namespaced_topics,
./test_peers,
./test_published_address,
./test_sharding,
./test_time

View File

@ -0,0 +1,6 @@
{.used.}
import
./test_waku_client,
./test_waku_filter_protocol,
./test_waku_filter

View File

@ -0,0 +1,5 @@
{.used.}
import
./test_waku_relay,
./test_wakunode_relay

View File

@ -0,0 +1,7 @@
{.used.}
import
./test_rln_group_manager_onchain,
./test_rln_group_manager_static,
./test_waku_rln_relay,
./test_wakunode_rln_relay

View File

@ -0,0 +1,7 @@
{.used.}
import
./test_resume,
./test_rpc_codec,
./test_waku_store,
./test_wakunode_store

View File

@ -0,0 +1,5 @@
{.used.}
import
./test_app,
./test_validators

View File

@ -0,0 +1,8 @@
{.used.}
import
./test_jsonrpc_admin,
./test_jsonrpc_debug,
./test_jsonrpc_filter,
./test_jsonrpc_relay,
./test_jsonrpc_store

View File

@ -0,0 +1,12 @@
{.used.}
import
./test_rest_debug_serdes,
./test_rest_debug,
./test_rest_filter,
./test_rest_health,
./test_rest_legacy_filter,
./test_rest_relay_serdes,
./test_rest_relay,
./test_rest_serdes,
./test_rest_store