@@ -3,7 +3,6 @@ import createTestCafe, { ClientFunction } from 'testcafe';
33import * as fs from 'fs' ;
44import * as process from 'process' ;
55import parseArgs from 'minimist' ;
6- import { globSync } from 'glob' ;
76import { DEFAULT_BROWSER_SIZE } from './helpers/const' ;
87import {
98 addShadowRootTree ,
@@ -119,18 +118,6 @@ function getArgs(): ParsedArgs {
119118 } ) as ParsedArgs ;
120119}
121120
122- const split = < T > ( array : T [ ] , chunkCount : number ) : T [ ] [ ] => {
123- const fixturesInChunkCount = Math . ceil ( array . length / chunkCount ) ;
124- const arr = [ ...array ] ;
125- const res : T [ ] [ ] = [ ] ;
126-
127- while ( arr . length ) {
128- res . push ( arr . splice ( 0 , fixturesInChunkCount ) ) ;
129- }
130-
131- return res ;
132- } ;
133-
134121async function main ( ) {
135122 let testCafe : Awaited < ReturnType < typeof createTestCafe > > | null = null ;
136123
@@ -175,34 +162,26 @@ async function main() {
175162 } ,
176163 } ) ;
177164
178- runner . concurrency ( filterByFailedTests ? 1 : ( args . concurrency || 4 ) ) ;
165+ runner . concurrency ( filterByFailedTests ? 1 : ( args . concurrency || 5 ) ) ;
179166
180167 const filters : FilterFunction [ ] = [ ] ;
181168
182- if ( indices ) {
169+ if ( indices && ! filterByFailedTests ) {
183170 const [ current , total ] = indices . split ( / _ | o f | \\ | \/ / ig) . map ( ( x ) => + x ) ;
184- const fixtures = globSync ( [ `./tests/${ componentFolder } /*.ts` ] ) ;
185- const fixtureChunks = split ( fixtures , total ) ;
186- const targetFixtureChunk = fixtureChunks [ current - 1 ] ?? [ ] ;
187- const targetFixtureChunkSet = new Set ( targetFixtureChunk ) ;
188171
189- if ( ! filterByFailedTests ) {
190- /* eslint-disable no-console */
191- console . info ( ' === test run config ===' ) ;
192- console . info ( ` > indices: current = ${ current } | total = ${ total } ` ) ;
193- console . info ( ' > glob: ' , [ `./tests/${ componentFolder } /*.ts` ] ) ;
194- console . info ( ' > all fixtures: ' , fixtureChunks ) ;
195- console . info ( ' > fixtures: ' , targetFixtureChunk , '\n' ) ;
196- /* eslint-enable no-console */
197- }
172+ /* eslint-disable no-console */
173+ console . info ( ' === test run config ===' ) ;
174+ console . info ( ` > indices: current = ${ current } | total = ${ total } ` ) ;
175+ console . info ( ' > strategy: round-robin by test (not by file)' ) ;
176+ console . info ( ' > glob: ' , [ `./tests/${ componentFolder } /*.ts` ] ) ;
177+ console . info ( '\n' ) ;
178+ /* eslint-enable no-console */
198179
199- filters . push ( (
200- _testName : string ,
201- _fixtureName : string ,
202- fixturePath : string ,
203- ) => {
204- const testPath = fixturePath . split ( '/testcafe-devextreme/' ) [ 1 ] ;
205- return targetFixtureChunkSet . has ( testPath ) ;
180+ let globalTestIndex = 0 ;
181+ filters . push ( ( ) => {
182+ globalTestIndex += 1 ;
183+ const testChunk = ( ( globalTestIndex - 1 ) % total ) + 1 ;
184+ return testChunk === current ;
206185 } ) ;
207186 }
208187
@@ -211,6 +190,16 @@ async function main() {
211190 }
212191
213192 if ( filterByFailedTests && failedTests . size > 0 ) {
193+ /* eslint-disable no-console */
194+ console . info ( '=' . repeat ( 60 ) ) ;
195+ console . info ( 'RETRY FILTER CONFIGURATION' ) ;
196+ console . info ( `Failed tests to retry: ${ failedTests . size } ` ) ;
197+ console . info ( 'Test names:' ) ;
198+ failedTests . forEach ( ( name ) => console . info ( ` - ${ name } ` ) ) ;
199+ console . info ( '=' . repeat ( 60 ) ) ;
200+ console . info ( '\n' ) ;
201+ /* eslint-enable no-console */
202+
214203 filters . push ( ( name : string ) => failedTests . has ( name ) ) ;
215204 }
216205
@@ -328,6 +317,7 @@ async function main() {
328317
329318 isRetryRun = true ;
330319 const retryRunner = createRunner ( true ) ;
320+
331321 failedCount = await retry (
332322 ( ) => retryRunner . run ( runOptions ) ,
333323 LAUNCH_RETRY_ATTEMPTS ,
0 commit comments