Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not discard context from substeps #488

Merged
merged 2 commits into from
Jul 25, 2022

Conversation

wichert
Copy link
Contributor

@wichert wichert commented Jul 22, 2022

The context from a substep was accidentally discarded because the ctx variable was shadowed.

This fixes #487

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

This text was originally generated from a template, then edited by hand. You can modify the template here.

@codecov
Copy link

codecov bot commented Jul 22, 2022

Codecov Report

Merging #488 (4717fa8) into main (5e176da) will increase coverage by 0.00%.
The diff coverage is 50.00%.

@@           Coverage Diff           @@
##             main     #488   +/-   ##
=======================================
  Coverage   81.72%   81.72%           
=======================================
  Files          27       27           
  Lines        2232     2233    +1     
=======================================
+ Hits         1824     1825    +1     
  Misses        312      312           
  Partials       96       96           
Impacted Files Coverage Δ
suite.go 87.61% <50.00%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5e176da...4717fa8. Read the comment docs.

Copy link
Member

@vearutop vearutop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

CHANGELOG.md Outdated
@@ -12,6 +12,7 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
- README example is updated with `context.Context` and `go test` usage. ([477](https://github.com/cucumber/godog/pull/477) - [vearutop](https://github.com/vearutop))

### Fixed
- Fixed a bug which would ignore the context returned from a substep.([488](https://github.com/cucumber/godog/pull/480) - [wichert](https://github.com/wichert))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Fixed a bug which would ignore the context returned from a substep.([488](https://github.com/cucumber/godog/pull/480) - [wichert](https://github.com/wichert))
- Fixed a bug which would ignore the context returned from a substep.([488](https://github.com/cucumber/godog/pull/488) - [wichert](https://github.com/wichert))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed!

@wichert wichert force-pushed the fix-substep-context branch 2 times, most recently from 887fd69 to 8615b6a Compare July 22, 2022 12:25
@wichert
Copy link
Contributor Author

wichert commented Jul 22, 2022

I'm afraid I don't understand why the tests are failing. The errors look unrelated to my changes?

@dumpsterfireproject
Copy link
Contributor

I had a similar experience with my commit. In run_test.go, Test_AllFeaturesRun and Test_AllFeaturesRunAsSubtests run all the .features in the features directory with the progress formatter. So when new .features are added to that directory, it changes the expected output of the progress formatter. The number of dots output by the progress formatter as well as the scenario and step counts output will all increase with the new .feature added to that directory. I updated those tests to reflect the additional steps & scenarios on my PR. But we should probably log an issue to change the Options.Paths used in those two tests to only use .features in that directory that the test expects instead of just running them all, so the test doesn't break every time a new .feature is added.

@vearutop
Copy link
Member

Yes, that's true. In order to fix tests you need to update expected report (which is now having a few more steps covered).

    run_test.go:483: 
        	Error Trace:	run_test.go:483
        	Error:      	Not equal: 
        	            	expected: "...................................................................... 70\n...................................................................... 140\n...................................................................... 210\n...................................................................... 280\n.................................................                      329\n\n\n86 scenarios (86 passed)\n329 steps (329 passed)\n0s\n"
        	            	actual  : "...................................................................... 70\n...................................................................... 140\n...................................................................... 210\n...................................................................... 280\n.......................................................                335\n\n\n88 scenarios (88 passed)\n335 steps (335 passed)\n0s\n"
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -4,7 +4,7 @@
        	            	 ...................................................................... 280
        	            	-.................................................                      329
        	            	+.......................................................                335
        	            	-86 scenarios (86 passed)
        	            	-329 steps (329 passed)
        	            	+88 scenarios (88 passed)
        	            	+335 steps (335 passed)
        	            	 0s

@wichert
Copy link
Contributor Author

wichert commented Jul 25, 2022

Thanks, that solved the test errors!

FWIW when using go 1.18 the tests are failing because the source filename is no longer available, resulting in many instances of this:

 Scenario: load features within path    # features/load.feature:6
-Given a feature path "features"      # suite_context_test.go:0 -> *godogFeaturesScenario
-When I parse features                # suite_context_test.go:0 -> *godogFeaturesScenario
-Then I should have 13 feature files: # suite_context_test.go:0 -> *godogFeaturesScenario
+Given a feature path "features"      # <autogenerated>:1 -> *godogFeaturesScenario
+When I parse features                # <autogenerated>:1 -> *godogFeaturesScenario
+Then I should have 13 feature files: # <autogenerated>:1 -> *godogFeaturesScenario

It looks like the name of the source files is lost, and replaced with <autogenerated>

@vearutop
Copy link
Member

Yes, go1.18 has a technically breaking change wrt closure introspection (#466, golang/go#51774), hopefully it will be fixed in 1.19 or 1.20.

On our side I think we should also upgrade function resolver to not show autogenerated as it is useless.

@vearutop vearutop merged commit b2672bb into cucumber:main Jul 25, 2022
@aslakhellesoy
Copy link
Contributor

Hi @wichert,

Thanks for your making your first contribution to Cucumber, and welcome to the Cucumber committers team! You can now push directly to this repo and all other repos under the cucumber organization! 🍾

In return for this generous offer we hope you will:

  • ✅ Continue to use branches and pull requests. When someone on the core team approves a pull request (yours or someone else's), you're welcome to merge it yourself.
  • 💚 Commit to setting a good example by following and upholding our code of conduct in your interactions with other collaborators and users.
  • 💬 Join the community Slack channel to meet the rest of the team and make yourself at home.
  • ℹ️ Don't feel obliged to help, just do what you can if you have the time and the energy.
  • 🙋 Ask if you need anything. We're looking for feedback about how to make the project more welcoming, so please tell us!

On behalf of the Cucumber core team,
Aslak Hellesøy
Creator of Cucumber

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.

Context from substeps is lost
4 participants