Skip to content

test: inject filesystem, parser and writer into Kvs::Open - #621

Draft
arkjedrz wants to merge 1 commit into
eclipse-score:mainfrom
qorix-group:arkjedrz_tests-03-cpp-fault-injection
Draft

arkjedrz wants to merge 1 commit into
eclipse-score:mainfrom
qorix-group:arkjedrz_tests-03-cpp-fault-injection

Conversation

@arkjedrz

Copy link
Copy Markdown
Contributor
  • Kvs::Open() takes the filesystem, the JSON parser and the JSON writer as required parameters. A null pointer violates a precondition, checked with the S-CORE assertion macro.
  • KvsBuilder::Build() and the deprecated open() pass the real objects.
  • Tests open the KVS through a file-local OpenKvs() helper. Its defaulted parameters supply the real objects, and tests pass mocks in their place.
  • Convert 6 tests to inject mocks and drive the public API.
  • Split the two filename failure tests into a real and a mock case.
  • Replace the no_parent_path sub-case with a public-API test for an empty working directory. It pins a known defect.
  • Add a death test for the null precondition.

Relates to #574

@arkjedrz arkjedrz self-assigned this Oct 29, 2026
@arkjedrz
arkjedrz requested a review from umaucher as a code owner October 29, 2026 08:44
@arkjedrz arkjedrz changed the title test(kvs): inject filesystem, parser and writer into Kvs::Open test: inject filesystem, parser and writer into Kvs::Open Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run --lockfile_mode=error //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Starting local Bazel server (8.7.0) and connecting to it...
INFO: Invocation ID: 4ada7969-37ef-488b-b4b7-a9450a28bb5a
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 2 packages loaded
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Analyzing: target //:license-check (3 packages loaded, 0 targets configured)
Analyzing: target //:license-check (3 packages loaded, 0 targets configured)

Analyzing: target //:license-check (73 packages loaded, 14 targets configured)

Analyzing: target //:license-check (99 packages loaded, 14 targets configured)

Analyzing: target //:license-check (100 packages loaded, 14 targets configured)

Analyzing: target //:license-check (100 packages loaded, 14 targets configured)

Analyzing: target //:license-check (152 packages loaded, 2308 targets configured)

Analyzing: target //:license-check (197 packages loaded, 6848 targets configured)

Analyzing: target //:license-check (207 packages loaded, 11661 targets configured)

Analyzing: target //:license-check (207 packages loaded, 11661 targets configured)

Analyzing: target //:license-check (207 packages loaded, 11661 targets configured)

Analyzing: target //:license-check (209 packages loaded, 15886 targets configured)

INFO: Analyzed target //:license-check (213 packages loaded, 17903 targets configured).
[3 / 14] [Prepa] Expanding template external/score_tooling+/dash/tool/formatters/dash_format_converter [for tool]
INFO: From Generating Dash formatted dependency file ...:
INFO: Successfully converted 50 packages from Cargo.lock to bazel-out/k8-fastbuild/bin/tools/formatted.txt
[13 / 16] JavaToolchainCompileClasses external/rules_java+/toolchains/platformclasspath_classes; 0s disk-cache, processwrapper-sandbox
[14 / 16] JavaToolchainCompileBootClasspath external/rules_java+/toolchains/platformclasspath.jar; 0s disk-cache, processwrapper-sandbox
INFO: Found 1 target...
Target //tools:license.check.license_check up-to-date:
  bazel-bin/tools/license.check.license_check
  bazel-bin/tools/license.check.license_check.jar
INFO: Elapsed time: 64.342s, Critical Path: 2.81s
INFO: 16 processes: 12 internal, 3 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 16 total actions
INFO: Running command line: bazel-bin/tools/license.check.license_check tools/formatted.txt <args omitted>
[main] INFO Querying Eclipse Foundation for license data for 42 items.
[main] INFO Found 32 items.
[main] INFO Querying ClearlyDefined for license data for 10 items.
[main] INFO Found 10 items.
[main] INFO License information could not be automatically verified for the following content:
[main] INFO 
[main] INFO crate/cratesio/-/lazy_static/1.5.1
[main] INFO 
[main] INFO This content is either not correctly mapped by the system, or requires review.

- Kvs::Open() takes the filesystem, the JSON parser and the JSON
  writer as required parameters. A null pointer violates a
  precondition, checked with the S-CORE assertion macro.
- KvsBuilder::Build() and the deprecated open() pass the real
  objects.
- Tests open the KVS through a file-local OpenKvs() helper. Its
  defaulted parameters supply the real objects, and tests pass mocks
  in their place.
- Convert 6 tests to inject mocks and drive the public API.
- Split the two filename failure tests into a real and a mock case.
- Replace the no_parent_path sub-case with a public-API test for an
  empty working directory. It pins a known defect.
- Add a death test for the null precondition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@arkjedrz
arkjedrz force-pushed the arkjedrz_tests-03-cpp-fault-injection branch from 4923d74 to 9e26819 Compare October 29, 2026 09:08
@arkjedrz
arkjedrz deployed to workflow-approval October 29, 2026 09:08 — with GitHub Actions Active
@arkjedrz
arkjedrz deployed to workflow-approval October 29, 2026 09:08 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

Documentation preview for this pull request is available at:
pr-621: https://eclipse-score.github.io/persistency/pr-621/

Comment thread score/kvs/kvs.cpp
std::unique_ptr<score::json::IJsonParser> parser,
std::unique_ptr<score::json::IJsonWriter> writer) noexcept
{
SCORE_LANGUAGE_FUTURECPP_PRECONDITION_PRD_MESSAGE(filesystem != nullptr, "Kvs::Open: filesystem must not be null");

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.

why do you mandate to have them as mandatory args .

why not makeing them optional parameters with defult value = nullptr then in testing scenario we can pass them but in normal use cases not passing them to open function ?

@arkjedrz

Copy link
Copy Markdown
Contributor Author

Halting the topic until #538 is fixed - approach will have to change.

@arkjedrz
arkjedrz marked this pull request as draft October 30, 2026 13:05

This branch was successfully deployed

1 active deployment
workflow-approval — 9e268193 Deployed Oct 29, 2026 by arkjedrz via qnx-build (score-qnx-aarch64) / approval #1605
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants