summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-03-08 12:21:35 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2019-03-25 16:28:07 +0100
commit97737fd5fb4a6b36c2e65905b8cf3518499a8a5e (patch)
tree0028cc7ca3c42d3474097f86d8b0c026a34d633d /test
parent96204c3c71f6cc571be56269ba9d584d615f0a06 (diff)
downloadandroid-node-v8-97737fd5fb4a6b36c2e65905b8cf3518499a8a5e.tar.gz
android-node-v8-97737fd5fb4a6b36c2e65905b8cf3518499a8a5e.tar.bz2
android-node-v8-97737fd5fb4a6b36c2e65905b8cf3518499a8a5e.zip
repl: fix terminal default setting
This makes sure that the described default behavior for the `terminal` option is actually always used and not only when running the REPL as standalone program. The options code is now logically combined instead of being spread out in the big REPL constructor. PR-URL: https://github.com/nodejs/node/pull/26518 Reviewed-By: Lance Ball <lball@redhat.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-repl-colors.js3
-rw-r--r--test/parallel/test-repl-envvars.js8
2 files changed, 10 insertions, 1 deletions
diff --git a/test/parallel/test-repl-colors.js b/test/parallel/test-repl-colors.js
index f484f57945..dd1bdb1a08 100644
--- a/test/parallel/test-repl-colors.js
+++ b/test/parallel/test-repl-colors.js
@@ -19,6 +19,8 @@ inout._write = function(s, _, cb) {
};
const repl = new REPLServer({ input: inout, output: inout, useColors: true });
+inout.isTTY = true;
+const repl2 = new REPLServer({ input: inout, output: inout });
process.on('exit', function() {
// https://github.com/nodejs/node/pull/16485#issuecomment-350428638
@@ -28,4 +30,5 @@ process.on('exit', function() {
strictEqual(output.includes(`'\u001b[32m\\'string\\'\u001b[39m'`), false);
strictEqual(inspect.defaultOptions.colors, false);
strictEqual(repl.writer.options.colors, true);
+ strictEqual(repl2.writer.options.colors, true);
});
diff --git a/test/parallel/test-repl-envvars.js b/test/parallel/test-repl-envvars.js
index 6679cd6cd7..4fab77b7c0 100644
--- a/test/parallel/test-repl-envvars.js
+++ b/test/parallel/test-repl-envvars.js
@@ -38,19 +38,25 @@ const tests = [
function run(test) {
const env = test.env;
const expected = test.expected;
+
const opts = {
terminal: true,
input: new stream.Readable({ read() {} }),
output: new stream.Writable({ write() {} })
};
- REPL.createInternalRepl(env, opts, function(err, repl) {
+ Object.assign(process.env, env);
+
+ REPL.createInternalRepl(process.env, opts, function(err, repl) {
assert.ifError(err);
assert.strictEqual(repl.terminal, expected.terminal,
`Expected ${inspect(expected)} with ${inspect(env)}`);
assert.strictEqual(repl.useColors, expected.useColors,
`Expected ${inspect(expected)} with ${inspect(env)}`);
+ for (const key of Object.keys(env)) {
+ delete process.env[key];
+ }
repl.close();
});
}