File tree Expand file tree Collapse file tree 4 files changed +48
-1
lines changed Expand file tree Collapse file tree 4 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -728,6 +728,7 @@ export function only( testName, callback ) {
728
728
729
729
// Put a hold on processing and return a function that will release it.
730
730
export function internalStop ( test ) {
731
+ let released = false ;
731
732
test . semaphore += 1 ;
732
733
config . blocking = true ;
733
734
@@ -748,13 +749,13 @@ export function internalStop( test ) {
748
749
`Test took longer than ${ timeoutDuration } ms; test timed out.` ,
749
750
sourceFromStacktrace ( 2 )
750
751
) ;
752
+ released = true ;
751
753
internalRecover ( test ) ;
752
754
} , timeoutDuration ) ;
753
755
}
754
756
755
757
}
756
758
757
- let released = false ;
758
759
return function resume ( ) {
759
760
if ( released ) {
760
761
return ;
Original file line number Diff line number Diff line change @@ -164,6 +164,26 @@ not ok 1 global failure
164
164
# skip 0
165
165
# todo 0
166
166
# fail 1
167
+ ` ,
168
+
169
+ "qunit timeout" :
170
+ `TAP version 13
171
+ not ok 1 timeout > first
172
+ ---
173
+ message: "Test took longer than 10ms; test timed out."
174
+ severity: failed
175
+ actual: null
176
+ expected: undefined
177
+ stack: at ontimeout (.*)
178
+ at tryOnTimeout (.*)
179
+ (.*)\\s*(.*)?
180
+ ...
181
+ ok 2 timeout > second
182
+ 1..2
183
+ # pass 1
184
+ # skip 0
185
+ # todo 0
186
+ # fail 1
167
187
` ,
168
188
169
189
// in node 8, the stack trace includes 'at <anonymous>. But not in node 6 or 10.
Original file line number Diff line number Diff line change
1
+ QUnit . module ( "timeout" , function ( ) {
2
+ QUnit . test ( "first" , function ( assert ) {
3
+ assert . timeout ( 10 ) ;
4
+
5
+ return new Promise ( resolve => setTimeout ( resolve , 20 ) ) ;
6
+ } ) ;
7
+
8
+ QUnit . test ( "second" , function ( assert ) {
9
+ return new Promise ( resolve => setTimeout ( resolve , 20 ) )
10
+ . then ( ( ) => {
11
+ assert . ok ( true , "This promise resolved" ) ;
12
+ } ) ;
13
+ } ) ;
14
+ } ) ;
Original file line number Diff line number Diff line change @@ -137,6 +137,18 @@ QUnit.module( "CLI Main", function() {
137
137
}
138
138
} ) ) ;
139
139
140
+ QUnit . test ( "timeouts correctly recover" , co . wrap ( function * ( assert ) {
141
+ const command = "qunit timeout" ;
142
+ try {
143
+ yield execute ( command ) ;
144
+ } catch ( e ) {
145
+ assert . equal ( e . code , 1 ) ;
146
+ assert . equal ( e . stderr , "" ) ;
147
+ const re = new RegExp ( expectedOutput [ command ] ) ;
148
+ assert . equal ( re . test ( e . stdout ) , true ) ;
149
+ }
150
+ } ) ) ;
151
+
140
152
if ( semver . gte ( process . versions . node , "9.0.0" ) ) {
141
153
QUnit . test ( "callbacks and hooks from modules are properly released for garbage collection" , co . wrap ( function * ( assert ) {
142
154
const command = "node --expose-gc --allow-natives-syntax ../../../bin/qunit.js memory-leak/*.js" ;
You can’t perform that action at this time.
0 commit comments