@@ -724,7 +724,6 @@ Runner.prototype.runSuite = function(suite, fn) {
724724 var i = 0 ;
725725 var self = this ;
726726 var total = this . grepTotal ( suite ) ;
727- var afterAllHookCalled = false ;
728727
729728 debug ( 'run suite %s' , suite . fullTitle ( ) ) ;
730729
@@ -772,21 +771,13 @@ Runner.prototype.runSuite = function(suite, fn) {
772771 self . suite = suite ;
773772 self . nextSuite = next ;
774773
775- if ( afterAllHookCalled ) {
776- fn ( errSuite ) ;
777- } else {
778- // mark that the afterAll block has been called once
779- // and so can be skipped if there is an error in it.
780- afterAllHookCalled = true ;
781-
782- // remove reference to test
783- delete self . test ;
774+ // remove reference to test
775+ delete self . test ;
784776
785- self . hook ( HOOK_TYPE_AFTER_ALL , function ( ) {
786- self . emit ( constants . EVENT_SUITE_END , suite ) ;
787- fn ( errSuite ) ;
788- } ) ;
789- }
777+ self . hook ( HOOK_TYPE_AFTER_ALL , function ( ) {
778+ self . emit ( constants . EVENT_SUITE_END , suite ) ;
779+ fn ( errSuite ) ;
780+ } ) ;
790781 }
791782
792783 this . nextSuite = next ;
@@ -861,36 +852,13 @@ Runner.prototype.uncaught = function(err) {
861852
862853 // we cannot recover gracefully if a Runnable has already passed
863854 // then fails asynchronously
864- var alreadyPassed = runnable . isPassed ( ) ;
865- // this will change the state to "failed" regardless of the current value
866- this . fail ( runnable , err ) ;
867- if ( ! alreadyPassed ) {
868- // recover from test
869- if ( runnable . type === constants . EVENT_TEST_BEGIN ) {
870- this . emit ( constants . EVENT_TEST_END , runnable ) ;
871- this . hookUp ( HOOK_TYPE_AFTER_EACH , this . next ) ;
872- return ;
873- }
855+ if ( runnable . isPassed ( ) ) {
856+ this . fail ( runnable , err ) ;
857+ this . abort ( ) ;
858+ } else {
874859 debug ( runnable ) ;
875-
876- // recover from hooks
877- var errSuite = this . suite ;
878-
879- // XXX how about a less awful way to determine this?
880- // if hook failure is in afterEach block
881- if ( runnable . fullTitle ( ) . indexOf ( 'after each' ) > - 1 ) {
882- return this . hookErr ( err , errSuite , true ) ;
883- }
884- // if hook failure is in beforeEach block
885- if ( runnable . fullTitle ( ) . indexOf ( 'before each' ) > - 1 ) {
886- return this . hookErr ( err , errSuite , false ) ;
887- }
888- // if hook failure is in after or before blocks
889- return this . nextSuite ( errSuite ) ;
860+ return runnable . callback ( err ) ;
890861 }
891-
892- // bail
893- this . abort ( ) ;
894862} ;
895863
896864/**
0 commit comments