feat: expose scenario information in scenario and step hooks#369
Conversation
✅
|
| Descriptor | Linter | Files | Fixed | Errors | Warnings | Elapsed time |
|---|---|---|---|---|---|---|
| ✅ ACTION | actionlint | 6 | 0 | 0 | 0.27s | |
| ✅ ACTION | zizmor | 6 | 0 | 0 | 0 | 3.46s |
| ✅ CPP | clang-format | 239 | 1 | 0 | 0 | 1.86s |
| ✅ DOCKERFILE | hadolint | 1 | 0 | 0 | 0.04s | |
| markdownlint | 7 | 4 | 20 | 0 | 1.02s | |
| ✅ MARKDOWN | markdown-table-formatter | 7 | 4 | 0 | 0 | 0.26s |
| ✅ REPOSITORY | betterleaks | yes | no | no | 0.88s | |
| ✅ REPOSITORY | git_diff | yes | no | no | 0.03s | |
| ✅ REPOSITORY | grype | yes | no | no | 47.89s | |
| ✅ REPOSITORY | ls-lint | yes | no | no | 0.01s | |
| ✅ REPOSITORY | secretlint | yes | no | no | 4.05s | |
| ✅ REPOSITORY | syft | yes | no | no | 2.43s | |
| ✅ REPOSITORY | trivy | yes | no | no | 12.06s | |
| ✅ REPOSITORY | trivy-sbom | yes | no | no | 0.17s | |
| ✅ REPOSITORY | trufflehog | yes | no | no | 5.43s | |
| lychee | 86 | 1 | 0 | 12.24s | ||
| ✅ YAML | prettier | 10 | 0 | 0 | 0 | 0.57s |
| ✅ YAML | v8r | 10 | 0 | 0 | 8.1s | |
| ✅ YAML | yamllint | 10 | 0 | 0 | 0.48s |
Detailed Issues
⚠️ SPELL / lychee - 1 error
📝 Summary
---------------------
🔍 Total..........178
🔗 Unique.........172
✅ Successful.....177
⏳ Timeouts.........0
🔀 Redirected......81
👻 Excluded.........0
❓ Unknown..........0
🚫 Errors...........1
⛔ Unsupported......1
Errors in CONTRIBUTING.md
[404] https://github.com/yourname/amp-cucumber-cpp-runner.git (at 41:36) | Rejected status code: 404 Not Found | Followed 1 redirect. Redirects: https://github.com/yourname/amp-cucumber-cpp-runner.git --[301]--> https://github.com/yourname/amp-cucumber-cpp-runner
Hint: Followed 81 redirects. You might want to consider replacing redirecting URLs with the resolved URLs. Use verbose mode (`-v`/`-vv`) to see redirection details.
Hint: You can configure accepted/rejected response codes with `-a` or `--accept`
⚠️ MARKDOWN / markdownlint - 20 errors
CHANGELOG.md:31 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Features"]
CHANGELOG.md:38 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Bug Fixes"]
CHANGELOG.md:44 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Chores"]
CHANGELOG.md:51 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Features"]
CHANGELOG.md:58 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Chores"]
CHANGELOG.md:66 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "⚠ BREAKING CHANGES"]
CHANGELOG.md:70 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Features"]
CHANGELOG.md:79 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Features"]
CHANGELOG.md:85 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Chores"]
CHANGELOG.md:93 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "⚠ BREAKING CHANGES"]
CHANGELOG.md:97 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Features"]
CHANGELOG.md:102 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Bug Fixes"]
CHANGELOG.md:111 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Features"]
CHANGELOG.md:122 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Chores"]
CHANGELOG.md:130 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "⚠ BREAKING CHANGES"]
CHANGELOG.md:134 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Features"]
CHANGELOG.md:159 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Bug Fixes"]
CHANGELOG.md:166 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Chores"]
cmake/WindowsToolchainFilesProvidedBy.md:1 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "<https://github.com/MarkSchofi..."]
README.md:132 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
Notices
📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)
See detailed reports in MegaLinter artifacts
Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)
- Documentation: Custom Flavors
- Command:
npx mega-linter-runner@9.6.0 --custom-flavor-setup --custom-flavor-linters ACTION_ACTIONLINT,ACTION_ZIZMOR,CPP_CLANG_FORMAT,DOCKERFILE_HADOLINT,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_GIT_DIFF,REPOSITORY_BETTERLEAKS,REPOSITORY_GRYPE,REPOSITORY_LS_LINT,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,SPELL_LYCHEE,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

Show us your support by starring ⭐ the repository
There was a problem hiding this comment.
Pull request overview
This PR extends the hook execution context so scenario/step hooks can access basic scenario metadata (name + tags) via a new ScenarioInfo type, and wires that information through the runtime and hook factory pathway. It also adds early parse-error reporting during feature collection and includes an acceptance test for the scenario-info exposure.
Changes:
- Introduce
util::ScenarioInfoand pass it (optionally) throughutil::HookFactoryinto hook implementations. - Add new engine hook implementations (
HookImpl/GlobalHookImpl) to support scenario info access in applicable hooks. - Add parse error collection/printing in
RunCucumberand an acceptance test covering scenario info access from scenario and step hooks.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| cucumber_cpp/Steps.hpp | Exposes StepBase by including the engine step header. |
| cucumber_cpp/library/util/ScenarioInfo.hpp | Adds a new struct carrying scenario name and tags. |
| cucumber_cpp/library/util/HookFactory.hpp | Extends hook factory signature to accept optional scenario info. |
| cucumber_cpp/library/support/DefinitionRegistration.cpp | Removes standalone-only debug printing and uses try_emplace. |
| cucumber_cpp/library/runtime/Worker.cpp | Updates global/feature hook invocation to pass std::nullopt scenario info. |
| cucumber_cpp/library/runtime/TestCaseRunner.cpp | Adds scenario info creation and passes it into scenario/step hook invocations. |
| cucumber_cpp/library/Hooks.hpp | Updates hook macros to select the appropriate engine base implementation. |
| cucumber_cpp/library/engine/Hook.hpp | Adds HookImpl/GlobalHookImpl types and ScenarioInfo() accessor on HookImpl. |
| cucumber_cpp/library/engine/Hook.cpp | Implements the new hook types. |
| cucumber_cpp/library/api/RunCucumber.cpp | Adds parse error listener and prints parse errors before running. |
| cucumber_cpp/acceptance_test/test.bats | Adds an acceptance test invocation for the new scenario info behavior. |
| cucumber_cpp/acceptance_test/steps/Steps.cpp | Adds step assertions validating stored scenario info (name/tags). |
| cucumber_cpp/acceptance_test/hooks/Hooks.cpp | Adds hooks that read ScenarioInfo() and optionally store it in context. |
| cucumber_cpp/acceptance_test/features/test_expose_scenario_info.feature | Adds a feature validating scenario info availability/unavailability in hooks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|



This PR extends the hook execution context so scenario/step hooks can access basic scenario metadata (name + tags) via a new ScenarioInfo type, and wires that information through the runtime and hook factory pathway. It also adds early parse-error reporting during feature collection and includes an acceptance test for the scenario-info exposure.