test: add missing newlines to repl .exit writes

some tests write `.exit` into a repl server without
including a newline character (`\n`), such commands
are therefore simply not executed at all, the changes
here add the missing newlines and as a side effect
remove no longer necessary `end` calls

PR-URL: https://github.com/nodejs/node/pull/58041
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
This commit is contained in:
Dario Piotrowicz 2025-04-28 22:19:07 +02:00 committed by GitHub
parent 067a779f17
commit 53abd1a7e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 7 additions and 10 deletions

View File

@ -1,6 +1,6 @@
// Reference: https://github.com/nodejs/node/pull/7624
'use strict';
require('../common');
const common = require('../common');
const assert = require('assert');
const repl = require('repl');
const stream = require('stream');
@ -9,7 +9,8 @@ const r = initRepl();
r.input.emit('data', 'function a() { return 42; } (1)\n');
r.input.emit('data', 'a\n');
r.input.emit('data', '.exit');
r.input.emit('data', '.exit\n');
r.once('exit', common.mustCall());
const expected = '1\n[Function: a]\n';
const got = r.output.accumulator.join('');

View File

@ -23,5 +23,4 @@ child.on('exit', common.mustCall(() => {
}));
child.stdin.write('await import(\'./message.mjs\');\n');
child.stdin.write('.exit');
child.stdin.end();
child.stdin.write('.exit\n');

View File

@ -136,6 +136,5 @@ r4.close();
child.stdin.write(
'assert.ok(util.inspect(repl.repl, {depth: -1}).includes("REPLServer"));\n'
);
child.stdin.write('.exit');
child.stdin.end();
child.stdin.write('.exit\n');
}

View File

@ -20,5 +20,4 @@ child.on('exit', common.mustCall(() => {
child.stdin.write('const isObject = (obj) => obj.constructor === Object;\n');
child.stdin.write('isObject({});\n');
child.stdin.write(`require(${JSON.stringify(fixture)}).isObject({});\n`);
child.stdin.write('.exit');
child.stdin.end();
child.stdin.write('.exit\n');

View File

@ -23,5 +23,4 @@ child.on('exit', common.mustCall(() => {
}));
child.stdin.write('require("self_ref");\n');
child.stdin.write('.exit');
child.stdin.end();
child.stdin.write('.exit\n');