From 5095b991c0d21c6381dfa1aea4ea4d076c0c84d7 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 f3c0082f553c1d..1bd7e01eeed4bf 100644 --- a/test/parallel/test-os.js +++ b/test/parallel/test-os.js @@ -161,7 +161,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'));