What version of godog are you using?
What version of Go are you using?
What did you do?
Given a feature file like the following:
Feature: simple feature
simple feature description
Rule: simple rule
Example: simple example
Running godog will panic:
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0x11cc0c6]
goroutine 34 [running]:
github.com/cucumber/godog/internal/formatters.(*Pretty).printStep(0xc0002020d0, 0xc000250360, 0xc000208680)
/Users/michaelsauter/go/pkg/mod/github.com/cucumber/godog@v0.12.2/internal/formatters/fmt_pretty.go:384 +0xf26
Additional context
I've looked a bit into the source code and added the following test to pretty.feature:
Scenario: Support of Feature Plus Rule Node
Given a feature "features/simple.feature" file:
"""
Feature: simple feature
simple feature description
Rule: simple rule
Scenario: simple scenario
simple scenario description
"""
When I run feature suite with formatter "pretty"
Then the rendered output will be as follows:
"""
Feature: simple feature
simple feature description
Rule: simple rule # features/simple.feature:3
Scenario: simple scenario # features/simple.feature:4
1 scenarios (1 undefined)
No steps
0s
"""
This lead me to apply the following fix in fmt_pretty.go:
func (f *Pretty) scenarioLengths(pickle *messages.Pickle) (scenarioHeaderLength int, maxLength int) {
feature := f.Storage.MustGetFeature(pickle.Uri)
astRule := feature.FindRule(pickle.AstNodeIds[0])
astScenario := feature.FindScenario(pickle.AstNodeIds[0])
astBackground := feature.FindBackground(pickle.AstNodeIds[0])
if astScenario != nil {
scenarioHeaderLength = f.lengthPickle(astScenario.Keyword, astScenario.Name)
maxLength = f.longestStep(astScenario.Steps, scenarioHeaderLength)
}
if astBackground != nil {
maxLength = f.longestStep(astBackground.Steps, maxLength)
}
if astRule != nil {
for _, rc := range astRule.Children {
if rc.Scenario != nil {
maxLength = f.longestStep(rc.Scenario.Steps, maxLength)
} else if rc.Background != nil {
maxLength = f.longestStep(rc.Scenario.Steps, maxLength)
}
}
}
return scenarioHeaderLength, maxLength
}
... but there are many more issues in the pretty formatter, plus I realized all the other formatters would need to be fixed, too. Seems like supporting rules will be quite the effort. Are there plans to do this already?
What version of godog are you using?
What version of Go are you using?
What did you do?
Given a feature file like the following:
Running
godogwill panic:Additional context
I've looked a bit into the source code and added the following test to
pretty.feature:This lead me to apply the following fix in
fmt_pretty.go:... but there are many more issues in the pretty formatter, plus I realized all the other formatters would need to be fixed, too. Seems like supporting rules will be quite the effort. Are there plans to do this already?