/usr/share/gocode/src/github.com/smartystreets/goconvey/reporting/statistics.go is in golang-github-smartystreets-goconvey-dev 1.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | package reporting
import (
"fmt"
"github.com/smartystreets/goconvey/printing"
)
func (self *statistics) BeginStory(story *StoryReport) {}
func (self *statistics) Enter(scope *ScopeReport) {}
func (self *statistics) Report(report *AssertionResult) {
if !self.failing && report.Failure != "" {
self.failing = true
}
if !self.erroring && report.Error != nil {
self.erroring = true
}
if report.Skipped {
self.skipped += 1
} else {
self.total++
}
}
func (self *statistics) Exit() {}
func (self *statistics) EndStory() {
self.reportAssertions()
self.reportSkippedSections()
self.completeReport()
}
func (self *statistics) reportAssertions() {
self.decideColor()
self.out.Print("\n%d %s thus far", self.total, plural("assertion", self.total))
}
func (self *statistics) decideColor() {
if self.failing && !self.erroring {
fmt.Print(yellowColor)
} else if self.erroring {
fmt.Print(redColor)
} else {
fmt.Print(greenColor)
}
}
func (self *statistics) reportSkippedSections() {
if self.skipped > 0 {
fmt.Print(yellowColor)
self.out.Print(" (one or more sections skipped)")
self.skipped = 0
}
}
func (self *statistics) completeReport() {
fmt.Print(resetColor)
self.out.Print("\n")
self.out.Print("\n")
}
func NewStatisticsReporter(out *printing.Printer) *statistics {
self := statistics{}
self.out = out
return &self
}
type statistics struct {
out *printing.Printer
total int
failing bool
erroring bool
skipped int
}
func plural(word string, count int) string {
if count == 1 {
return word
}
return word + "s"
}
|