From 65ace21dc8d65ad081be3cc120ecfa9b8953e090 Mon Sep 17 00:00:00 2001 From: Ingo Oeser Date: Wed, 22 Jun 2016 23:43:07 +0200 Subject: [PATCH 1/2] use maximum step length of background and scenario in order to avoid panic in printStep (line 217). Fixes #42 --- fmt_pretty.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fmt_pretty.go b/fmt_pretty.go index ca6b94d..f0c30f0 100644 --- a/fmt_pretty.go +++ b/fmt_pretty.go @@ -256,6 +256,9 @@ func (f *pretty) printStepKind(res *stepResult) { // first step of scenario, print header and calculate comment position case f.scenario != nil && f.steps == len(f.scenario.Steps): f.commentPos = f.longestStep(f.scenario.Steps, f.length(f.scenario)) + if bgLen := f.longestStep(f.feature.Background.Steps, f.length(f.feature.Background)); bgLen > f.commentPos { + f.commentPos = bgLen + } text := s(f.indent) + bcl(f.scenario.Keyword+": ", white) + f.scenario.Name text += s(f.commentPos-f.length(f.scenario)+1) + f.line(f.scenario.Location) fmt.Println("\n" + text) From 7d11af4218d115c81ec2cdcba563f3f5d3cd9dd7 Mon Sep 17 00:00:00 2001 From: Ingo Oeser Date: Wed, 22 Jun 2016 23:48:29 +0200 Subject: [PATCH 2/2] use max step len of background & scenario outline in order to avoid panic in printStep (line 217) also for scenario outlines. Updates #42 --- fmt_pretty.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fmt_pretty.go b/fmt_pretty.go index f0c30f0..cad0736 100644 --- a/fmt_pretty.go +++ b/fmt_pretty.go @@ -269,6 +269,9 @@ func (f *pretty) printStepKind(res *stepResult) { // first step of outline scenario, print header and calculate comment position case f.outline != nil && f.steps == len(f.outline.Steps): f.commentPos = f.longestStep(f.outline.Steps, f.length(f.outline)) + if bgLen := f.longestStep(f.feature.Background.Steps, f.length(f.feature.Background)); bgLen > f.commentPos { + f.commentPos = bgLen + } text := s(f.indent) + bcl(f.outline.Keyword+": ", white) + f.outline.Name text += s(f.commentPos-f.length(f.outline)+1) + f.line(f.outline.Location) fmt.Println("\n" + text)