| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4c0036b commit 3dddc01
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -785,9 +785,8 @@ changes: | |||
| 785 | 785 | properties are supported: | |
| 786 | 786 | * `concurrency` {number|boolean} If a number is provided, | |
| 787 | 787 | then that many tests would run in parallel within the application thread. | |
| 788 | - If `true`, it would run `os.availableParallelism() - 1` tests in parallel. | ||
| 789 | - For subtests, it will be `Infinity` tests in parallel. | ||
| 790 | - If `false`, it would only run one test at a time. | ||
| 788 | + If `true`, all scheduled asynchronous tests run concurrently within the | ||
| 789 | + thread. If `false`, only one test runs at a time. | ||
| 791 | 790 | If unspecified, subtests inherit this value from their parent. | |
| 792 | 791 | **Default:** `false`. | |
| 793 | 792 | * `only` {boolean} If truthy, and the test context is configured to run | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ const assert = require('node:assert'); | |||
| 7 | 7 | const path = require('node:path'); | |
| 8 | 8 | const fs = require('node:fs/promises'); | |
| 9 | 9 | const os = require('node:os'); | |
| 10 | + const timers = require('node:timers/promises'); | ||
| 10 | 11 | ||
| 11 | 12 | tmpdir.refresh(); | |
| 12 | 13 | ||
@@ -35,6 +36,22 @@ describe( | |||
| 35 | 36 | } | |
| 36 | 37 | ); | |
| 37 | 38 | ||
| 39 | + // Despite the docs saying so at some point, setting concurrency to true should | ||
| 40 | + // not limit concurrency to the number of available CPU cores. | ||
| 41 | + describe('concurrency: true implies Infinity', { concurrency: true }, () => { | ||
| 42 | + // The factor 5 is intentionally chosen to be higher than the default libuv | ||
| 43 | + // thread pool size. | ||
| 44 | + const nTests = 5 * os.availableParallelism(); | ||
| 45 | + let nStarted = 0; | ||
| 46 | + for (let i = 0; i < nTests; i++) { | ||
| 47 | + it(`should run test ${i} concurrently`, async () => { | ||
| 48 | + assert.strictEqual(nStarted++, i); | ||
| 49 | + await timers.setImmediate(); | ||
| 50 | + assert.strictEqual(nStarted, nTests); | ||
| 51 | + }); | ||
| 52 | + } | ||
| 53 | + }); | ||
| 54 | + | ||
| 38 | 55 | { | |
| 39 | 56 | // Make sure tests run in order when root concurrency is 1 (default) | |
| 40 | 57 | const tree = []; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments