@@ -30,6 +30,12 @@ var HEIGHT = 500;
30
30
// minimum satisfactory file size [in bytes]
31
31
var MIN_SIZE = 100 ;
32
32
33
+ // wait time between each test batch
34
+ var BATCH_WAIT = 500 ;
35
+
36
+ // number of tests in each test batch
37
+ var BATCH_SIZE = 5 ;
38
+
33
39
/**
34
40
* Image export test script.
35
41
*
@@ -65,21 +71,39 @@ if(mockList.length === 0) {
65
71
runInBatch ( mockList ) ;
66
72
67
73
function runInBatch ( mockList ) {
74
+ var running = 0 ;
75
+
68
76
test ( 'testing image export formats' , function ( t ) {
69
77
t . plan ( mockList . length * FORMATS . length ) ;
70
78
71
- // send all requests out at once
72
- mockList . forEach ( function ( mockName ) {
73
- FORMATS . forEach ( function ( format ) {
74
- testExport ( mockName , format , t ) ;
75
- } ) ;
76
- } ) ;
79
+ for ( var i = 0 ; i < mockList . length ; i ++ ) {
80
+ for ( var j = 0 ; j < FORMATS . length ; j ++ ) {
81
+ run ( mockList [ i ] , FORMATS [ j ] , t ) ;
82
+ }
83
+ }
77
84
} ) ;
85
+
86
+ function run ( mockName , format , t ) {
87
+ if ( running >= BATCH_SIZE ) {
88
+ setTimeout ( function ( ) {
89
+ run ( mockName , format , t ) ;
90
+ } , BATCH_WAIT ) ;
91
+ return ;
92
+ }
93
+ running ++ ;
94
+
95
+ // throttle the number of tests running concurrently
96
+
97
+ testExport ( mockName , format , function ( didExport , mockName , format ) {
98
+ running -- ;
99
+ t . ok ( didExport , mockName + ' should be properly exported as a ' + format ) ;
100
+ } ) ;
101
+ }
78
102
}
79
103
80
104
// The tests below determine whether the images are properly
81
105
// exported by (only) checking the file size of the generated images.
82
- function testExport ( mockName , format , t ) {
106
+ function testExport ( mockName , format , cb ) {
83
107
var specs = {
84
108
mockName : mockName ,
85
109
format : format ,
@@ -105,7 +129,7 @@ function testExport(mockName, format, t) {
105
129
didExport = stats . size > MIN_SIZE ;
106
130
}
107
131
108
- t . ok ( didExport , mockName + ' should be properly exported as a ' + format ) ;
132
+ cb ( didExport , mockName , format ) ;
109
133
}
110
134
111
135
request ( requestOpts )
0 commit comments