From c8e04ad0981d7a70c82626c89cad74c31c878886 Mon Sep 17 00:00:00 2001
From: Paul Andrey <paul.andrey@inria.fr>
Date: Thu, 2 Mar 2023 17:02:08 +0100
Subject: [PATCH] Configure coverage tool with 'pyproject.toml'.

* Add 'pytest-cov' (hence, indirectly, 'coverage') to third-party
  dependencies of test environments.
* Add configuration of 'coverage' to properly target declearn code
  (excluding auto-generated protobuf code as well as `test_utils`
  submodule) and be compatible with the use of multiprocessing in
  some functional~integration tests.
---
 pyproject.toml | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/pyproject.toml b/pyproject.toml
index 2d7af898..427d27ba 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -86,6 +86,7 @@ tests = [
     "pylint >= 2.14",
     "pytest >= 6.1",
     "pytest-asyncio",
+    "pytest-cov >= 4.0",
 ]
 
 [project.urls]
@@ -96,6 +97,18 @@ repository = "https://gitlab.inria.fr/magnet/declearn/declearn2.git"
 line-length = 79
 extend-exclude = "(.*_pb2.*py$)"  # exclude auto-generated protobuf code files
 
+[tool.coverage.run]
+# enable coverage collection within multiprocessing
+concurrency = ["multiprocessing"]
+parallel = true
+sigterm = true
+# define rules to select the code files that need covering
+source = ["declearn"]
+omit = [
+    ".*_pb2.*.py$",  # auto-generated rotobuf code files
+    "declearn/test_utils/*.py",  # dev-only test-oriented utils
+]
+
 [tool.mypy]
 exclude = [".*_pb2.*.py$"]
 follow_imports = "skip"  # otherwise excluded files are checked
-- 
GitLab