Skip to content

Bump minimum Bazel version and add C++/Rust usage examples - #34

Open
Subramanian-K812 wants to merge 3 commits into
eclipse-score:mainfrom
qorix-group:Subramanian-K812_add_cpp_rust_examples
Open

Subramanian-K812 wants to merge 3 commits into
eclipse-score:mainfrom
qorix-group:Subramanian-K812_add_cpp_rust_examples

Conversation

@Subramanian-K812

Copy link
Copy Markdown
Contributor

Add C++/Rust usage examples and bump minimum Bazel version to 8.6.0

Adds a runnable "getting started" example for test_scenarios_cpp/test_scenarios_rust, and
bumps the repo's minimum Bazel version.

What this PR does

  1. Bazel version — bumps .bazelversion from 8.4.2 to 8.6.0
  2. C++ examplescore/test_scenarios_cpp/examples/basic.cpp, wired as a new cc_binary
    target (:basic) in score/test_scenarios_cpp/BUILD.
  3. Rust examplescore/test_scenarios_rust/examples/basic.rs, wired as a new
    rust_binary target (:basic) in score/test_scenarios_rust/BUILD.
  4. Both examples implement two Scenarios (version.parse, version.satisfies_minimum)
    grouped under a nested version ScenarioGroup, demonstrating
    Scenario/ScenarioGroupImpl/TestContext/run_cli_app end to end.
    version.satisfies_minimum checks its input against this repo's own real minimum Bazel
    version (8.6.0), so success/failure is a genuine, real consequence of the input rather than
    scripted output.
  5. A root examples/BUILD aliases both (//examples:cpp_basic, //examples:rust_basic) and
    examples/README.md documents them, following the same examples/ layout used by
    kyron and score_orchestrator.

Files

  • .bazelversion8.4.28.6.0
  • score/test_scenarios_cpp/examples/basic.cpp — new, C++ example
  • score/test_scenarios_cpp/BUILD — adds the basic cc_binary target
  • score/test_scenarios_rust/examples/basic.rs — new, Rust example
  • score/test_scenarios_rust/BUILD — adds the basic rust_binary target
  • examples/BUILD — new, root-level aliases (cpp_basic, rust_basic)
  • examples/README.md — new, documents both examples

Verification

  • bazel build //... / bazel test //... --config=x86_64-linux under Bazel 8.6.0 — unaffected,
    still pass (10 targets, 2/2 tests)
  • bazel test --config=clang-tidy //score/test_scenarios_cpp:clang_tidy — passes (scope
    unchanged; doesn't cover examples/, same as tests/)
  • cargo clippy --locked --all-targets -- -D warnings at pinned 1.92.0 — clean, 0 warnings
    (covers the new Rust example via --all-targets)
  • ruff check . --exclude scripts/internal — all checks passed
  • bazel test //:requirements_test — passes
  • Both examples exercised directly for every documented command: --list-scenarios,
    --name version.parse --input 8.6.0, --name version.satisfies_minimum --input 8.6.0
    (success), --name version.satisfies_minimum --input 8.4.2 (genuine failure, exit 1),
    --name version.parse --input garbage (genuine parse failure, exit 1) — identical
    output/exit codes between C++ and Rust

Known limitations

  • check_direct_dependencies now warns (non-fatal) for bazel_skylib, rules_cc, and
    buildifier_prebuilt, whose declared versions in MODULE.bazel are older than what's
    actually resolved — pre-existing drift surfaced by Bazel 8.6's stricter checking, not
    introduced by this change.
  • The C++ example isn't covered by clang_tidy_test (that target's srcs only include the
    test_scenarios_cpp library, matching how tests/*.cpp is already excluded).

Comment thread examples/README.md Outdated

```bash
bazel run //examples:cpp_basic -- --list-scenarios
bazel run //examples:cpp_basic -- --name version.parse --input 8.6.0

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.

combining bazel version as example is confusing for user. Do something unrelated to env, even simple enumeration would be good


fn run(&self, input: &str) -> Result<(), String> {
let (major, minor, patch) = parse_version(input)?;
println!("major={major} minor={minor} patch={patch}");

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.

the whole point of scenarios is to use logging that comes with monotonic clock, same for cpp

Comment on lines +22 to +33
fn parse_version(input: &str) -> Result<(u32, u32, u32), String> {
let parts: Vec<&str> = input.split('.').collect();
let err = || format!("'{input}' is not a valid major.minor.patch version");
if parts.len() != 3 {
return Err(err());
}
let mut numbers = [0u32; 3];
for (i, part) in parts.iter().enumerate() {
numbers[i] = part.parse::<u32>().map_err(|_| err())?;
}
Ok((numbers[0], numbers[1], numbers[2]))
}

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.

create a struct with Serialize/Deserialize, create a custom type instance by parsing input json. take a look at kyron tests implementation

@Subramanian-K812
Subramanian-K812 force-pushed the Subramanian-K812_add_cpp_rust_examples branch from af0f2e2 to 3ec7773 Compare September 18, 2026 13:58
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