Skip to content

feat: expose scenario information in scenario and step hooks#369

Merged
Daan Timmer (daantimmer) merged 5 commits into
mainfrom
feature/expose-scenario-information-in-scenario-and-step-hooks
Jul 13, 2026
Merged

feat: expose scenario information in scenario and step hooks#369
Daan Timmer (daantimmer) merged 5 commits into
mainfrom
feature/expose-scenario-information-in-scenario-and-step-hooks

Conversation

@daantimmer

@daantimmer Daan Timmer (daantimmer) commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

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.

Copilot AI review requested due to automatic review settings July 13, 2026 07:30
@daantimmer Daan Timmer (daantimmer) requested review from a team as code owners July 13, 2026 07:30
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

⚠️MegaLinter analysis: Success with warnings

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
⚠️ MARKDOWN 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
⚠️ SPELL 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

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

Copilot AI left a comment

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.

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::ScenarioInfo and pass it (optionally) through util::HookFactory into hook implementations.
  • Add new engine hook implementations (HookImpl / GlobalHookImpl) to support scenario info access in applicable hooks.
  • Add parse error collection/printing in RunCucumber and 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.

Comment thread cucumber_cpp/library/runtime/TestCaseRunner.cpp
Comment thread cucumber_cpp/library/Hooks.hpp Outdated
Comment thread cucumber_cpp/acceptance_test/features/test_expose_scenario_info.feature Outdated
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

Test Results

31 tests  +2   31 ✅ +2   16s ⏱️ +3s
 1 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit f9de21b. ± Comparison against base commit 9c930ac.

♻️ This comment has been updated with latest results.

Copilot AI review requested due to automatic review settings July 13, 2026 07:51

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Comment thread cucumber_cpp/library/engine/Hook.cpp
Comment thread cucumber_cpp/library/util/HookFactory.hpp
Comment thread cucumber_cpp/library/api/RunCucumber.cpp
Copilot AI review requested due to automatic review settings July 13, 2026 08:08

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Comment thread cucumber_cpp/library/engine/Hook.cpp
Copilot AI review requested due to automatic review settings July 13, 2026 10:04

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Comment thread cucumber_cpp/library/runtime/TestCaseRunner.cpp
Comment thread cucumber_cpp/library/engine/Hook.cpp
Comment thread cucumber_cpp/acceptance_test/test.bats
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 13, 2026 10:10

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Comment thread cucumber_cpp/library/api/RunCucumber.cpp
Comment thread cucumber_cpp/library/engine/Hook.cpp
@sonarqubecloud

Copy link
Copy Markdown

@daantimmer Daan Timmer (daantimmer) merged commit fae5994 into main Jul 13, 2026
25 checks passed
@daantimmer Daan Timmer (daantimmer) deleted the feature/expose-scenario-information-in-scenario-and-step-hooks branch July 13, 2026 10:39
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.

3 participants