From 7e1a187df17b7ebad6ac977a374f0b138f98f43e Mon Sep 17 00:00:00 2001 From: Gibson Fahnestock Date: Wed, 18 Oct 2017 10:02:58 +0100 Subject: [PATCH] test: handle blank shells in test-os.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The shell in /etc/passwd can be blank, in which case the user is given the default shell. Handle this by only checking the shell contains a path separator if the string isn't empty. PR-URL: https://github.com/nodejs/node/pull/16287 Fixes: https://github.com/nodejs/node/issues/15684 Reviewed-By: Ben Noordhuis Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Tobias Nießen --- test/parallel/test-os.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-os.js b/test/parallel/test-os.js index 4246a769fdbe47..b35faeb7cd7bbe 100644 --- a/test/parallel/test-os.js +++ b/test/parallel/test-os.js @@ -208,7 +208,11 @@ if (common.isWindows) { } else { is.number(pwd.uid); is.number(pwd.gid); - assert.ok(pwd.shell.includes(path.sep)); + assert.strictEqual(typeof pwd.shell, 'string'); + // It's possible for /etc/passwd to leave the user's shell blank. + if (pwd.shell.length > 0) { + assert(pwd.shell.includes(path.sep)); + } assert.strictEqual(pwd.uid, pwdBuf.uid); assert.strictEqual(pwd.gid, pwdBuf.gid); assert.strictEqual(pwd.shell, pwdBuf.shell.toString('utf8'));