Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jan 9, 2024
1 parent dbad39f commit a64afa9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/vitest/src/runtime/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import { ModuleCacheMap } from 'vite-node/client'
import type { ContextRPC } from '../types/rpc'
import { loadEnvironment } from '../integrations/env/loader'
import type { WorkerGlobalState } from '../types/worker'
import { isChildProcess, setProcessTitle } from '../utils/base'
import { setupInspect } from './inspector'
import { createRuntimeRpc, rpcDone } from './rpc'
import type { VitestWorker } from './workers/types'

if (isChildProcess())
setProcessTitle(`vitest ${poolId}`)

// this is what every pool executes when running tests
export async function run(ctx: ContextRPC) {
const prepareStart = performance.now()
Expand Down
6 changes: 3 additions & 3 deletions packages/vitest/src/runtime/workers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export function createThreadsRpcOptions({ port }: WorkerContext): WorkerRpcOptio
}
}

export function createForksRpcOptions(v8: typeof import('v8')): WorkerRpcOptions {
export function createForksRpcOptions(nodeV8: typeof import('v8')): WorkerRpcOptions {
return {
serialize: v8.serialize,
deserialize: v => v8.deserialize(Buffer.from(v)),
serialize: nodeV8.serialize,
deserialize: v => nodeV8.deserialize(Buffer.from(v)),
post(v) { process.send!(v) },
on(fn) {
process.on('message', (message: any, ...extras: any) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/runtime/workers/vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ export async function runVmTests(state: WorkerGlobalState) {

const stubs = getDefaultRequestStubs(context)

const externalModulesExecutor: ExternalModulesExecutor | null = new ExternalModulesExecutor({
const externalModulesExecutor = new ExternalModulesExecutor({
context,
fileMap,
packageCache,
transform: rpc.transform,
viteClientModule: stubs['/@vite/client'],
})

const executor: VitestExecutor | null = await startVitestExecutor({
const executor = await startVitestExecutor({
context,
moduleCache: state.moduleCache,
mockMap: state.mockMap,
Expand Down
7 changes: 7 additions & 0 deletions packages/vitest/src/utils/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,10 @@ export { AggregateErrorPonyfill as AggregateError }
export function isChildProcess(): boolean {
return !!process?.send
}

export function setProcessTitle(title: string) {
try {
process.title = `node (${title})`
}
catch {}
}

0 comments on commit a64afa9

Please sign in to comment.