test: change test framework from cucumber-cpp to cwt-cucumber#89
test: change test framework from cucumber-cpp to cwt-cucumber#89NeaguGeorgiana23 wants to merge 9 commits intomainfrom
Conversation
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the project's testing infrastructure by migrating from the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request successfully migrates the testing framework from cucumber-cpp to cwt-cucumber, which is a great move towards a more modern and lightweight C++20 BDD framework. The changes involve removing the Ruby-based dependencies and build configurations, and replacing them with the new setup for cwt-cucumber. The updates to the Bazel build files and the C++ step definitions are consistent and correct. I have one suggestion to improve the maintainability and security of how the new cwt-cucumber dependency is fetched.
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
test/e2e/cwt_extension.bzl
Outdated
| #Inject a BUILD file to compile it on the fly | ||
| build_file_content = """ | ||
| load("@rules_cc//cc:defs.bzl", "cc_library") | ||
|
|
||
| #Generate the version file from the template | ||
| genrule( | ||
| name = "generate_version_file", | ||
| srcs =["src/version.template"], | ||
| outs = ["src/version.hpp"], | ||
| cmd = "sed 's/@PROJECT_VERSION@/{version}/g' $< > $@", | ||
| ) | ||
|
|
||
| cc_library( | ||
| name = "cwt-cucumber", | ||
| srcs = glob( | ||
| ["src/**/*.cpp"], | ||
| exclude =["src/main.cpp"] | ||
| ), | ||
| hdrs = glob([ | ||
| "src/**/*.hpp", | ||
| ]) +[ | ||
| "src/version.hpp", | ||
| ], | ||
| strip_include_prefix = "src", | ||
| copts =["-std=c++20"], | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
| """.replace("{version}", version), | ||
| ) |
There was a problem hiding this comment.
I think It should be moved into it's own file.
There was a problem hiding this comment.
wdym exactly by this?
MODULE.bazel
Outdated
| cwt_ext = use_extension("//test/e2e:cwt_extension.bzl", "cwt_ext") | ||
| use_repo(cwt_ext, "cwt_cucumber") No newline at end of file |
There was a problem hiding this comment.
I'm not an expert on bazel, but on cpp-sdk-contrib I was using git_repository rule instead of writing my own extension. If we introduce it here, we have clear dependency definition and one place for specifing dependencies version. (currently you need to specify version of this library in cwt_extension.bzl). I checked that if we change those lines to:
git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
# Fetch cwt-cucumber directly from GitHub
git_repository(
name = "cwt_cucumber",
build_file = "//test/e2e:cwt-cucumber.BUILD",
remote = "https://github.com/ThoSe1990/cwt-cucumber.git",
tag = "2.8",
)
And create //test/e2e/cwt-cucumber.BUILD with contents:
load("@rules_cc//cc:defs.bzl", "cc_library")
# Generate the version file from the template by extracting the version from CMakeLists.txt
genrule(
name = "generate_version_file",
srcs = [
"CMakeLists.txt",
"src/version.template",
],
outs = ["src/version.hpp"],
cmd = """
VERSION=$$(grep 'project(cwt-cucumber VERSION' $(location CMakeLists.txt) | sed 's/.*VERSION \\([0-9.]*\\).*/\\1/');
sed "s/@PROJECT_VERSION@/$$VERSION/g" $(location src/version.template) > $@
""",
)
cc_library(
name = "cwt-cucumber",
srcs = glob(
["src/**/*.cpp"],
exclude = ["src/main.cpp"],
),
hdrs = glob([
"src/**/*.hpp",
]) + [
"src/version.hpp",
],
copts = ["-std=c++20"],
strip_include_prefix = "src",
visibility = ["//visibility:public"],
)
We get the same functionality, but in my opinion with clearer definition of dependencies and structure. Unfortunately, it makes the generation of version.hpp file a bit more complex, since we need to extract the info on version from the CMake file. @oxddr do you know what's the best practice here?
BUILD
Outdated
| name = "openfeature_gherkin_spec_features", | ||
| srcs = glob(["spec/specification/assets/gherkin/evaluation.feature"]), |
There was a problem hiding this comment.
Out of curiosity, are those files introduced with git submodule? I think @oxddr mentioned that It would be better to have single way of defining dependencies, and manage them by bazel. I needed to do something really similar with flagd-schemas in cpp-sdk-contrib. Is it something worth considering?
There was a problem hiding this comment.
Yes, they are introduced with submodule.
There was a problem hiding this comment.
NIT: Since you moved handling this dependency to bazel, maybe we can remove the submodule?
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
BUILD
Outdated
| name = "openfeature_gherkin_spec_features", | ||
| srcs = glob(["spec/specification/assets/gherkin/evaluation.feature"]), |
There was a problem hiding this comment.
NIT: Since you moved handling this dependency to bazel, maybe we can remove the submodule?
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
This PR
Notes
We do this because cwt-cucumber is a lightweight, modern C++20 BDD testing framework for native C++ projects. We wanted to switch from cucumber-cpp because this framework was using a wire protocol and have Cucumber-Ruby connecting to a TCP port where the C++ implementation is listening.