Permalink
Browse files

Ginkgo's parallel test runner streams output in realtime

  • Loading branch information...
1 parent 9019392 commit d6b13df1865f79525395c741a261633103dc1bb0 Onsi Fakhouri committed Dec 31, 2013
View
@@ -16,6 +16,7 @@ type example struct {
failure types.ExampleFailure
didInterceptFailure bool
interceptedFailure failureData
+ exampleIndex int
}
func newExample(subject exampleSubject) *example {
@@ -173,7 +174,7 @@ func (ex *example) processOutcomeAndFailure(containerIndex int, componentType ty
return
}
-func (ex *example) summary() *types.ExampleSummary {
+func (ex *example) summary(suiteID string) *types.ExampleSummary {
componentTexts := make([]string, len(ex.containers)+1)
componentCodeLocations := make([]types.CodeLocation, len(ex.containers)+1)
@@ -194,6 +195,8 @@ func (ex *example) summary() *types.ExampleSummary {
RunTime: ex.runTime,
Failure: ex.failure,
Measurements: ex.measurementsReport(),
+ SuiteID: suiteID,
+ ExampleIndex: ex.exampleIndex,
}
}
View
@@ -17,6 +17,7 @@ type exampleCollection struct {
exampleCountBeforeParallelization int
reporters []Reporter
startTime time.Time
+ suiteID string
runningExample *example
config config.GinkgoConfigType
}
@@ -28,9 +29,12 @@ func newExampleCollection(t GinkgoTestingT, description string, examples []*exam
examples: examples,
reporters: reporters,
config: config,
+ suiteID: types.GenerateRandomID(),
exampleCountBeforeParallelization: len(examples),
}
+ collection.enumerateAndAssignExampleIndices()
+
r := rand.New(rand.NewSource(config.RandomSeed))
if config.RandomizeAllSpecs {
collection.shuffle(r)
@@ -53,6 +57,12 @@ func newExampleCollection(t GinkgoTestingT, description string, examples []*exam
return collection
}
+func (collection *exampleCollection) enumerateAndAssignExampleIndices() {
+ for index, example := range collection.examples {
+ example.exampleIndex = index
+ }
+}
+
func (collection *exampleCollection) applyProgrammaticFocus() {
hasFocusedTests := false
for _, example := range collection.examples {
@@ -166,14 +176,14 @@ func (collection *exampleCollection) reportSuiteWillBegin() {
}
func (collection *exampleCollection) reportExampleWillRun(example *example) {
- summary := example.summary()
+ summary := example.summary(collection.suiteID)
for _, reporter := range collection.reporters {
reporter.ExampleWillRun(summary)
}
}
func (collection *exampleCollection) reportExampleDidComplete(example *example) {
- summary := example.summary()
+ summary := example.summary(collection.suiteID)
for _, reporter := range collection.reporters {
reporter.ExampleDidComplete(summary)
}
@@ -231,6 +241,7 @@ func (collection *exampleCollection) summary() *types.SuiteSummary {
return &types.SuiteSummary{
SuiteDescription: collection.description,
SuiteSucceeded: success,
+ SuiteID: collection.suiteID,
NumberOfExamplesBeforeParallelization: collection.exampleCountBeforeParallelization,
NumberOfTotalExamples: len(collection.examples),
Oops, something went wrong. Retry.

0 comments on commit d6b13df

Please sign in to comment.