From 8ec342e1f77208fe433b8a32087c4beeb99fd8f7 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 20 Dec 2017 12:31:22 -0800 Subject: [PATCH 1/2] test: refactor test-repl-definecommand The test was writing to both REPL input and output but only checking output. Sending output to both streams seems like it was an error. --- test/parallel/test-repl-definecommand.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-repl-definecommand.js b/test/parallel/test-repl-definecommand.js index b6368bbd940d50..d39884869532b1 100644 --- a/test/parallel/test-repl-definecommand.js +++ b/test/parallel/test-repl-definecommand.js @@ -23,22 +23,28 @@ r.defineCommand('say1', { help: 'help for say1', action: function(thing) { output = ''; - this.write(`hello ${thing}`); + this.output.write(`hello ${thing}\n`); this.displayPrompt(); } }); r.defineCommand('say2', function() { output = ''; - this.write('hello from say2'); + this.output.write('hello from say2\n'); this.displayPrompt(); }); inputStream.write('.help\n'); -assert(/\n\.say1 help for say1\n/.test(output), - 'help for say1 not present'); +assert.ok(/\n\.say1 help for say1\n/.test(output), + 'help for say1 not present'); assert(/\n\.say2\n/.test(output), 'help for say2 not present'); inputStream.write('.say1 node developer\n'); -assert(/> hello node developer/.test(output), 'say1 outputted incorrectly'); +assert.ok(output.startsWith('hello node developer\n'), + `say1 output starts incorrectly: "${output}"`); +assert.ok(output.includes('> '), + `say1 output does not include prompt: "${output}"`); inputStream.write('.say2 node developer\n'); -assert(/> hello from say2/.test(output), 'say2 outputted incorrectly'); +assert.ok(output.startsWith('hello from say2\n'), + `say2 output starts incorrectly: "${output}"`); +assert.ok(output.includes('> '), + `say2 output does not include prompt: "${output}"`); From 309ab33b49fc23eb629a46a205552686daab0e7b Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 21 Dec 2017 10:19:54 -0800 Subject: [PATCH 2/2] Update test-repl-definecommand.js --- test/parallel/test-repl-definecommand.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-repl-definecommand.js b/test/parallel/test-repl-definecommand.js index d39884869532b1..efa22ed56f740f 100644 --- a/test/parallel/test-repl-definecommand.js +++ b/test/parallel/test-repl-definecommand.js @@ -35,8 +35,8 @@ r.defineCommand('say2', function() { }); inputStream.write('.help\n'); -assert.ok(/\n\.say1 help for say1\n/.test(output), - 'help for say1 not present'); +assert(/\n\.say1 help for say1\n/.test(output), + 'help for say1 not present'); assert(/\n\.say2\n/.test(output), 'help for say2 not present'); inputStream.write('.say1 node developer\n'); assert.ok(output.startsWith('hello node developer\n'),