Skip to content

Commit 302408e

Browse files
AdamMajercodebytere
authored andcommitted
test: skip some console tests on dumb terminal
Add capabilities to common test module to detect and skip tests on dumb terminals. In some of our build environments, like s390x, the terminal is a dumb terminal meaning it has very rudimentary capabilities. These in turn prevent some of the tests from completing with errors as below. not ok 1777 parallel/test-readline-tab-complete --- duration_ms: 0.365 severity: fail exitcode: 1 stack: |- assert.js:103 throw new AssertionError(obj); ^ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: '\t' !== '' at /home/abuild/rpmbuild/BUILD/node-git.8698dd98bb/test/parallel/test-readline-tab-complete.js:63:14 at Array.forEach (<anonymous>) at /home/abuild/rpmbuild/BUILD/node-git.8698dd98bb/test/parallel/test-readline-tab-complete.js:18:17 at Array.forEach (<anonymous>) at Object.<anonymous> (/home/abuild/rpmbuild/BUILD/node-git.8698dd98bb/test/parallel/test-readline-tab-complete.js:17:3) at Module._compile (internal/modules/cjs/loader.js:1176:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10) at Module.load (internal/modules/cjs/loader.js:1040:32) at Function.Module._load (internal/modules/cjs/loader.js:929:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) { generatedMessage: true, code: 'ERR_ASSERTION', actual: '\t', expected: '', operator: 'strictEqual' } ... PR-URL: #33165 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 6bca487 commit 302408e

16 files changed

+50
-5
lines changed

test/common/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ Platform check for Advanced Interactive eXecutive (AIX).
223223

224224
Attempts to 'kill' `pid`
225225

226+
### `isDumbTerminal`
227+
228+
* [&lt;boolean>][]
229+
226230
### `isFreeBSD`
227231

228232
* [&lt;boolean>][]
@@ -385,6 +389,10 @@ will not be run.
385389

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

392+
### `skipIfDumbTerminal()`
393+
394+
Skip the rest of the tests if the current terminal is a dumb terminal
395+
388396
### `skipIfEslintMissing()`
389397

390398
Skip the rest of the tests in the current file when `ESLint` is not available

test/common/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ const isOpenBSD = process.platform === 'openbsd';
112112
const isLinux = process.platform === 'linux';
113113
const isOSX = process.platform === 'darwin';
114114

115+
const isDumbTerminal = process.env.TERM === 'dumb';
116+
115117
const rootDir = isWindows ? 'c:\\' : '/';
116118

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

