         return i if l.indexOf(p) isnt -1
     -1
 
-  registerSpecs: =>
+  registerSpecs: (results) =>
     set = @root.children
     set = set.sort(@randomSort) if @options.random
     for example in set
       @register example, @root.hasExclusiveExamples()
+
+    results
 
   register: (child, exclusiveOnly=false) ->
     if child.children?

    @seed = (@seed * 9301 + 49297) % 233280
    @seed / 233280.0

class spectacular.Runner

  @include spectacular.EventDispatcher


    return

  executeSpecs: (results) =>
    promise = new spectacular.Promise
    @nextExample promise, results
    promise

  nextExample: (defer, results) =>
    spectacular.nextTick =>
      if @stack.length is 0
        defer.resolve(results)
      else
        nextExample = @stack.shift()

        @env.currentExample = nextExample
        nextExample.run()
        .then =>
          @handleResult nextExample, results
          @nextExample defer, results
        .fail (reason) =>
          @handleResult nextExample, results
          @nextExample defer, results

  handleResult: (example, results) ->
    results.results.push example.result
    results.examples.push example

    switch example.result.state
      when 'pending' then results.pending.push example
      when 'skipped' then results.skipped.push example
      when 'errored' then results.errors.push example
      when 'failure' then results.failures.push example

    @dispatch new spectacular.Event 'result', example
    @env.currentExample = null

  notifyEnd: (results) =>
    @dispatch new spectacular.Event 'end', results
    results
