File tree 2 files changed +43
-8
lines changed 2 files changed +43
-8
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ function Results () {
24
24
this . _stream = through ( ) ;
25
25
this . tests = [ ] ;
26
26
this . _only = null ;
27
+ this . _isRunning = false ;
27
28
}
28
29
29
30
Results . prototype . createStream = function ( opts ) {
@@ -65,14 +66,17 @@ Results.prototype.createStream = function (opts) {
65
66
self . _stream . pipe ( output ) ;
66
67
}
67
68
68
- nextTick ( function next ( ) {
69
- var t ;
70
- while ( t = getNextTest ( self ) ) {
71
- t . run ( ) ;
72
- if ( ! t . ended ) return t . once ( 'end' , function ( ) { nextTick ( next ) ; } ) ;
73
- }
74
- self . emit ( 'done' ) ;
75
- } ) ;
69
+ if ( ! this . _isRunning ) {
70
+ this . _isRunning = true ;
71
+ nextTick ( function next ( ) {
72
+ var t ;
73
+ while ( t = getNextTest ( self ) ) {
74
+ t . run ( ) ;
75
+ if ( ! t . ended ) return t . once ( 'end' , function ( ) { nextTick ( next ) ; } ) ;
76
+ }
77
+ self . emit ( 'done' ) ;
78
+ } ) ;
79
+ }
76
80
77
81
return output ;
78
82
} ;
Original file line number Diff line number Diff line change
1
+ var tape = require ( '../' ) ;
2
+
3
+ tape . test ( 'createMultipleStreams' , function ( tt ) {
4
+ tt . plan ( 2 ) ;
5
+
6
+ var th = tape . createHarness ( ) ;
7
+ th . createStream ( )
8
+ th . createStream ( )
9
+
10
+ var testOneComplete = false ;
11
+
12
+ th ( 'test one' , function ( tht ) {
13
+ tht . plan ( 1 ) ;
14
+ setTimeout ( function ( ) {
15
+ tht . pass ( ) ;
16
+ testOneComplete = true ;
17
+ } , 100 ) ;
18
+ } ) ;
19
+
20
+ th ( 'test two' , function ( tht ) {
21
+ tht . ok ( testOneComplete , 'test 1 completed before test 2' ) ;
22
+ tht . end ( ) ;
23
+ } ) ;
24
+
25
+ th . onFinish ( function ( ) {
26
+ tt . equal ( th . _results . count , 2 , "harness test ran" ) ;
27
+ tt . equal ( th . _results . fail , 0 , "harness test didn't fail" ) ;
28
+ } ) ;
29
+ } ) ;
30
+
31
+
You can’t perform that action at this time.
0 commit comments