Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: skip some console tests on dumb terminal #33165

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/common/README.md
Expand Up @@ -223,6 +223,10 @@ Platform check for Advanced Interactive eXecutive (AIX).

Attempts to 'kill' `pid`

### `isDumbTerminal`

* [<boolean>][]

### `isFreeBSD`

* [<boolean>][]
Expand Down Expand Up @@ -385,6 +389,10 @@ will not be run.

Logs '1..0 # Skipped: ' + `msg` and exits with exit code `0`.

### `skipIfDumbTerminal()`

Skip the rest of the tests if the current terminal is a dumb terminal

### `skipIfEslintMissing()`

Skip the rest of the tests in the current file when `ESLint` is not available
Expand Down
10 changes: 10 additions & 0 deletions test/common/index.js
Expand Up @@ -112,6 +112,8 @@ const isOpenBSD = process.platform === 'openbsd';
const isLinux = process.platform === 'linux';
const isOSX = process.platform === 'darwin';

const isDumbTerminal = process.env.TERM === 'dumb';
BridgeAR marked this conversation as resolved.
Show resolved Hide resolved

const rootDir = isWindows ? 'c:\\' : '/';

const buildType = process.config.target_defaults ?
Expand Down Expand Up @@ -653,6 +655,12 @@ function invalidArgTypeHelper(input) {
return ` Received type ${typeof input} (${inspected})`;
}

function skipIfDumbTerminal() {
if (isDumbTerminal) {
skip('skipping - dumb terminal');
}
}

const common = {
allowGlobals,
buildType,
Expand All @@ -672,6 +680,7 @@ const common = {
invalidArgTypeHelper,
isAIX,
isAlive,
isDumbTerminal,
isFreeBSD,
isLinux,
isMainThread,
Expand All @@ -692,6 +701,7 @@ const common = {
runWithInvalidFD,
skip,
skipIf32Bits,
skipIfDumbTerminal,
skipIfEslintMissing,
skipIfInspectorDisabled,
skipIfWorker,
Expand Down
4 changes: 4 additions & 0 deletions test/common/index.mjs
Expand Up @@ -12,6 +12,7 @@ const {
isIBMi,
isLinuxPPCBE,
isSunOS,
isDumbTerminal,
isFreeBSD,
isOpenBSD,
isLinux,
Expand All @@ -31,6 +32,7 @@ const {
mustCall,
mustCallAtLeast,
hasMultiLocalhost,
skipIfDumbTerminal,
skipIfEslintMissing,
canCreateSymLink,
getCallSite,
Expand All @@ -57,6 +59,7 @@ export {
isIBMi,
isLinuxPPCBE,
isSunOS,
isDumbTerminal,
isFreeBSD,
isOpenBSD,
isLinux,
Expand All @@ -76,6 +79,7 @@ export {
mustCall,
mustCallAtLeast,
hasMultiLocalhost,
skipIfDumbTerminal,
skipIfEslintMissing,
canCreateSymLink,
getCallSite,
Expand Down
6 changes: 4 additions & 2 deletions test/parallel/test-console-clear.js
@@ -1,6 +1,6 @@
'use strict';

require('../common');
const common = require('../common');
const assert = require('assert');

const stdoutWrite = process.stdout.write;
Expand All @@ -18,5 +18,7 @@ function doTest(isTTY, check) {
}

// Fake TTY
doTest(true, check);
if (!common.isDumbTerminal) {
doTest(true, check);
}
doTest(false, '');
1 change: 1 addition & 0 deletions test/parallel/test-readline-interface.js
Expand Up @@ -22,6 +22,7 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
common.skipIfDumbTerminal();

const assert = require('assert');
const readline = require('readline');
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-readline-position.js
@@ -1,13 +1,15 @@
// Flags: --expose-internals
'use strict';
require('../common');
const common = require('../common');
const { internalBinding } = require('internal/test/binding');
const { PassThrough } = require('stream');
const readline = require('readline');
const assert = require('assert');

const ctrlU = { ctrl: true, name: 'u' };

common.skipIfDumbTerminal();

{
const input = new PassThrough();
const rl = readline.createInterface({
Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-readline-tab-complete.js
Expand Up @@ -8,6 +8,8 @@ const assert = require('assert');
const EventEmitter = require('events').EventEmitter;
const { getStringWidth } = require('internal/util/inspect');

common.skipIfDumbTerminal();

// This test verifies that the tab completion supports unicode and the writes
// are limited to the minimum.
[
Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-readline-undefined-columns.js
Expand Up @@ -5,6 +5,8 @@ const assert = require('assert');
const PassThrough = require('stream').PassThrough;
const readline = require('readline');

common.skipIfDumbTerminal();

// Checks that tab completion still works
// when output column size is undefined

Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-readline.js
Expand Up @@ -4,6 +4,8 @@ const { PassThrough } = require('stream');
const readline = require('readline');
const assert = require('assert');

common.skipIfDumbTerminal();

{
const input = new PassThrough();
const rl = readline.createInterface({
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-repl-editor.js
@@ -1,10 +1,12 @@
'use strict';

require('../common');
const common = require('../common');
const assert = require('assert');
const repl = require('repl');
const ArrayStream = require('../common/arraystream');

common.skipIfDumbTerminal();

// \u001b[nG - Moves the cursor to n st column
// \u001b[0J - Clear screen
// \u001b[0K - Clear to line end
Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-repl-history-navigation.js
Expand Up @@ -10,6 +10,8 @@ const fs = require('fs');
const path = require('path');
const { inspect } = require('util');

common.skipIfDumbTerminal();

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-repl-load-multiline.js
@@ -1,10 +1,12 @@
'use strict';
require('../common');
const common = require('../common');
const ArrayStream = require('../common/arraystream');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const repl = require('repl');

common.skipIfDumbTerminal();

const command = `.load ${fixtures.path('repl-load-multiline.js')}`;
const terminalCode = '\u001b[1G\u001b[0J \u001b[1G';
const terminalCodeRegex = new RegExp(terminalCode.replace(/\[/g, '\\['), 'g');
Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-repl-persistent-history.js
Expand Up @@ -12,6 +12,8 @@ const path = require('path');
const os = require('os');
const util = require('util');

common.skipIfDumbTerminal();

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-repl-preview.js
Expand Up @@ -7,6 +7,7 @@ const { Stream } = require('stream');
const { inspect } = require('util');

common.skipIfInspectorDisabled();
common.skipIfDumbTerminal();

const PROMPT = 'repl > ';

Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-repl-programmatic-history.js
Expand Up @@ -10,6 +10,8 @@ const path = require('path');
const os = require('os');
const util = require('util');

common.skipIfDumbTerminal();

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-repl-reverse-search.js
Expand Up @@ -10,6 +10,7 @@ const fs = require('fs');
const path = require('path');
const { inspect } = require('util');

common.skipIfDumbTerminal();
common.allowGlobals('aaaa');

const tmpdir = require('../common/tmpdir');
Expand Down