Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,6 @@ in Bazel. Therefore following bazel rules are available:

Once the architecture is in place, the build parses the PlantUML diagram and validates it against the Bazel model. It verifies element names, structural hierarchy, and consistency between the declared diagram and the implemented architecture.

How is this verification done? i.e. what build / test target?

→ Full guide: :doc:`../architectural_design`
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,7 @@ To validate TRLC syntax and Traceability within the requirements, each of the re
bazel targets exposes via a marco already a test target, which can be run via e.g.:
``bazel test //:assumed_system_requirements_test``.

Why does it specify a relative path here? In the Build part it mentions building from the root, I think this distinction should be mentioned here (and saying to run the command from bazel/rules/rules_score/examples/minimal directory). Building from root or from the minimal directory seems to cause an issue with include paths? If building with full path, the include should be
#include "bazel/rules/rules_score/examples/minimal/src/my_unit.h" and if it's relative, it should be #include "src/my_unit.h". It doesn't seem to support building from the root and the tutorials dir.

→ Full guide: :doc:`../requirements`
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class_design.puml
src/my_unit.h
--------------

Is this required? "can" is very vague, it should say exactly when it's required / what the benefit is.
The public interface of the unit can be tied to its source symbols via a ``// trace:`` tag.

.. literalinclude:: ../../examples/minimal/src/my_unit.h
Expand Down Expand Up @@ -76,8 +77,10 @@ from the ``unit``:

The ``unit_design.static`` attribute accepts PlantUML files (class, state,
object diagrams); use ``dynamic`` for sequence and activity diagrams.
scope here is referring to unit(), not unit_design, right?
``scope`` declares which targets the unit "owns" — targets outside the scope
that appear in the transitive implementation closure fail the scope check at
build time.
What's the transitive implementation closure?

→ Full guide: :doc:`../unit_design`
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Instead, test intent is captured as a **Given-When-Then** description right
next to the code as record properties in the test name/body itself. The specification will
then be rendered in the traceability report, together with the test results and coverage information.

test/my_unit_test.cpp
src/my_unit_test.cpp
----------------------

.. literalinclude:: ../../examples/minimal/test/my_unit_test.cpp
.. literalinclude:: ../../examples/minimal/src/my_unit_test.cpp
:language: cpp
:lines: 14-

Expand All @@ -45,6 +45,7 @@ They are picked up the same way as ``lobster-tracing`` — as plain
traceability report. Test cases without them are still traced, but show up
without a Given-When-Then specification.

How do we generate the lobster report to see the given when then output?
BUILD
------

Expand Down Expand Up @@ -73,4 +74,4 @@ Run the tests with:

bazel test //:my_unit_test

→ Full guide: :doc:`../unit_design`
→ Full guide: :doc:`../validation`
12 changes: 10 additions & 2 deletions bazel/rules/rules_score/examples/minimal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ filegroup(
"requirements/feature_requirements.trlc",
"src/my_unit.cpp",
"src/my_unit.h",
"test/my_unit_test.cpp",
"src/my_unit_test.cpp",
],
visibility = ["//bazel/rules/rules_score:__pkg__"],
)
Expand Down Expand Up @@ -64,7 +64,7 @@ cc_library(

cc_test(
name = "my_unit_test",
srcs = ["test/my_unit_test.cpp"],
srcs = ["src/my_unit_test.cpp"],
deps = [
":my_unit_lib",
"@googletest//:gtest_main",
Expand All @@ -76,6 +76,13 @@ unit_design(
static = ["docs/class_design.puml"],
)

# bazel build //bazel/rules/rules_score/examples/minimal:MyUnit currently fails to complile:
# Failed to parse /home/q624760/.cache/bazel/_bazel_q624760/7f8ab4cad6514b4c7cf0f5238512a834/sandbox/linux-sandbox/729/execroot/_main/bazel/rules/rules_score/examples/minimal/docs/class_design.puml with any available parser
# Parsers tried: Component, Activity, Class, Sequence
# Parser with longest match: Class
# Failed at line 19: - _store : dict[str, str]
# Error: Pest error: Parsing error at (19, 21), expected [NUMBER], got []
# Target //bazel/rules/rules_score/examples/minimal:MyUnit failed to build
unit(
name = "MyUnit",
scope = ["//:my_unit_lib"],
Expand All @@ -99,5 +106,6 @@ dependable_element(
dependability_analysis = [],
integrity_level = "B",
requirements = [":feature_requirements"],
# It would be good to have an example of a component test which tests the interaction of 2 components / units
tests = [],
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,25 @@ TEST(MyUnitTest, ConfigureAndGet) {
"configure is called with a known key");
::testing::Test::RecordProperty("then", "get returns the configured value");

MyUnit unit;
// Given a default-constructed MyUnit instance
MyUnit unit{};

// When configure is called with a key that hasn't been configured yet
unit.configure("mode", "fast");

// Then get returns the configured value
EXPECT_EQ(unit.get("mode"), "fast");
}

TEST(MyUnitTest, MissingKeyReturnsEmpty) {
::testing::Test::RecordProperty("lobster-tracing", "MinimalExample.FEAT_002");

MyUnit unit;
EXPECT_EQ(unit.get("undefined"), "");
// Given a default-constructed MyUnit instance
MyUnit unit{};

// When get is called with a key that hasn't been configured yet
const auto retrieved_value = unit.get("undefined");

// Then get returns an empty string
EXPECT_EQ(retrieved_value, "");
}
Loading