Skip to content

Commit

Permalink
fix: colors on forks pool (#7090)
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio authored Jan 14, 2025
1 parent 798c0da commit 8cab960
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"magic-string": "^0.30.17",
"msw": "^2.7.0",
"sirv": "^3.0.0",
"tinyrainbow": "^1.2.0",
"tinyrainbow": "^2.0.0",
"ws": "^8.18.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/coverage-istanbul/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"istanbul-reports": "^3.1.7",
"magicast": "^0.3.5",
"test-exclude": "^7.0.1",
"tinyrainbow": "^1.2.0"
"tinyrainbow": "^2.0.0"
},
"devDependencies": {
"@types/debug": "^4.1.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/coverage-v8/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"magicast": "^0.3.5",
"std-env": "^3.8.0",
"test-exclude": "^7.0.1",
"tinyrainbow": "^1.2.0"
"tinyrainbow": "^2.0.0"
},
"devDependencies": {
"@types/debug": "^4.1.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/expect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@vitest/spy": "workspace:*",
"@vitest/utils": "workspace:*",
"chai": "^5.1.2",
"tinyrainbow": "^1.2.0"
"tinyrainbow": "^2.0.0"
},
"devDependencies": {
"@types/chai": "4.3.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/pretty-format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"dev": "rollup -c --watch"
},
"dependencies": {
"tinyrainbow": "^1.2.0"
"tinyrainbow": "^2.0.0"
},
"devDependencies": {
"@types/react-is": "^19.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"pathe": "^2.0.0",
"sirv": "^3.0.0",
"tinyglobby": "^0.2.10",
"tinyrainbow": "^1.2.0"
"tinyrainbow": "^2.0.0"
},
"devDependencies": {
"@faker-js/faker": "^9.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"dependencies": {
"@vitest/pretty-format": "workspace:*",
"loupe": "^3.1.2",
"tinyrainbow": "^1.2.0"
"tinyrainbow": "^2.0.0"
},
"devDependencies": {
"@jridgewell/trace-mapping": "^0.3.25",
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@
"devDependencies": {
"@jridgewell/trace-mapping": "^0.3.25",
"@types/debug": "^4.1.12",
"tinyrainbow": "^1.2.0"
"tinyrainbow": "^2.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
"tinybench": "^2.9.0",
"tinyexec": "^0.3.2",
"tinypool": "^1.0.2",
"tinyrainbow": "^1.2.0",
"tinyrainbow": "^2.0.0",
"vite": "^5.0.0 || ^6.0.0",
"vite-node": "workspace:*",
"why-is-node-running": "^2.3.0"
Expand Down
2 changes: 2 additions & 0 deletions packages/vitest/src/node/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Vitest } from './core'
import type { TestProject } from './project'
import type { TestSpecification } from './spec'
import type { BuiltinPool, Pool } from './types/pool-options'
import { isatty } from 'node:tty'
import mm from 'micromatch'
import { isWindows } from '../utils/env'
import { createForksPool } from './pools/forks'
Expand Down Expand Up @@ -124,6 +125,7 @@ export function createPool(ctx: Vitest): ProcessPool {
VITEST: 'true',
NODE_ENV: process.env.NODE_ENV || 'test',
VITEST_MODE: ctx.config.watch ? 'WATCH' : 'RUN',
FORCE_TTY: isatty(1) ? 'true' : '',
...process.env,
...ctx.config.env,
},
Expand Down
50 changes: 25 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions test/config/test/console-color.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, test } from 'vitest'
import { isWindows } from '../../../packages/vite-node/src/utils'
import { runVitest } from '../../test-utils'

test('with color', async () => {
Expand Down Expand Up @@ -29,3 +30,35 @@ test('without color', async () => {
expect(stdout).toContain('true\n')
expect(stdout).not.toContain('\x1B[33mtrue\x1B[39m\n')
})

test.skipIf(isWindows)('without color, forks pool in non-TTY parent', async () => {
const { stdout } = await runVitest({
root: 'fixtures/console-color',
env: {
CI: undefined,
FORCE_COLOR: undefined,
NO_COLOR: undefined,
GITHUB_ACTIONS: undefined,

// Overrides current process's value, since we are running Vitest in Vitest here
FORCE_TTY: undefined,
},
}, undefined, undefined, undefined, { preserveAnsi: true })

expect(stdout).toContain('true\n')
expect(stdout).not.toContain('\x1B[33mtrue\x1B[39m\n')
})

test('with color, forks pool in TTY parent', async () => {
const { stdout } = await runVitest({
root: 'fixtures/console-color',
env: {
CI: undefined,
FORCE_COLOR: undefined,
NO_COLOR: undefined,
GITHUB_ACTIONS: undefined,
},
}, undefined, undefined, undefined, { preserveAnsi: true })

expect(stdout).toContain('\x1B[33mtrue\x1B[39m\n')
})
2 changes: 1 addition & 1 deletion test/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"react": "^18.3.1",
"react-19": "npm:react@19.0.0-rc-b01722d5-20241114",
"sweetalert2": "^11.6.16",
"tinyrainbow": "^1.2.0",
"tinyrainbow": "^2.0.0",
"tinyspy": "^1.0.2",
"url": "^0.11.0",
"vite-node": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion test/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"devDependencies": {
"tinyexec": "^0.3.2",
"tinyrainbow": "^1.2.0",
"tinyrainbow": "^2.0.0",
"vite": "latest",
"vite-node": "workspace:*",
"vitest": "workspace:*"
Expand Down

0 comments on commit 8cab960

Please sign in to comment.