Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions src/extensions/score_metamodel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,41 @@ score_pytest(
)

score_pytest(
name = "file_based_tests",
size = "medium",
name = "file_based_tests_architecture",
srcs = ["tests/test_rules_file_based.py"],
# All requirements already in the library so no need to have it double
data = glob(
[
"tests/**/*.rst",
"tests/**/*.yaml",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not forget to also add the .yaml file, one tests needs that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are all passing. Maybe you think of test_metamodel_load.py? That one is part of :unit_tests.

],
) + ["tests/rst/conf.py"],
data = glob(["tests/rst/architecture/*.rst"]) + ["tests/rst/conf.py"],
pytest_config = "//:pyproject.toml",
deps = [":score_metamodel"],
)

score_pytest(
name = "file_based_tests_attributes",
srcs = ["tests/test_rules_file_based.py"],
data = glob(["tests/rst/attributes/*.rst"]) + ["tests/rst/conf.py", "tests/rst/attributes/needs.json"],
pytest_config = "//:pyproject.toml",
deps = [":score_metamodel"],
)

score_pytest(
name = "file_based_tests_graph",
srcs = ["tests/test_rules_file_based.py"],
data = glob(["tests/rst/graph/*.rst"]) + ["tests/rst/conf.py"],
pytest_config = "//:pyproject.toml",
deps = [":score_metamodel"],
)

score_pytest(
name = "file_based_tests_id_contains_feature",
srcs = ["tests/test_rules_file_based.py"],
data = glob(["tests/rst/id_contains_feature/*.rst"]) + ["tests/rst/conf.py"],
pytest_config = "//:pyproject.toml",
deps = [":score_metamodel"],
)

score_pytest(
name = "file_based_tests_options",
srcs = ["tests/test_rules_file_based.py"],
data = glob(["tests/rst/options/*.rst"]) + ["tests/rst/conf.py"],
pytest_config = "//:pyproject.toml",
deps = [":score_metamodel"],
)
29 changes: 29 additions & 0 deletions src/extensions/score_metamodel/tests/rst/attributes/needs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"current_version": "1.0",
"project": "test",
"project_url": "https://eclipse-score.github.io/process_description/main/",
"versions": {
"1.0": {
"needs": {
"doc_getstrt__req__process": {
"docname": "getting_started",
"id": "doc_getstrt__req__process",
"lineno": 1,
"status": "valid",
"title": "Process requirement (stub for tests)",
"type": "doc_req",
"type_name": "doc_req"
},
"gd_guidl__req__engineering": {
"docname": "guidelines",
"id": "gd_guidl__req__engineering",
"lineno": 1,
"status": "valid",
"title": "Engineering guideline requirement (stub for tests)",
"type": "gd_req",
"type_name": "gd_req"
}
}
}
}
}
6 changes: 0 additions & 6 deletions src/extensions/score_metamodel/tests/rst/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@
"score_metamodel",
]

needs_external_needs = [
{
"base_url": "https://eclipse-score.github.io/process_description/main/",
"json_url": "https://eclipse-score.github.io/process_description/main/needs.json",
}
]
# We add these suppress_warnings here to ease the load of the warnings
# In the future we might want to check if ANY warnings comes in the document
# And then ensure that we error, as this could also be parsing errors etc.
Expand Down
15 changes: 15 additions & 0 deletions src/extensions/score_metamodel/tests/test_rules_file_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,21 @@ def test_rst_files(

# Build the documentation with the enabled checks
app.config.score_metamodel_checks = rst_data.enabled_checks

# Replace any network json_url with a local json_path to avoid network I/O in tests
local_needs = RST_DIR / Path(rst_file).parent / "needs.json"
if local_needs.exists():
shutil.copy(local_needs, app.srcdir)
app.config.needs_external_needs = [
{k: v for k, v in ext.items() if k != "json_url"}
| {"json_path": "needs.json"}
if "json_url" in ext
else ext
for ext in (app.config.needs_external_needs or [])
]
else:
app.config.needs_external_needs = []
Comment thread
a-zw marked this conversation as resolved.

app.build()

# Collect the warnings
Expand Down
Loading