658+
function skipIfDumbTerminal() {
659+
if (isDumbTerminal) {
660+
skip('skipping - dumb terminal');
661+
}
662+
}
663+
656664
const common = {
657665
allowGlobals,
658666
buildType,
@@ -672,6 +680,7 @@ const common = {
672680
invalidArgTypeHelper,
673681
isAIX,
674682
isAlive,
683+
isDumbTerminal,
675684
isFreeBSD,
676685
isLinux,
677686
isMainThread,
@@ -692,6 +701,7 @@ const common = {
692701
runWithInvalidFD,
693702
skip,
694703
skipIf32Bits,
704+
skipIfDumbTerminal,
695705
skipIfEslintMissing,
696706
skipIfInspectorDisabled,
697707
skipIfWorker,

test/common/index.mjs

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const {
1212
isIBMi,
1313
isLinuxPPCBE,
1414
isSunOS,
15+
isDumbTerminal,
1516
isFreeBSD,
1617
isOpenBSD,
1718
isLinux,
@@ -31,6 +32,7 @@ const {
3132
mustCall,
3233
mustCallAtLeast,
3334
hasMultiLocalhost,
35+
skipIfDumbTerminal,
3436
skipIfEslintMissing,
3537
canCreateSymLink,
3638
getCallSite,
@@ -57,6 +59,7 @@ export {
5759
isIBMi,
5860
isLinuxPPCBE,
5961
isSunOS,
62+
isDumbTerminal,
6063
isFreeBSD,
6164
isOpenBSD,
6265
isLinux,
@@ -76,6 +79,7 @@ export {
7679
mustCall,
7780
mustCallAtLeast,
7881
hasMultiLocalhost,
82+
skipIfDumbTerminal,
7983
skipIfEslintMissing,
8084
canCreateSymLink,
8185
getCallSite,

test/parallel/test-console-clear.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
44
const assert = require('assert');
55

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

2020
// Fake TTY
21-
doTest(true, check);
21+
if (!common.isDumbTerminal) {
22+
doTest(true, check);
23+
}
2224
doTest(false, '');

test/parallel/test-readline-interface.js

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// Flags: --expose-internals
2323
'use strict';
2424
const common = require('../common');
25+
common.skipIfDumbTerminal();
2526

2627
const assert = require('assert');
2728
const readline = require('readline');

test/parallel/test-readline-position.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// Flags: --expose-internals
22
'use strict';
3-
require('../common');
3+
const common = require('../common');
44
const { internalBinding } = require('internal/test/binding');
55
const { PassThrough } = require('stream');
66
const readline = require('readline');
77
const assert = require('assert');
88

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

11+
common.skipIfDumbTerminal();
12+
1113
{
1214
const input = new PassThrough();
1315
const rl = readline.createInterface({

test/parallel/test-readline-tab-complete.js

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const assert = require('assert');
88
const EventEmitter = require('events').EventEmitter;
99
const { getStringWidth } = require('internal/util/inspect');
1010

11+
common.skipIfDumbTerminal();
12+
1113
// This test verifies that the tab completion supports unicode and the writes
1214
// are limited to the minimum.
1315
[

test/parallel/test-readline-undefined-columns.js

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const assert = require('assert');
55
const PassThrough = require('stream').PassThrough;
66
const readline = require('readline');
77

8+
common.skipIfDumbTerminal();
9+
810
// Checks that tab completion still works
911
// when output column size is undefined
1012

test/parallel/test-readline.js

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const { PassThrough } = require('stream');
44
const readline = require('readline');
55
const assert = require('assert');
66

7+
common.skipIfDumbTerminal();
8+
79
{
810
const input = new PassThrough();
911
const rl = readline.createInterface({

test/parallel/test-repl-editor.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
44
const assert = require('assert');
55
const repl = require('repl');
66
const ArrayStream = require('../common/arraystream');
77

8+
common.skipIfDumbTerminal();
9+
810
// \u001b[nG - Moves the cursor to n st column
911
// \u001b[0J - Clear screen
1012
// \u001b[0K - Clear to line end

test/parallel/test-repl-history-navigation.js

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const fs = require('fs');
1010
const path = require('path');
1111
const { inspect } = require('util');
1212

13+
common.skipIfDumbTerminal();
14+
1315
const tmpdir = require('../common/tmpdir');
1416
tmpdir.refresh();
1517

test/parallel/test-repl-load-multiline.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
'use strict';
2-
require('../common');
2+
const common = require('../common');
33
const ArrayStream = require('../common/arraystream');
44
const fixtures = require('../common/fixtures');
55
const assert = require('assert');
66
const repl = require('repl');
77

8+
common.skipIfDumbTerminal();
9+
810
const command = `.load ${fixtures.path('repl-load-multiline.js')}`;
911
const terminalCode = '\u001b[1G\u001b[0J \u001b[1G';
1012
const terminalCodeRegex = new RegExp(terminalCode.replace(/\[/g, '\\['), 'g');

test/parallel/test-repl-persistent-history.js

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const path = require('path');
1212
const os = require('os');
1313
const util = require('util');
1414

15+
common.skipIfDumbTerminal();
16+
1517
const tmpdir = require('../common/tmpdir');
1618
tmpdir.refresh();
1719

test/parallel/test-repl-preview.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const { Stream } = require('stream');
77
const { inspect } = require('util');
88

99
common.skipIfInspectorDisabled();
10+
common.skipIfDumbTerminal();
1011

1112
const PROMPT = 'repl > ';
1213

test/parallel/test-repl-programmatic-history.js

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const path = require('path');
1010
const os = require('os');
1111
const util = require('util');
1212

13+
common.skipIfDumbTerminal();
14+
1315
const tmpdir = require('../common/tmpdir');
1416
tmpdir.refresh();
1517

test/parallel/test-repl-reverse-search.js

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const fs = require('fs');
1010
const path = require('path');
1111
const { inspect } = require('util');
1212

13+
common.skipIfDumbTerminal();
1314
common.allowGlobals('aaaa');
1415

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

0 commit comments

Comments
 (0)