-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
104 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
counter.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Check that subprocesses are reused |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env node | ||
|
||
const assert = require('assert'); | ||
const { writeFileSync } = require('fs'); | ||
const { resolve } = require('path'); | ||
const MochaParallelTests = require('../../dist/main/mocha').default; | ||
|
||
const counterFilePath = resolve(__dirname, 'counter.json'); | ||
const reporterPath = resolve(__dirname, '../util/silent-reporter.js'); | ||
|
||
process.on('unhandledRejection', (reason) => { | ||
console.error(reason.stack); | ||
process.exit(1); | ||
}); | ||
|
||
// initialize counter file | ||
writeFileSync(counterFilePath, '[]'); | ||
|
||
const mocha = new MochaParallelTests(); | ||
mocha | ||
.reporter(reporterPath) | ||
.addFile(`${__dirname}/spec/1.spec.js`) | ||
.addFile(`${__dirname}/spec/2.spec.js`) | ||
.addFile(`${__dirname}/spec/3.spec.js`) | ||
.addFile(`${__dirname}/spec/4.spec.js`) | ||
.slow(5000) | ||
.setMaxParallel(2) | ||
.run() | ||
.on('end', function () { | ||
const pidsUsed = require(counterFilePath); | ||
assert.strictEqual(pidsUsed.length, 2, `Number of processes is wrong: ${pidsUsed.length}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { writeFileSync } = require('fs'); | ||
const { resolve } = require('path'); | ||
|
||
const updateCounterWithOwnPid = () => { | ||
const counterFilePath = resolve(__dirname, '../counter.json'); | ||
const pids = new Set(require(counterFilePath)); | ||
|
||
pids.add(process.pid); | ||
writeFileSync(counterFilePath, JSON.stringify([...pids])); | ||
}; | ||
|
||
describe('suite', () => { | ||
it('case', (done) => { | ||
updateCounterWithOwnPid(); | ||
setTimeout(done, 1000); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { writeFileSync } = require('fs'); | ||
const { resolve } = require('path'); | ||
|
||
const updateCounterWithOwnPid = () => { | ||
const counterFilePath = resolve(__dirname, '../counter.json'); | ||
const pids = new Set(require(counterFilePath)); | ||
|
||
pids.add(process.pid); | ||
writeFileSync(counterFilePath, JSON.stringify([...pids])); | ||
}; | ||
|
||
describe('suite', () => { | ||
it('case', (done) => { | ||
updateCounterWithOwnPid(); | ||
setTimeout(done, 1000); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { writeFileSync } = require('fs'); | ||
const { resolve } = require('path'); | ||
|
||
const updateCounterWithOwnPid = () => { | ||
const counterFilePath = resolve(__dirname, '../counter.json'); | ||
const pids = new Set(require(counterFilePath)); | ||
|
||
pids.add(process.pid); | ||
writeFileSync(counterFilePath, JSON.stringify([...pids])); | ||
}; | ||
|
||
describe('suite', () => { | ||
it('case', (done) => { | ||
updateCounterWithOwnPid(); | ||
setTimeout(done, 1000); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { writeFileSync } = require('fs'); | ||
const { resolve } = require('path'); | ||
|
||
const updateCounterWithOwnPid = () => { | ||
const counterFilePath = resolve(__dirname, '../counter.json'); | ||
const pids = new Set(require(counterFilePath)); | ||
|
||
pids.add(process.pid); | ||
writeFileSync(counterFilePath, JSON.stringify([...pids])); | ||
}; | ||
|
||
describe('suite', () => { | ||
it('case', (done) => { | ||
updateCounterWithOwnPid(); | ||
setTimeout(done, 1000); | ||
}); | ||
}); |