Skip to content

Commit 66a9c2d

Browse files
committed
Merge remote-tracking branch 'origin/main' into template_inspection_needs
# Conflicts: # src/extensions/score_metamodel/metamodel.yaml
2 parents 72bdbf9 + 45e72c7 commit 66a9c2d

28 files changed

Lines changed: 989 additions & 727 deletions

.github/workflows/renovate.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ http_file(
6969
urls = ["https://github.com/withered-magic/starpls/releases/download/v0.1.21/starpls-linux-amd64"],
7070
)
7171

72-
bazel_dep(name = "score_process", version = "1.6.0")
72+
bazel_dep(name = "score_process", version = "2.0.1")
7373

7474
# Provide the tools from the devcontainer to Bazel
7575
bazel_dep(name = "score_devcontainer", version = "1.7.0")

MODULE.bazel.lock

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

docs/internals/extensions/rst_filebased_testing.md

Lines changed: 87 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,111 +4,141 @@
44
## Test Function
55
The functionality of the Sphinx build rules can be verified with test rst files.
66

7-
The function *test_check_rules* in *test_rules_file_based.py* is executed for
7+
The function *test_rst_files* in *test_rules_file_based.py* is executed for
88
each rst file in the directory *rst*.
99
It creates a SphinxTestApp and a document source folder with an index.rst file
1010
that contains a toctree with the given rst file.
1111

1212
It uses the SphinxTestApp to build the documentation and checks for the
1313
**expected/not expected** warnings.
1414

15+
**It has it's OWN conf.py, so if changes need to be made ensure they are made in there**
16+
1517
## Create a test rst file
16-
To add a new test case create a new rst file in the rst directory.
18+
To add a new test case either create a new rst file in the rst directory,
19+
or add it to an existing one if it tests something similar
1720
The test files can also be organized in a subfolder structure below directory rst.
18-
The test files are expected to contain the following format:
1921

20-
#CHECK: <check functions>
22+
Each test file consists of two parts:
2123

22-
#EXPECT[+x]: <warning message>
23-
#EXPECT-NOT[+x]: <warning message>
24+
1. Exactly **one** `test_metadata` need at the top of the file. It declares which
25+
check(s) to run and links the test to the requirements it verifies.
26+
2. One or more Sphinx-Needs directives. A need that should (or should not) emit a
27+
warning carries an `:expect:` / `:expect_not:` option describing that warning.
2428

25-
<need information>
29+
### The `test_metadata` need
2630

27-
**\<check functions>**<br>
28-
Check functions (comma separated) to be used for the Sphinx build. Following
29-
warnings will only be generated by these check functions.
30-
Only one CHECK statement per file. Usually at the very top.
31-
If CHECK is not provided, all checks are enabled.
31+
`test_metadata` is now a real Sphinx-Needs directive (not a comment). There must
32+
be exactly one per file:
3233

33-
**\<warning message>**<br>
34-
Message text which is expected/not expected during the
35-
Sphinx build to be shown.
36-
This message is checked for the Sphinx-Needs directive
37-
specified after the EXPECT/EXPECT-NOT statement.
34+
.. code-block:: rst
3835

39-
This message needs a '[+x]'offset after the 'EXPECT/-NOT' that should point to the need
40-
that should (not) emit the warning.
36+
.. test_metadata::
37+
:id: test_metadata__<unique_name>
38+
:partially_verifies_list: <requirement id(s)>
39+
:test_type: requirements_based
40+
:derivation_technique: requirements_based
4141

42-
**\<need information>**<br>
43-
One or more Sphinx-Needs directives needed for the
44-
Sphinx document build
42+
<description of what this file tests>
4543

46-
**Example:**
44+
**\<check functions>**
45+
All checks are run in each rst test file to ensure no contradiction and make testing easier / more complete
4746

48-
#CHECK: check_options
49-
#EXPECT[+2]: std_wp__test__abcd: is missing required attribute: `status`.
47+
**\<requirement id(s)>**`:partially_verifies_list:` / `:fully_verifies_list:`<br>
48+
The requirement(s) this test verifies. At least one of `:partially_verifies_list:`
49+
or `:fully_verifies_list:` must be provided, otherwise the test fails.
5050

51-
.. std_wp:: Test requirement
52-
:id: std_wp__test__abcd
51+
**`:test_type:` / `:derivation_technique:`**<br>
52+
Describe how the test was derived. They are attached as properties to the test
53+
result.
5354

