vitest icon indicating copy to clipboard operation
vitest copied to clipboard

fix: colors on `forks` pool

Open AriPerkkio opened this issue 1 year ago • 1 comments

Description

  • Fixes https://github.com/vitest-dev/vitest/issues/7042
  • Requires https://github.com/tinylibs/tinyrainbow/pull/3

This should probably be ported to v2 as colors are not working in latest there.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • [ ] It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • [ ] Ideally, include a test that fails without this PR but passes with it.
  • [ ] Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • [ ] Run the tests with pnpm test:ci.

Documentation

  • [ ] If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • [ ] Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

AriPerkkio avatar Dec 17 '24 08:12 AriPerkkio

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
Latest commit e4153c7f9a6ff7b92781019783cfd0fdf57cacfe
Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/67855bcce585af00087e6722
Deploy Preview https://deploy-preview-7090--vitest-dev.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Dec 17 '24 08:12 netlify[bot]

Windows CI is failing. It's like it didn't set isatty(1) as false when forked process's stdout is captured into buffer. 🤔

Anyone with Windows machine to check what following script prints?

import { writeFileSync } from "node:fs";
import { fork } from "node:child_process";
import { setTimeout } from "node:timers/promises";
import { isatty } from "node:tty";

console.log("main thread", isatty(1));

writeFileSync(
  "./worker.mjs",
  `
import { isatty } from "node:tty";

console.log("process", isatty(1));
`.trim(),
  "utf8"
);

const subprocess = fork("./worker.mjs", { stdio: "pipe" });
subprocess.stdout.pipe(process.stdout);
subprocess.stderr.pipe(process.stderr);

await setTimeout(3_000);
subprocess.kill();

AriPerkkio avatar Jan 13 '25 19:01 AriPerkkio

imagen

userquin avatar Jan 13 '25 19:01 userquin

It's likely caused by colors being enabled on based on platform here: https://github.com/tinylibs/tinyrainbow/blob/550fbcdc56b9b2d69230e73b48e3d7ba0dc2e60c/src/index.ts#L91

I'll add skip to windows on tests.

AriPerkkio avatar Jan 14 '25 06:01 AriPerkkio