Skip to content

Commit 2c35b3d

Browse files
committed
Fix goconvey service for newer Go versions.
This is a bit of a temporary patch; I think the time has come to completely rebuild `goconvey` to rely on `go test -json` as the next thing to do.
1 parent 485adb0 commit 2c35b3d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

web/server/parser/packageParser.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,15 @@ func (self *outputParser) recordTestingOutcome(outcome string) {
138138
self.result.PackageName = strings.TrimSpace(fields[1])
139139
self.result.Elapsed = parseDurationInSeconds(fields[2], 3)
140140
}
141+
142+
var coverageStatementRE = regexp.MustCompile(`coverage: (\d+\.\d)% of statements`)
143+
141144
func (self *outputParser) recordCoverageSummary(summary string) {
142-
start := len("coverage: ")
143-
end := strings.Index(summary, "%")
144-
value := summary[start:end]
145-
parsed, err := strconv.ParseFloat(value, 64)
145+
matches := coverageStatementRE.FindStringSubmatch(summary)
146+
if len(matches) == 0 {
147+
panic("recordCoverageSummary")
148+
}
149+
parsed, err := strconv.ParseFloat(matches[1], 64)
146150
if err != nil {
147151
self.result.Coverage = -1
148152
} else {

web/server/parser/rules.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ func packagePassed(line string) bool {
4141
return strings.HasPrefix(line, "ok \t")
4242
}
4343
func isCoverageSummary(line string) bool {
44-
return strings.HasPrefix(line, "coverage: ") && strings.Contains(line, "% of statements")
44+
return strings.Contains(line, "coverage: ") && strings.Contains(line, "% of statements")
4545
}

web/server/system/shell.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,4 @@ func (this Command) Execute() Command {
158158
const goconveyDSLImport = "github.com/smartystreets/goconvey/convey " // note the trailing space: we don't want to target packages nested in the /convey package.
159159
const gopathProblem = "Please run goconvey from within $GOPATH/src (also, symlinks might be problematic). Output and Error: "
160160

161-
var coverageStatementRE = regexp.MustCompile(`(?m)^coverage: \d+\.\d% of statements(.*)$|^panic: test timed out after `)
161+
var coverageStatementRE = regexp.MustCompile(`(?m)coverage: \d+\.\d% of statements(.*)$|^panic: test timed out after `)

0 commit comments

Comments
 (0)