Skip to content

Commit

Permalink
Ginkgo's parallel test runner streams output in realtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Onsi Fakhouri committed Jan 10, 2014
1 parent 9019392 commit d6b13df
Show file tree
Hide file tree
Showing 32 changed files with 1,919 additions and 163 deletions.
5 changes: 4 additions & 1 deletion example.go
Expand Up @@ -16,6 +16,7 @@ type example struct {
failure types.ExampleFailure
didInterceptFailure bool
interceptedFailure failureData
exampleIndex int
}

func newExample(subject exampleSubject) *example {
Expand Down Expand Up @@ -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)

Expand All @@ -194,6 +195,8 @@ func (ex *example) summary() *types.ExampleSummary {
RunTime: ex.runTime,
Failure: ex.failure,
Measurements: ex.measurementsReport(),
SuiteID: suiteID,
ExampleIndex: ex.exampleIndex,
}
}

Expand Down
15 changes: 13 additions & 2 deletions example_collection.go
Expand Up @@ -17,6 +17,7 @@ type exampleCollection struct {
exampleCountBeforeParallelization int
reporters []Reporter
startTime time.Time
suiteID string
runningExample *example
config config.GinkgoConfigType
}
Expand All @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit d6b13df

Please sign in to comment.