Skip to content

Commit 1acca7a

Browse files
eelcoemEmpting Eelco (ETAS-ECM/XPC-Fe2)
andauthored
Show requirements statistics and test results in documentation (#77)
* Add showing test results * Reenable starpls * Fix workflow file * Minor adjustments * Address reviewer comment, add test logs to docc * Fix failing formatter * Address reviewer comments * Fix failing checks * Fix merge coflicts, dac version * Minor fix * Fix formatting * Try fi xocverage --------- Co-authored-by: Empting Eelco (ETAS-ECM/XPC-Fe2) <Eelco.Empting2@etas.com>
1 parent d6b5092 commit 1acca7a

11 files changed

Lines changed: 291 additions & 43 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,24 @@ on:
3131
types: [created]
3232

3333
jobs:
34+
docs-verify:
35+
uses: eclipse-score/cicd-workflows/.github/workflows/docs-verify.yml@main
36+
permissions:
37+
pull-requests: write
38+
contents: read
39+
with:
40+
bazel-docs-verify-target: "//:docs_check"
41+
run-tests:
42+
uses: eclipse-score/cicd-workflows/.github/workflows/tests.yml@main
43+
permissions:
44+
contents: read
45+
pull-requests: read
46+
with:
47+
bazel-target: 'test //src/... //tests/... --config=x86_64-linux'
48+
upload-name: 'bazel-testlogs'
3449
build-docs:
50+
needs: run-tests
51+
if: ${{ always() }}
3552
uses: eclipse-score/cicd-workflows/.github/workflows/docs.yml@main
3653
permissions:
3754
contents: write
@@ -43,3 +60,4 @@ jobs:
4360
# the bazel-target depends on your repo specific docs_targets configuration (e.g. "suffix")
4461
bazel-target: "//:docs -- --github_user=${{ github.repository_owner }} --github_repo=${{ github.event.repository.name }}"
4562
retention-days: 3
63+
tests-report-artifact: bazel-testlogs

MODULE.bazel

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ module(
1616
)
1717

1818
# Bazel global rules
19-
bazel_dep(name = "rules_python", version = "1.4.1")
19+
bazel_dep(name = "rules_python", version = "1.8.3")
2020
bazel_dep(name = "rules_rust", version = "0.61.0")
21-
bazel_dep(name = "rules_cc", version = "0.2.14")
22-
bazel_dep(name = "aspect_rules_lint", version = "1.5.3")
21+
bazel_dep(name = "rules_cc", version = "0.2.16")
22+
bazel_dep(name = "aspect_rules_lint", version = "2.0.0")
2323
bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2")
2424
bazel_dep(name = "platforms", version = "1.0.0")
2525
bazel_dep(name = "flatbuffers", version = "25.9.23")
26-
bazel_dep(name = "download_utils", version = "1.0.1")
27-
bazel_dep(name = "googletest", version = "1.17.0.bcr.1")
26+
bazel_dep(name = "download_utils", version = "1.2.2")
27+
bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
2828

2929
# S-CORE process rules
3030
bazel_dep(name = "score_bazel_platforms", version = "0.0.4")

MODULE.bazel.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/conf.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
# For the full list of built-in configuration values, see the documentation:
1717
# https://www.sphinx-doc.org/en/master/usage/configuration.html
1818

19+
from itertools import chain
20+
from pathlib import Path
21+
22+
from docutils import nodes
23+
from docutils.parsers.rst import Directive
1924

2025
# -- Project information -----------------------------------------------------
2126
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
@@ -54,3 +59,43 @@
5459

5560
# Enable numref
5661
numfig = True
62+
63+
64+
class DisplayTestLogs(Directive):
65+
"""Find and display the raw content of all test.log files."""
66+
67+
def run(self):
68+
env = self.state.document.settings.env
69+
ws_root = Path(env.app.srcdir).parent
70+
71+
result_nodes = []
72+
for log_file in chain(
73+
(ws_root / "bazel-testlogs").rglob("test.log"),
74+
(ws_root / "tests-report").rglob("test.log"),
75+
):
76+
rel_path = log_file.relative_to(ws_root)
77+
78+
title = nodes.rubric(text=str(rel_path))
79+
result_nodes.append(title)
80+
81+
try:
82+
content = log_file.read_text(encoding="utf-8")
83+
except Exception as e:
84+
content = f"Error reading file: {e}"
85+
86+
code = nodes.literal_block(content, content)
87+
code["language"] = "text"
88+
code["source"] = str(rel_path)
89+
result_nodes.append(code)
90+
91+
if not result_nodes:
92+
para = nodes.paragraph(
93+
text="No test.log files found in bazel-testlogs or tests-report."
94+
)
95+
result_nodes.append(para)
96+
97+
return result_nodes
98+
99+
100+
def setup(app):
101+
app.add_directive("display-test-logs", DisplayTestLogs)

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Lifecycle
2121
:titlesonly:
2222

2323
module/*/index
24+
statistics.rst
2425

2526
Overview
2627
--------

docs/statistics.rst

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
.. _statistics:
2+
3+
Component Requirements Statistics
4+
=================================
5+
6+
Overview
7+
--------
8+
9+
.. needpie:: Requirements Status
10+
:labels: not valid, valid but not tested, valid and tested
11+
:colors: red, yellow, green
12+
13+
type == 'comp_req' and status == 'invalid'
14+
type == 'comp_req' and testlink == '' and (status == 'valid' or status == 'invalid')
15+
type == 'comp_req' and testlink != '' and (status == 'valid' or status == 'invalid')
16+
17+
In Detail
18+
---------
19+
20+
.. grid:: 2
21+
:class-container: score-grid
22+
23+
.. grid-item-card::
24+
25+
.. needpie:: Requirements marked as Valid
26+
:labels: not valid, valid
27+
:colors: red, orange, green
28+
29+
type == 'comp_req' and status == 'invalid'
30+
type == 'comp_req' and status == 'valid'
31+
32+
.. grid-item-card::
33+
34+
.. needpie:: Requirements with Codelinks
35+
:labels: no codelink, with codelink
36+
:colors: red, green
37+
38+
type == 'comp_req' and source_code_link == ''
39+
type == 'comp_req' and source_code_link != ''
40+
41+
.. grid-item-card::
42+
43+
.. needpie:: Test Results
44+
:labels: passed, failed, skipped
45+
:colors: green, red, orange
46+
47+
type == 'testcase' and result == 'passed'
48+
type == 'testcase' and result == 'failed'
49+
type == 'testcase' and result == 'skipped'
50+
51+
.. grid:: 2
52+
53+
.. grid-item-card::
54+
55+
Failed Tests
56+
57+
*Hint: This table should be empty. Before a PR can be merged all tests have to be successful.*
58+
59+
.. needtable:: FAILED TESTS
60+
:filter: result == "failed"
61+
:tags: TEST
62+
:columns: name as "testcase";result;fully_verifies;partially_verifies;test_type;derivation_technique;id as "link"
63+
64+
.. grid-item-card::
65+
66+
Skipped / Disabled Tests
67+
68+
.. needtable:: SKIPPED/DISABLED TESTS
69+
:filter: result != "failed" and result != "passed"
70+
:tags: TEST
71+
:columns: name as "testcase";result;fully_verifies;partially_verifies;test_type;derivation_technique;id as "link"
72+
73+
74+
75+
76+
All passed Tests
77+
-----------------
78+
79+
.. needtable:: SUCCESSFUL TESTS
80+
:filter: result == "passed"
81+
:tags: TEST
82+
:columns: name as "testcase";result;fully_verifies;partially_verifies;test_type;derivation_technique;id as "link"
83+
84+
85+
Details About Testcases
86+
------------------------
87+
88+
.. needpie:: Test Types Used In Testcases
89+
:labels: static-code-analysis, structural-statement-coverage, structural-branch-coverage, walkthrough, inspection, interface-test, requirements-based, resource-usage, control-flow-analysis, data-flow-analysis, fault-injection, struct-func-cov, struct-call-cov
90+
:legend:
91+
92+
type == 'testcase' and test_type == 'static-code-analysis'
93+
type == 'testcase' and test_type == 'structural-statement-coverage'
94+
type == 'testcase' and test_type == 'structural-branch-coverage'
95+
type == 'testcase' and test_type == 'walkthrough'
96+
type == 'testcase' and test_type == 'inspection'
97+
type == 'testcase' and test_type == 'interface-test'
98+
type == 'testcase' and test_type == 'requirements-based'
99+
type == 'testcase' and test_type == 'resource-usage'
100+
type == 'testcase' and test_type == 'control-flow-analysis'
101+
type == 'testcase' and test_type == 'data-flow-analysis'
102+
type == 'testcase' and test_type == 'fault-injection'
103+
type == 'testcase' and test_type == 'struct-func-cov'
104+
type == 'testcase' and test_type == 'struct-call-cov'
105+
106+
107+
.. needpie:: Derivation Techniques Used In Testcases
108+
:labels: requirements-analysis, boundary-values, equivalence-classes, fuzz-testing, error-guessing, explorative-testing
109+
:legend:
110+
111+
type == 'testcase' and derivation_technique == 'requirements-analysis'
112+
type == 'testcase' and derivation_technique == 'boundary-values'
113+
type == 'testcase' and derivation_technique == 'equivalence-classes'
114+
type == 'testcase' and derivation_technique == 'fuzz-testing'
115+
type == 'testcase' and derivation_technique == 'error-guessing'
116+
type == 'testcase' and derivation_technique == 'explorative-testing'
117+
118+
119+
Test Log Files
120+
--------------
121+
122+
.. display-test-logs::

src/health_monitoring_lib/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ load("@rules_rust//rust:defs.bzl", "rust_library", "rust_static_library", "rust_
1616
load("@score_baselibs//:bazel/unit_tests.bzl", "cc_gtest_unit_test")
1717

1818
COMMON_DEPS = [
19-
"@score_baselibs_rust//src/containers",
20-
"@score_baselibs_rust//src/log/score_log",
19+
"@score_baselibs_rust//src/containers:containers",
20+
"@score_baselibs_rust//src/log/score_log:score_log",
2121
"//src/launch_manager_daemon/health_monitor_lib/rust_bindings:monitor_rs",
2222
]
2323

src/health_monitoring_lib/cpp/tests/health_monitor_test.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,21 @@ using namespace score::hm;
2020

2121
class HealthMonitorTest : public ::testing::Test
2222
{
23+
protected:
24+
void SetUp() override
25+
{
26+
RecordProperty("TestType", "interface-test");
27+
RecordProperty("DerivationTechnique", "explorative-testing ");
28+
}
2329
};
2430

2531
// For first review round, only single test case to show up API
2632
TEST_F(HealthMonitorTest, TestName)
2733
{
34+
RecordProperty(
35+
"Description",
36+
"This test demonstrates the usage of HealthMonitor and DeadlineMonitor APIs. It creates a HealthMonitor with a "
37+
"DeadlineMonitor, retrieves the DeadlineMonitor, and tests starting a deadline.");
2838
// Setup deadline monitor construction.
2939
const MonitorTag deadline_monitor_tag{"deadline_monitor"};
3040
auto deadline_monitor_builder =

0 commit comments

Comments
 (0)