mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 14:41:29 +00:00

TTY tests should almost never be placed in `/parallel/`. Skipping TTY tests there due to missing tty fds just means they will never be run, ever, on any system. This moves the tty-get-color-depth test to `/pseudo-tty/` where the test runner will actually make a pty fd. Refs: https://github.com/nodejs/node/pull/17615 PR-URL: https://github.com/nodejs/node/pull/18800 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
37 lines
931 B
JavaScript
37 lines
931 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert').strict;
|
|
/* eslint-disable no-restricted-properties */
|
|
const { WriteStream } = require('tty');
|
|
|
|
const fd = common.getTTYfd();
|
|
const writeStream = new WriteStream(fd);
|
|
|
|
{
|
|
const depth = writeStream.getColorDepth();
|
|
|
|
assert.equal(typeof depth, 'number');
|
|
assert(depth >= 1 && depth <= 24);
|
|
|
|
if (depth === 1) {
|
|
// Terminal does not support colors, compare to a value that would.
|
|
assert.notEqual(writeStream.getColorDepth({ COLORTERM: '1' }), depth);
|
|
} else {
|
|
// Terminal supports colors, compare to a value that would not.
|
|
assert.notEqual(writeStream.getColorDepth({ TERM: 'dumb' }), depth);
|
|
}
|
|
}
|
|
|
|
// Deactivate colors
|
|
{
|
|
const tmp = process.env.NODE_DISABLE_COLORS;
|
|
process.env.NODE_DISABLE_COLORS = 1;
|
|
|
|
const depth = writeStream.getColorDepth();
|
|
|
|
assert.equal(depth, 1);
|
|
|
|
process.env.NODE_DISABLE_COLORS = tmp;
|
|
}
|