Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d596803
doc: add path rules and validation for export targets in package.json
0hmX Jun 9, 2025
893999e
src: replace V8 Fast API todo comment with note comment
dario-piotrowicz Jun 9, 2025
a4d7560
test: close FileHandle objects in tests explicitly
jasnell Jun 9, 2025
713fbad
test_runner: support object property mocking
idango10 Jun 9, 2025
4347ce3
src: add new CopyUtimes function to reduce code duplication
dario-piotrowicz Jun 9, 2025
dc10238
deps: update zlib to 1.3.1-470d3a2
nodejs-github-bot Jun 10, 2025
80eac14
deps: update simdjson to 3.13.0
nodejs-github-bot Jun 10, 2025
3aa2762
deps: update sqlite to 3.50.1
nodejs-github-bot Jun 10, 2025
181014a
test: cleanup status files
panva Jun 10, 2025
e9c6fa5
src: replace std::array with static arrays in contextify
mertcanaltin Jun 10, 2025
85f062c
test: deflake async-hooks/test-improper-order on AIX
bakigul1 Jun 3, 2025
7e34aa4
test: skip tests failing when run under root
LiviaMedeiros Jun 10, 2025
839964e
fs: allow correct handling of burst in fs-events with AsyncIterator
pipobscure Jun 10, 2025
450f481
deps: update amaro to 1.0.0
nodejs-github-bot Jun 11, 2025
76e3c8a
test: update WPT for es-exceptions to 2f96fa1996
nodejs-github-bot Jun 11, 2025
aa657f0
test: split indirect eval import tests
legendecas Jun 11, 2025
a3c7a63
module: allow cycles in require() in the CJS handling in ESM loader
joyeecheung Jun 11, 2025
9b28f40
module: remove experimental warning from type stripping
marco-ippolito Jun 11, 2025
fa089d6
test: update WPT for dom/abort to dc928169ee
nodejs-github-bot Jun 11, 2025
94e53d4
test: update WPT for urlpattern to 3ffda23e5a
nodejs-github-bot Jun 1, 2025
b1f60d2
http2: add diagnostics channel 'http2.server.stream.close'
RaisinTen Jun 11, 2025
b11da11
http2: fix DEP0194 message
climba03003 Jun 11, 2025
afbaf92
tools: improve release proposal linter
aduh95 Jun 11, 2025
6390f70
lib,src: support DOMException ser-des
legendecas Jun 11, 2025
b6760b3
esm: syncify default path of `ModuleLoader.load`
JakobJingleheimer Jun 11, 2025
ffff8ce
typings: add ZSTD_COMPRESS, ZSTD_DECOMPRESS to internalBinding
nektro Jun 12, 2025
45f7d16
module: refactor commonjs typescript loader
marco-ippolito Jun 12, 2025
ff8a369
module: fix typescript import.meta.main
marco-ippolito Jun 12, 2025
c1f9791
tools: edit commit-queue workflow file
aduh95 Jun 12, 2025
1cc77c7
doc: punctuation fix for Node-API versioning clarification
jiacai2050 Jun 12, 2025
268c8c1
tools: remove config.status under `make distclean`
Renegade334 Jun 12, 2025
b22e970
tools: switch to `@stylistic/eslint-plugin`
targos Jun 13, 2025
ec808b3
test: use `common.skipIfInspectorDisabled()` to skip tests
dario-piotrowicz Jun 13, 2025
dfb0144
src: enhance error messages for unknown options
pmarchini Jun 13, 2025
e6a1787
tools: bump brace-expansion from 1.1.11 to 1.1.12 in /tools/eslint
dependabot[bot] Jun 14, 2025
dc2f23e
tools: bump `brace-expansion` in `/tools/clang-format`
dependabot[bot] Jun 14, 2025
ef0230a
url: add fileURLToPathBuffer API
jasnell Jun 12, 2025
b7e488c
test: refactor repl tab complete tests
dario-piotrowicz Jun 15, 2025
c39d570
test: reduce the use of private symbols in test-events-once.js
kt3k Jun 15, 2025
17df800
typings: add Atomics primordials
Renegade334 Jun 4, 2025
704b1fa
test: add tests for REPL custom evals
dario-piotrowicz Jun 15, 2025
841609a
doc: add islandryu to collaborators
islandryu Jun 16, 2025
8aa0513
2025-06-17, Version 24.3.0 (Current)
nodejs-github-bot Jun 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: refactor repl tab complete tests
refactor the test/parallel/test-repl-tab-complete.js file by:
 - making the tests in the file self-contained
   (instead of all of them sharing the same REPL instance and
   constantly calling `.clear` on it)
 - using the test runner with appropriate descriptions to make
   clearer what is being tested
 - extracting some tests in their own js test files
   (to increase isolation of the tests and help with issues such
   as flakiness)

