Skip to content

Commit 524eb24

Browse files
panvanodejs-github-bot
authored andcommitted
test: isolate styleText tests from the environment
The TTY cases inherit TERM, CI and the color override variables. These can disable colors in a case expecting styling, or force colors in a case expecting plain text. The tests skip these cases without a TTY, which hides the dependency in many standalone runs. Set a color-capable TERM and only the environment variables specified by each case. Remove the RISC-V flaky expectations. Refs: nodejs/build#4099 (comment) Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Claude, Codex PR-URL: #66320 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 929b39c commit 524eb24

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

‎test/parallel/parallel.status‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,3 @@ test-http-correct-hostname: SKIP
130130
[$arch==riscv64]
131131
# Snapshot test works in some environments but not others for now on RISC-V
132132
test-snapshot-reproducible: PASS, FLAKY
133-
# styletext ones are failing in jenkins but pass standalone so something
134-
# odd is happening to the ttys when run via java. tty issue
135-
# https://github.com/nodejs/build/issues/4099#issuecomment-5070947806
136-
test-util-styletext: PASS, FLAKY
137-
test-util-styletext-hex: PASS, FLAKY

‎test/parallel/test-util-styletext-hex.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,10 @@ describe('util.styleText hex color support', () => {
213213
for (const testCase of testCases) {
214214
it(`should respect ${testCase.description}`, () => {
215215
writeStream.isTTY = testCase.isTTY;
216+
// Do not inherit color-related variables (TERM, CI, NO_COLOR, ...)
217+
// from the environment the test happens to run in.
216218
process.env = {
217-
...originalEnv,
219+
TERM: 'xterm-256color',
218220
...testCase.env,
219221
};
220222
const output = util.styleText('#ffcc00', 'test', { stream: writeStream });

‎test/parallel/test-util-styletext.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,11 @@ if (fd !== -1) {
203203
{ isTTY: true, env: { FORCE_COLOR: '1', NO_COLOR: '1', NODE_DISABLE_COLORS: '1' }, expected: styled },
204204
].forEach((testCase) => {
205205
writeStream.isTTY = testCase.isTTY;
206+
// Do not inherit color-related variables (TERM, CI, NO_COLOR, ...) from
207+
// the environment the test happens to run in.
206208
process.env = {
207-
...process.env,
208-
...testCase.env
209+
TERM: 'xterm-256color',
210+
...testCase.env,
209211
};
210212
{
211213
const output = util.styleText('red', 'test', { stream: writeStream });

0 commit comments

Comments
 (0)