parser.go 716 B

1234567891011121314151617181920212223242526272829303132
  1. package parser
  2. import (
  3. "log"
  4. "github.com/smartystreets/goconvey/web/server/contract"
  5. )
  6. type Parser struct {
  7. parser func(*contract.PackageResult, string)
  8. }
  9. func (self *Parser) Parse(packages []*contract.Package) {
  10. for _, p := range packages {
  11. if p.Active() && p.HasUsableResult() {
  12. self.parser(p.Result, p.Output)
  13. } else if p.Ignored {
  14. p.Result.Outcome = contract.Ignored
  15. } else if p.Disabled {
  16. p.Result.Outcome = contract.Disabled
  17. } else {
  18. p.Result.Outcome = contract.TestRunAbortedUnexpectedly
  19. }
  20. log.Printf("[%s]: %s\n", p.Result.Outcome, p.Name)
  21. }
  22. }
  23. func NewParser(helper func(*contract.PackageResult, string)) *Parser {
  24. self := new(Parser)
  25. self.parser = helper
  26. return self
  27. }