test: refactor test-repl-sigint-nested-eval
* remove debugging code that prints child stdout * indexOf() -> includes() * improved messages on assertion failures PR-URL: https://github.com/nodejs/node/pull/11303 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
parent
e34ee1d2c9
commit
4762791fe2
@ -17,18 +17,10 @@ const child = spawn(process.execPath, [ '-i' ], {
|
||||
|
||||
let stdout = '';
|
||||
child.stdout.setEncoding('utf8');
|
||||
child.stdout.pipe(process.stdout);
|
||||
child.stdout.on('data', function(c) {
|
||||
stdout += c;
|
||||
});
|
||||
|
||||
child.stdin.write = ((original) => {
|
||||
return (chunk) => {
|
||||
process.stderr.write(chunk);
|
||||
return original.call(child.stdin, chunk);
|
||||
};
|
||||
})(child.stdin.write);
|
||||
|
||||
child.stdout.once('data', common.mustCall(() => {
|
||||
process.on('SIGUSR2', common.mustCall(() => {
|
||||
process.kill(child.pid, 'SIGINT');
|
||||
@ -45,6 +37,12 @@ child.stdout.once('data', common.mustCall(() => {
|
||||
|
||||
child.on('close', function(code) {
|
||||
assert.strictEqual(code, 0);
|
||||
assert.notStrictEqual(stdout.indexOf('Script execution interrupted.'), -1);
|
||||
assert.notStrictEqual(stdout.indexOf('foobar'), -1);
|
||||
assert.ok(
|
||||
stdout.includes('Script execution interrupted.'),
|
||||
`Expected stdout to contain "Script execution interrupted.", got ${stdout}`
|
||||
);
|
||||
assert.ok(
|
||||
stdout.includes('foobar'),
|
||||
`Expected stdout to contain "foobar", got ${stdout}`
|
||||
);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user