1package contract 2 3import ( 4 "github.com/smartystreets/goconvey/convey/reporting" 5 "github.com/smartystreets/goconvey/web/server/messaging" 6) 7 8type Package struct { 9 Path string 10 Name string 11 Ignored bool 12 Disabled bool 13 BuildTags []string 14 TestArguments []string 15 Error error 16 Output string 17 Result *PackageResult 18 19 HasImportCycle bool 20} 21 22func NewPackage(folder *messaging.Folder, name string, hasImportCycle bool) *Package { 23 self := new(Package) 24 self.Path = folder.Path 25 self.Name = name 26 self.Result = NewPackageResult(self.Name) 27 self.Ignored = folder.Ignored 28 self.Disabled = folder.Disabled 29 self.BuildTags = folder.BuildTags 30 self.TestArguments = folder.TestArguments 31 self.HasImportCycle = hasImportCycle 32 return self 33} 34 35func (self *Package) Active() bool { 36 return !self.Disabled && !self.Ignored 37} 38 39func (self *Package) HasUsableResult() bool { 40 return self.Active() && (self.Error == nil || (self.Output != "")) 41} 42 43type CompleteOutput struct { 44 Packages []*PackageResult 45 Revision string 46 Paused bool 47} 48 49var ( // PackageResult.Outcome values: 50 Ignored = "ignored" 51 Disabled = "disabled" 52 Passed = "passed" 53 Failed = "failed" 54 Panicked = "panicked" 55 BuildFailure = "build failure" 56 NoTestFiles = "no test files" 57 NoTestFunctions = "no test functions" 58 NoGoFiles = "no go code" 59 60 TestRunAbortedUnexpectedly = "test run aborted unexpectedly" 61) 62 63type PackageResult struct { 64 PackageName string 65 Elapsed float64 66 Coverage float64 67 Outcome string 68 BuildOutput string 69 TestResults []TestResult 70} 71 72func NewPackageResult(packageName string) *PackageResult { 73 self := new(PackageResult) 74 self.PackageName = packageName 75 self.TestResults = []TestResult{} 76 self.Coverage = -1 77 return self 78} 79 80type TestResult struct { 81 TestName string 82 Elapsed float64 83 Passed bool 84 Skipped bool 85 File string 86 Line int 87 Message string 88 Error string 89 Stories []reporting.ScopeResult 90 91 RawLines []string `json:",omitempty"` 92} 93 94func NewTestResult(testName string) *TestResult { 95 self := new(TestResult) 96 self.Stories = []reporting.ScopeResult{} 97 self.RawLines = []string{} 98 self.TestName = testName 99 return self 100} 101