forked from nodejs/node-core-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for boolean values for
concurrency
option
PR-URL: nodejs/node#43887 Fixes: nodejs/node#43837 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> (cherry picked from commit dab492f0444b0a6ae8a41dd1d9605e036c363655)
- Loading branch information
Showing
5 changed files
with
49 additions
and
6 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 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
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,31 @@ | ||
// https://github.com/nodejs/node/blob/dab492f0444b0a6ae8a41dd1d9605e036c363655/test/parallel/test-runner-concurrency.js | ||
|
||
'use strict' | ||
require('../common') | ||
const { describe, it } = require('node:test') | ||
const assert = require('assert') | ||
|
||
describe('Concurrency option (boolean) = true ', { concurrency: true }, () => { | ||
let isFirstTestOver = false | ||
it('should start the first test', () => new Promise((resolve) => { | ||
setImmediate(() => { isFirstTestOver = true; resolve() }) | ||
})) | ||
it('should start before the previous test ends', () => { | ||
// Should work even on single core CPUs | ||
assert.strictEqual(isFirstTestOver, false) | ||
}) | ||
}) | ||
|
||
describe( | ||
'Concurrency option (boolean) = false ', | ||
{ concurrency: false }, | ||
() => { | ||
let isFirstTestOver = false | ||
it('should start the first test', () => new Promise((resolve) => { | ||
setImmediate(() => { isFirstTestOver = true; resolve() }) | ||
})) | ||
it('should start after the previous test ends', () => { | ||
assert.strictEqual(isFirstTestOver, true) | ||
}) | ||
} | ||
) |