summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2017-02-10 23:26:25 -0800
committerJames M Snell <jasnell@gmail.com>2017-02-13 08:14:52 -0800
commitf2023d7b6f88d3e9c8fbcee0d2615afbc947f0ca (patch)
treea49b190fa84a4e22bbd14e927a74492082691f32 /test
parent93982c0a3d4487e90272bee47860e7dc61f8ee28 (diff)
downloadandroid-node-v8-f2023d7b6f88d3e9c8fbcee0d2615afbc947f0ca.tar.gz
android-node-v8-f2023d7b6f88d3e9c8fbcee0d2615afbc947f0ca.tar.bz2
android-node-v8-f2023d7b6f88d3e9c8fbcee0d2615afbc947f0ca.zip
test: refactor test-repl-sigint
* remove debugging code that prints child stdout * indexOf() -> includes() * improved messages on assertion failures PR-URL: https://github.com/nodejs/node/pull/11309 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>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-repl-sigint.js18
1 files changed, 8 insertions, 10 deletions
diff --git a/test/parallel/test-repl-sigint.js b/test/parallel/test-repl-sigint.js
index 5ee974aaea..61bc75cc6f 100644
--- a/test/parallel/test-repl-sigint.js
+++ b/test/parallel/test-repl-sigint.js
@@ -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.\n'), -1);
- assert.notStrictEqual(stdout.indexOf('42042\n'), -1);
+ assert.ok(
+ stdout.includes('Script execution interrupted.\n'),
+ `Expected stdout to contain "Script execution interrupted.", got ${stdout}`
+ );
+ assert.ok(
+ stdout.includes('42042\n'),
+ `Expected stdout to contain "42042", got ${stdout}`
+ );
});