PR-URL: #58636
Reviewed-By: Giovanni Bucci <github@puskin.it>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
dario-piotrowicz authored and targos committed Jun 16, 2025
commit b7e488c77f994130088dfef9aeefbe7de01033f7
73 changes: 73 additions & 0 deletions test/parallel/test-repl-tab-complete-buffer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
'use strict';

const common = require('../common');
const ArrayStream = require('../common/arraystream');
const { hijackStderr, restoreStderr } = require('../common/hijackstdio');
const assert = require('assert');

const repl = require('repl');

const input = new ArrayStream();
const replServer = repl.start({
prompt: '',
input,
output: process.stdout,
allowBlockingCompletions: true,
});

// Some errors are passed to the domain, but do not callback
replServer._domain.on('error', assert.ifError);

for (const type of [
Array,
Buffer,

Uint8Array,
Uint16Array,
Uint32Array,

Uint8ClampedArray,
Int8Array,
Int16Array,
Int32Array,
Float32Array,
Float64Array,
]) {
input.run(['.clear']);

if (type === Array) {
input.run([
'var ele = [];',
'for (let i = 0; i < 1e6 + 1; i++) ele[i] = 0;',
'ele.biu = 1;',
]);
} else if (type === Buffer) {
input.run(['var ele = Buffer.alloc(1e6 + 1); ele.biu = 1;']);
} else {
input.run([`var ele = new ${type.name}(1e6 + 1); ele.biu = 1;`]);
}

hijackStderr(common.mustNotCall());
replServer.complete(
'ele.',
common.mustCall((err, data) => {
restoreStderr();
assert.ifError(err);

const ele =
type === Array ? [] : type === Buffer ? Buffer.alloc(0) : new type(0);

assert.strictEqual(data[0].includes('ele.biu'), true);

data[0].forEach((key) => {
if (!key || key === 'ele.biu') return;
assert.notStrictEqual(ele[key.slice(4)], undefined);
});
})
);
}

// check Buffer.prototype.length not crashing.
// Refs: https://github.com/nodejs/node/pull/11961
input.run(['.clear']);
replServer.complete('Buffer.prototype.', common.mustCall());
75 changes: 75 additions & 0 deletions test/parallel/test-repl-tab-complete-custom-completer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
'use strict';

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

const repl = require('repl');

const putIn = new ArrayStream();

// To test custom completer function.
// Sync mode.
{
const customCompletions = 'aaa aa1 aa2 bbb bb1 bb2 bb3 ccc ddd eee'.split(' ');
const testCustomCompleterSyncMode = repl.start({
prompt: '',
input: putIn,
output: putIn,
completer: function completer(line) {
const hits = customCompletions.filter((c) => c.startsWith(line));
// Show all completions if none found.
return [hits.length ? hits : customCompletions, line];
}
});

// On empty line should output all the custom completions
// without complete anything.
testCustomCompleterSyncMode.complete('', common.mustCall((error, data) => {
assert.deepStrictEqual(data, [
customCompletions,
'',
]);
}));

// On `a` should output `aaa aa1 aa2` and complete until `aa`.
testCustomCompleterSyncMode.complete('a', common.mustCall((error, data) => {
assert.deepStrictEqual(data, [
'aaa aa1 aa2'.split(' '),
'a',
]);
}));
}

