File tree Expand file tree Collapse file tree 10 files changed +108
-43
lines changed Expand file tree Collapse file tree 10 files changed +108
-43
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ export default class MochaWrapper extends Mocha {
5252
5353 setMaxParallel ( maxParallel : number ) {
5454 this . maxParallel = maxParallel ;
55+ return this ;
5556 }
5657
5758 enableExitMode ( ) {
Original file line number Diff line number Diff line change @@ -144,10 +144,13 @@ echo 'TESTCASE: --exit option support'
144144test test/exit/index.js
145145echo $?
146146echo ' TESTCASE: --retries plus all tests fail'
147- test/retries-all-fail/index.js
147+ test test /retries-all-fail/index.js
148148echo $?
149149echo ' TESTCASE: subprocess exits before sending an end message'
150- test/no-subprocess-end/index.js
150+ test test/no-subprocess-end/index.js
151+ echo $?
152+ echo ' TESTCASE: subprocess reusage'
153+ test test/subprocess-reuse/index.js
151154echo $?
152155
153156if [ $SAUCE_USERNAME ] && [ $SAUCE_ACCESS_KEY ]; then
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ counter.json
Original file line number Diff line number Diff line change 1+ Check that subprocesses are reused
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ const assert = require ( 'assert' ) ;
4+ const { writeFileSync } = require ( 'fs' ) ;
5+ const { resolve } = require ( 'path' ) ;
6+ const MochaParallelTests = require ( '../../dist/main/mocha' ) . default ;
7+
8+ const counterFilePath = resolve ( __dirname , 'counter.json' ) ;
9+ const reporterPath = resolve ( __dirname , '../util/silent-reporter.js' ) ;
10+
11+ process . on ( 'unhandledRejection' , ( reason ) => {
12+ console . error ( reason . stack ) ;
13+ process . exit ( 1 ) ;
14+ } ) ;
15+
16+ // initialize counter file
17+ writeFileSync ( counterFilePath , '[]' ) ;
18+
19+ const mocha = new MochaParallelTests ( ) ;
20+ mocha
21+ . reporter ( reporterPath )
22+ . addFile ( `${ __dirname } /spec/1.spec.js` )
23+ . addFile ( `${ __dirname } /spec/2.spec.js` )
24+ . addFile ( `${ __dirname } /spec/3.spec.js` )
25+ . addFile ( `${ __dirname } /spec/4.spec.js` )
26+ . slow ( 5000 )
27+ . setMaxParallel ( 2 )
28+ . run ( )
29+ . on ( 'end' , function ( ) {
30+ const pidsUsed = require ( counterFilePath ) ;
31+ assert . strictEqual ( pidsUsed . length , 2 , `Number of processes is wrong: ${ pidsUsed . length } ` ) ;
32+ } ) ;
Original file line number Diff line number Diff line change 1+ const { writeFileSync } = require ( 'fs' ) ;
2+ const { resolve } = require ( 'path' ) ;
3+
4+ const updateCounterWithOwnPid = ( ) => {
5+ const counterFilePath = resolve ( __dirname , '../counter.json' ) ;
6+ const pids = new Set ( require ( counterFilePath ) ) ;
7+
8+ pids . add ( process . pid ) ;
9+ writeFileSync ( counterFilePath , JSON . stringify ( [ ...pids ] ) ) ;
10+ } ;
11+
12+ describe ( 'suite' , ( ) => {
13+ it ( 'case' , ( done ) => {
14+ updateCounterWithOwnPid ( ) ;
15+ setTimeout ( done , 1000 ) ;
16+ } ) ;
17+ } ) ;
Original file line number Diff line number Diff line change 1+ const { writeFileSync } = require ( 'fs' ) ;
2+ const { resolve } = require ( 'path' ) ;
3+
4+ const updateCounterWithOwnPid = ( ) => {
5+ const counterFilePath = resolve ( __dirname , '../counter.json' ) ;
6+ const pids = new Set ( require ( counterFilePath ) ) ;
7+
8+ pids . add ( process . pid ) ;
9+ writeFileSync ( counterFilePath , JSON . stringify ( [ ...pids ] ) ) ;
10+ } ;
11+
12+ describe ( 'suite' , ( ) => {
13+ it ( 'case' , ( done ) => {
14+ updateCounterWithOwnPid ( ) ;
15+ setTimeout ( done , 1000 ) ;
16+ } ) ;
17+ } ) ;
Original file line number Diff line number Diff line change 1+ const { writeFileSync } = require ( 'fs' ) ;
2+ const { resolve } = require ( 'path' ) ;
3+
4+ const updateCounterWithOwnPid = ( ) => {
5+ const counterFilePath = resolve ( __dirname , '../counter.json' ) ;
6+ const pids = new Set ( require ( counterFilePath ) ) ;
7+
8+ pids . add ( process . pid ) ;
9+ writeFileSync ( counterFilePath , JSON . stringify ( [ ...pids ] ) ) ;
10+ } ;
11+
12+ describe ( 'suite' , ( ) => {
13+ it ( 'case' , ( done ) => {
14+ updateCounterWithOwnPid ( ) ;
15+ setTimeout ( done , 1000 ) ;
16+ } ) ;
17+ } ) ;
Original file line number Diff line number Diff line change 1+ const { writeFileSync } = require ( 'fs' ) ;
2+ const { resolve } = require ( 'path' ) ;
3+
4+ const updateCounterWithOwnPid = ( ) => {
5+ const counterFilePath = resolve ( __dirname , '../counter.json' ) ;
6+ const pids = new Set ( require ( counterFilePath ) ) ;
7+
8+ pids . add ( process . pid ) ;
9+ writeFileSync ( counterFilePath , JSON . stringify ( [ ...pids ] ) ) ;
10+ } ;
11+
12+ describe ( 'suite' , ( ) => {
13+ it ( 'case' , ( done ) => {
14+ updateCounterWithOwnPid ( ) ;
15+ setTimeout ( done , 1000 ) ;
16+ } ) ;
17+ } ) ;
You can’t perform that action at this time.
0 commit comments