Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: snapshots now updating #1503

Merged
merged 1 commit into from Jun 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/vitest/src/node/pool.ts
Expand Up @@ -7,7 +7,7 @@ import type { Options as TinypoolOptions } from 'tinypool'
import { Tinypool } from 'tinypool'
import { createBirpc } from 'birpc'
import type { RawSourceMap } from 'vite-node'
import type { WorkerContext, WorkerRPC } from '../types'
import type { ResolvedConfig, WorkerContext, WorkerRPC } from '../types'
import { distDir } from '../constants'
import { AggregateError, slash } from '../utils'
import type { Vitest } from './core'
Expand Down Expand Up @@ -66,9 +66,8 @@ export function createPool(ctx: Vitest): WorkerPool {

const runWithFiles = (name: string): RunWithFiles => {
let id = 0
const config = ctx.getSerializableConfig()

async function runFiles(files: string[], invalidates: string[] = []) {
async function runFiles(config: ResolvedConfig, files: string[], invalidates: string[] = []) {
const { workerPort, port } = createChannel(ctx)
const workerId = ++id
const data: WorkerContext = {
Expand All @@ -89,6 +88,8 @@ export function createPool(ctx: Vitest): WorkerPool {
}

return async (files, invalidates) => {
const config = ctx.getSerializableConfig()

if (config.shard) {
const { index, count } = config.shard
const shardSize = Math.ceil(files.length / count)
Expand All @@ -111,11 +112,11 @@ export function createPool(ctx: Vitest): WorkerPool {
}

if (!ctx.config.threads) {
await runFiles(files)
await runFiles(config, files)
}
else {
const results = await Promise.allSettled(files
.map(file => runFiles([file], invalidates)))
.map(file => runFiles(config, [file], invalidates)))

const errors = results.filter((r): r is PromiseRejectedResult => r.status === 'rejected').map(r => r.reason)
if (errors.length > 0)
Expand Down