mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
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: https://github.com/nodejs/node/pull/33165
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
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({
|
|
terminal: true,
|
|
input: input,
|
|
prompt: ''
|
|
});
|
|
|
|
const tests = [
|
|
[1, 'a'],
|
|
[2, 'ab'],
|
|
[2, '丁']
|
|
];
|
|
|
|
// The non-ICU JS implementation of character width calculation is only aware
|
|
// of the wide/narrow distinction. Only test these more advanced cases when
|
|
// ICU is available.
|
|
if (internalBinding('config').hasIntl) {
|
|
tests.push(
|
|
[0, '\u0301'], // COMBINING ACUTE ACCENT
|
|
[1, 'a\u0301'], // á
|
|
[0, '\u20DD'], // COMBINING ENCLOSING CIRCLE
|
|
[2, 'a\u20DDb'], // a⃝b
|
|
[0, '\u200E'] // LEFT-TO-RIGHT MARK
|
|
);
|
|
}
|
|
|
|
for (const [cursor, string] of tests) {
|
|
rl.write(string);
|
|
assert.strictEqual(rl.getCursorPos().cols, cursor);
|
|
rl.write(null, ctrlU);
|
|
}
|
|
}
|