Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
test: actually test tty getColorDepth()
Browse files Browse the repository at this point in the history
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: nodejs/node#17615
PR-URL: nodejs/node#18800
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
Fishrock123 committed Feb 20, 2018
1 parent 92bf249 commit 7514eb3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 35 deletions.
35 changes: 0 additions & 35 deletions test/parallel/test-tty-get-color-depth.js

This file was deleted.

36 changes: 36 additions & 0 deletions test/pseudo-tty/test-tty-get-color-depth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'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;
}
Empty file.

0 comments on commit 7514eb3

Please sign in to comment.