Skip to content

Commit 8db3c77

Browse files
TrottMylesBorins
authored andcommitted
test: refactor test-repl-sigint-nested-eval
* remove debugging code that prints child stdout * indexOf() -> includes() * improved messages on assertion failures PR-URL: #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>
1 parent 874ef9d commit 8db3c77

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

‎test/parallel/test-repl-sigint-nested-eval.js‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,10 @@ const child = spawn(process.execPath, [ '-i' ], {
1717

1818
letstdout='';
1919
child.stdout.setEncoding('utf8');
20-
child.stdout.pipe(process.stdout);
2120
child.stdout.on('data',function(c){
2221
stdout+=c;
2322
});
2423

25-
child.stdin.write=((original)=>{
26-
return(chunk)=>{
27-
process.stderr.write(chunk);
28-
returnoriginal.call(child.stdin,chunk);
29-
};
30-
})(child.stdin.write);
31-
3224
child.stdout.once('data',common.mustCall(()=>{
3325
process.on('SIGUSR2',common.mustCall(()=>{
3426
process.kill(child.pid,'SIGINT');
@@ -45,6 +37,12 @@ child.stdout.once('data', common.mustCall(() => {
4537

4638
child.on('close',function(code){
4739
assert.strictEqual(code,0);
48-
assert.notStrictEqual(stdout.indexOf('Script execution interrupted.'),-1);
49-
assert.notStrictEqual(stdout.indexOf('foobar'),-1);
40+
assert.ok(
41+
stdout.includes('Script execution interrupted.'),
42+
`Expected stdout to contain "Script execution interrupted.", got ${stdout}`
43+
);
44+
assert.ok(
45+
stdout.includes('foobar'),
46+
`Expected stdout to contain "foobar", got ${stdout}`
47+
);
5048
});

0 commit comments

Comments
 (0)