54-
This example verifies that the warning message
55-
*std_wp__test__abcd: is missing required attribute: \`status\`*
56-
is shown during the Sphinx build. Only the *check_options* check is enabled.
55+
### Needs with expectations
5756

58-
With the '[+2]' after the 'EXPECT' we tell the parser that we want this warning
59-
to be emitted and checked for 2 lines underneath
57+
The `:expect:` / `:expect_not:` options live **on the need that is being tested**.
58+
There is no separate statement and no `[+x]` line offset anymore &mdash; the warning is
59+
matched against the need's own location.
6060

61-
There is multiple things that are not allowed for example, you need to have
62-
a new line between the EXPECT/-NOT and the need that it refers to
61+
**\<warning message>** &mdash; `:expect:` / `:expect_not:`<br>
62+
Message text which is expected / not expected during the Sphinx build for this
63+
need. You only need to match a unique substring, not the full message.
6364

64-
**Negative Example**
65+
A need **without** `:expect:` or `:expect_not:` is treated as a setup /
66+
prerequisite need (for example a link target) and is not asserted against.
6567

68+
**Example:**
69+
70+
.. code-block:: rst
71+
72+
.. test_metadata::
73+
:id: test_metadata__mandatory_options
74+
:partially_verifies_list: tool_req__docs__status
75+
:test_type: requirements_based
76+
:derivation_technique: requirements_based
77+
78+
Tests that mandatory options are enforced.
6679

67-
#EXPECT-NOT[+1]: std_wp__test__abcd: is missing required attribute: `status`.
6880
.. std_wp:: Test requirement
69-
:id: std_wp__test__abcd
81+
:id: std_wp__test__abcd
82+
:expect: std_wp__test__abcd: is missing required attribute: `status`.
7083

71-
This will error and let you know that an offset of '1' is not allowed and you
72-
need to add a new line beneath the Warning Statement
84+
This example verifies that the warning message
85+
*std_wp__test__abcd: is missing required attribute: \`status\`* is shown during
86+
the Sphinx build.
7387

74-
## Graph check tests
88+
**Expect-not example:**
7589

76-
Graph checks (defined in `metamodel.yaml` under `graph_checks:`) are all executed
77-
by a single Python function `check_metamodel_graph`. Use that function name in `#CHECK:`:
90+
.. std_wp:: Test requirement
91+
:id: std_wp__test_options__abce
92+
:status: active
93+
:expect_not: attribute
7894

79-
#CHECK: check_metamodel_graph
95+
Here the need is fully valid, so we assert that no warning containing the
96+
substring *attribute* is emitted for it.
8097

81-
Graph check test files live in `tests/rst/graph/`.
98+
> **Note:** RST comments used to separate or describe cases (for example
99+
> `.. All required options are present`) must not contain `::`, otherwise the
100+
> parser counts them as needs.
82101
83102
### Warning message format
84103

85-
`check_metamodel_graph` emits warnings in this shape:
104+
You only need to match a unique substring, not the full message. For example:
86105

87-
{need_id}: Parent need `{parent_id}` does not fulfill condition `{condition}`. Explanation: {explanation}
106+
:expect: wp__bad: Parent need `std_req__aspice_40__bp`
88107

89-
You only need to match a unique substring, not the full message. For example:
108+
.. hint::
90109

91-
#EXPECT[+2]: wp__bad: Parent need `std_req__aspice_40__bp`
110+
For `:expect:` use as much as possible of the error message, however for `:expect_not:` use as little as possible
111+
to catch all other issues that MIGHT occur and to avoid for typos etc.
92112

93113
### Setup needs
94114

95-
Prerequisite needs (link targets, shared fixtures) belong at the top of the file
96-
with no `EXPECT`/`EXPECT-NOT` annotation. The framework only checks annotated lines,
97-
so unannotated needs are invisible to the assertion logic.
115+
Prerequisite needs (link targets, shared fixtures) carry no `:expect:` /
116+
`:expect_not:` option. The framework only asserts on needs that have one of these
117+
options, so unannotated needs are invisible to the assertion logic.
98118

99119
### The "exempt" case
100120

101121
A need that does not meet the `condition:` in the YAML check definition is not
102-
selected by the check at all — no warning is emitted. Test this with `EXPECT-NOT`:
122+
selected by the check at all &mdash; no warning is emitted. Test this with
123+
`:expect_not:`:
103124

104-
#EXPECT-NOT[+2]: <something from the explanation>
125+
.. code-block:: rst
105126

106127
.. workproduct:: No link at all
107128
:id: wp__no_link
129+
:expect_not: <something from the explanation>
108130

109131
### Full example (graph check)
110132

111-
#CHECK: check_metamodel_graph
133+
.. code-block:: rst
134+
135+
.. test_metadata::
136+
:id: test_metadata__graph_aspice_40
137+
:partially_verifies_list: gd_req__aspice_40__parent_link
138+
:test_type: requirements_based
139+
:derivation_technique: requirements_based
140+
141+
Verifies the ASPICE 40 IIC parent-link graph check.
112142

113143
.. std_req:: ASPICE 40 IIC requirement
114144
:id: std_req__aspice_40__iic_1
@@ -120,23 +150,20 @@ selected by the check at all — no warning is emitted. Test this with `EXPECT-N
120150

121151
.. Positive: links to allowed target — no warning.
122152

123-
#EXPECT-NOT[+2]: ASPICE 40 IIC
124-
125153
.. workproduct:: Valid workproduct
126154
:id: wp__valid
127155
:complies: std_req__aspice_40__iic_1
156+
:expect_not: ASPICE 40 IIC
128157

129158
.. Exempt: no complies link — condition not met, check skipped.
130159

131-
#EXPECT-NOT[+2]: ASPICE 40 IIC
132-
133160
.. workproduct:: Workproduct without link
134161
:id: wp__no_link
162+
:expect_not: ASPICE 40 IIC
135163

136164
.. Negative: links to disallowed target — warning expected.
137165

138-
#EXPECT[+2]: wp__bad: Parent need `std_req__aspice_40__bp_1`
139-
140166
.. workproduct:: Invalid workproduct
141167
:id: wp__bad
142168
:complies: std_req__aspice_40__bp_1
169+
:expect: wp__bad: Parent need `std_req__aspice_40__bp_1`

0 commit comments

Comments
 (0)