// To test custom completer function.
// Async mode.
{
const customCompletions = 'aaa aa1 aa2 bbb bb1 bb2 bb3 ccc ddd eee'.split(' ');
const testCustomCompleterAsyncMode = repl.start({
prompt: '',
input: putIn,
output: putIn,
completer: function completer(line, callback) {
const hits = customCompletions.filter((c) => c.startsWith(line));
// Show all completions if none found.
callback(null, [hits.length ? hits : customCompletions, line]);
}
});

// On empty line should output all the custom completions
// without complete anything.
testCustomCompleterAsyncMode.complete('', common.mustCall((error, data) => {
assert.deepStrictEqual(data, [
customCompletions,
'',
]);
}));

// On `a` should output `aaa aa1 aa2` and complete until `aa`.
testCustomCompleterAsyncMode.complete('a', common.mustCall((error, data) => {
assert.deepStrictEqual(data, [
'aaa aa1 aa2'.split(' '),
'a',
]);
}));
}
80 changes: 80 additions & 0 deletions test/parallel/test-repl-tab-complete-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
'use strict';

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

const { isMainThread } = require('worker_threads');

if (!isMainThread) {
common.skip('process.chdir is not available in Workers');
}

const repl = require('repl');

const replServer = repl.start({
prompt: '',
input: new ArrayStream(),
output: process.stdout,
allowBlockingCompletions: true,
});

// Some errors are passed to the domain, but do not callback
replServer._domain.on('error', assert.ifError);

// Tab completion for files/directories
{
process.chdir(__dirname);

const readFileSyncs = ['fs.readFileSync("', 'fs.promises.readFileSync("'];
if (!common.isWindows) {
readFileSyncs.forEach((readFileSync) => {
const fixturePath = `${readFileSync}../fixtures/test-repl-tab-completion`;
replServer.complete(
fixturePath,
common.mustCall((err, data) => {
assert.strictEqual(err, null);
assert.ok(data[0][0].includes('.hiddenfiles'));
assert.ok(data[0][1].includes('hellorandom.txt'));
assert.ok(data[0][2].includes('helloworld.js'));
})
);

replServer.complete(
`${fixturePath}/hello`,
common.mustCall((err, data) => {
assert.strictEqual(err, null);
assert.ok(data[0][0].includes('hellorandom.txt'));
assert.ok(data[0][1].includes('helloworld.js'));
})
);

replServer.complete(
`${fixturePath}/.h`,
common.mustCall((err, data) => {
assert.strictEqual(err, null);
assert.ok(data[0][0].includes('.hiddenfiles'));
})
);

replServer.complete(
`${readFileSync}./xxxRandom/random`,
common.mustCall((err, data) => {
assert.strictEqual(err, null);
assert.strictEqual(data[0].length, 0);
})
);

const testPath = fixturePath.slice(0, -1);
replServer.complete(
testPath,
common.mustCall((err, data) => {
assert.strictEqual(err, null);
assert.ok(data[0][0].includes('test-repl-tab-completion'));
assert.strictEqual(data[1], path.basename(testPath));
})
);
});
}
}
51 changes: 39 additions & 12 deletions test/parallel/test-repl-tab-complete-on-editor-mode.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,48 @@
'use strict';

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

const stream = new ArrayStream();
const replServer = repl.start({
input: stream,
output: stream,
terminal: true,
});
// Tab completion in editor mode
{
const editorStream = new ArrayStream();
const editor = repl.start({
stream: editorStream,
terminal: true,
useColors: false
});

// Editor mode
replServer.write('.editor\n');
editorStream.run(['.clear']);
editorStream.run(['.editor']);

editor.completer('Uin', common.mustCall((_error, data) => {
assert.deepStrictEqual(data, [['Uint'], 'Uin']);
}));

editorStream.run(['.clear']);
editorStream.run(['.editor']);

editor.completer('var log = console.l', common.mustCall((_error, data) => {
assert.deepStrictEqual(data, [['console.log'], 'console.l']);
}));
}

// Regression test for https://github.com/nodejs/node/issues/43528
replServer.write('a');
replServer.write(null, { name: 'tab' }); // Should not throw
{
const stream = new ArrayStream();
const replServer = repl.start({
input: stream,
output: stream,
terminal: true,
});

// Editor mode
replServer.write('.editor\n');

replServer.write('a');
replServer.write(null, { name: 'tab' }); // Should not throw

replServer.close();
replServer.close();
}
Loading