Skip to content

Commit

Permalink
refactor: rename to file-parallelism
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Dec 18, 2023
1 parent 1dcc5f9 commit 63b7aac
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -879,11 +879,11 @@ Pass additional arguments to `node` process in the VM context. See [Command-line
Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103.
:::

### parallelism
### fileParallelism

- **Type:** `boolean`
- **Default:** `true`
- **CLI:** `--parallelism`, `--no-parallelism`
- **CLI:** `--no-file-parallelism`, `--fileParallelism=false`
- **Version:** Since Vitest 1.1

Should all test files run in parallel. Setting this to `false` will override `maxWorkers` and `minWorkers` options to `1`.
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Run only [benchmark](https://vitest.dev/guide/features.html#benchmarking-experim
| `--poolOptions <options>` | Specify pool options |
| `--poolOptions.threads.isolate` | Isolate tests in threads pool (default: `true`) |
| `--poolOptions.forks.isolate` | Isolate tests in forks pool (default: `true`) |
| `--parallelism` | Should all test files run in parallel. Use --no-parallelism to disable (default: true) |
| `--fileParallelism` | Should all test files run in parallel. Use --no-parallelism to disable (default: true) |
| `--maxWorkers` | Maximum number of workers to run tests in |
| `--minWorkers` | Minimum number of workers to run tests in |
| `--silent` | Silent console output from tests |
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ If you are using Vitest 1.1 or higher, you can also just provide `--no-paralleli

```sh
# If pool is unknown
vitest --inspect-brk --no-parallelism
vitest --inspect-brk --no-file-parallelism
```

Once Vitest starts it will stop execution and wait for you to open developer tools that can connect to [Node.js inspector](https://nodejs.org/en/docs/guides/debugging-getting-started/). You can use Chrome DevTools for this by opening `chrome://inspect` on browser.
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cli
.option('--poolOptions <options>', 'Specify pool options')
.option('--poolOptions.threads.isolate', 'Isolate tests in threads pool (default: true)')
.option('--poolOptions.forks.isolate', 'Isolate tests in forks pool (default: true)')
.option('--parallelism', 'Should all test files run in parallel. Use --no-parallelism to disable (default: true)')
.option('--fileParallelism', 'Should all test files run in parallel. Use --no-file-parallelism to disable (default: true)')
.option('--maxWorkers', 'Maximum number of workers to run tests in')
.option('--minWorkers', 'Minimum number of workers to run tests in')
.option('--environment <env>', 'Specify runner environment, if not running in the browser (default: node)')
Expand Down
6 changes: 3 additions & 3 deletions packages/vitest/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ export function resolveConfig(
resolved.shard = { index, count }
}

resolved.parallelism ??= true
resolved.fileParallelism ??= true

if (!resolved.parallelism) {
if (!resolved.fileParallelism) {
// ignore user config, parallelism cannot be implemented without limiting workers
resolved.maxWorkers = 1
resolved.minWorkers = 1
Expand All @@ -125,7 +125,7 @@ export function resolveConfig(
const isSingleThread = resolved.pool === 'threads' && resolved.poolOptions?.threads?.singleThread
const isSingleFork = resolved.pool === 'forks' && resolved.poolOptions?.forks?.singleFork

if (resolved.parallelism && !isSingleThread && !isSingleFork) {
if (resolved.fileParallelism && !isSingleThread && !isSingleFork) {
const inspectOption = `--inspect${resolved.inspectBrk ? '-brk' : ''}`
throw new Error(`You cannot use ${inspectOption} without "--no-parallelism", "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/pools/child.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function createChildProcessPool(ctx: Vitest, { execArgv, env, forksPath }
if (isolated)
options.isolateWorkers = true

if (poolOptions.singleFork || !ctx.config.parallelism) {
if (poolOptions.singleFork || !ctx.config.fileParallelism) {
options.maxThreads = 1
options.minThreads = 1
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/pools/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function createThreadsPool(ctx: Vitest, { execArgv, env, workerPath }: Po
if (isolated)
options.isolateWorkers = true

if (poolOptions.singleThread || !ctx.config.parallelism) {
if (poolOptions.singleThread || !ctx.config.fileParallelism) {
options.maxThreads = 1
options.minThreads = 1
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/pools/vm-threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function createVmThreadsPool(ctx: Vitest, { execArgv, env, vmPath }: Pool
maxMemoryLimitBeforeRecycle: getMemoryLimit(ctx.config) || undefined,
}

if (poolOptions.singleThread || !ctx.config.parallelism) {
if (poolOptions.singleThread || !ctx.config.fileParallelism) {
options.maxThreads = 1
options.minThreads = 1
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export interface InlineConfig {
*
* @default true
*/
parallelism?: boolean
fileParallelism?: boolean

/**
* Automatically assign pool based on globs. The first match will be used.
Expand Down

0 comments on commit 63b7aac

Please sign in to comment.