From 3791b37315abc8405b84a71a285d9f0874154e57 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 6 Apr 2018 12:22:03 +0200 Subject: [PATCH 1/3] test: add check for root user Currently this test fails if run as the root user: Mismatched innerFn function calls. Expected exactly 62, actual 42. The motivation for this is that when building node in a docker container it is convenient to be able to build as root. --- .../test-child-process-spawnsync-validation-errors.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-child-process-spawnsync-validation-errors.js b/test/parallel/test-child-process-spawnsync-validation-errors.js index c12476c0422d0f..d0bc2fd46002c3 100644 --- a/test/parallel/test-child-process-spawnsync-validation-errors.js +++ b/test/parallel/test-child-process-spawnsync-validation-errors.js @@ -3,11 +3,12 @@ const common = require('../common'); const assert = require('assert'); const spawnSync = require('child_process').spawnSync; const signals = process.binding('constants').os.signals; +const rootUser = process.getuid() === 0; let invalidArgTypeError; let invalidArgTypeErrorCount = 62; -if (common.isWindows) { +if (common.isWindows || rootUser) { invalidArgTypeError = common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 42); } else { @@ -64,7 +65,7 @@ function fail(option, value, message) { if (!common.isWindows) { { // Validate the uid option - if (process.getuid() !== 0) { + if (!rootUser) { pass('uid', undefined); pass('uid', null); pass('uid', process.getuid()); From 4768a54db8025eb31a236b24581441338ff3b9f3 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 10 Apr 2018 07:21:22 +0200 Subject: [PATCH 2/3] squash: clean up --- ...ild-process-spawnsync-validation-errors.js | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/test/parallel/test-child-process-spawnsync-validation-errors.js b/test/parallel/test-child-process-spawnsync-validation-errors.js index d0bc2fd46002c3..e150d7b9748139 100644 --- a/test/parallel/test-child-process-spawnsync-validation-errors.js +++ b/test/parallel/test-child-process-spawnsync-validation-errors.js @@ -5,17 +5,9 @@ const spawnSync = require('child_process').spawnSync; const signals = process.binding('constants').os.signals; const rootUser = process.getuid() === 0; -let invalidArgTypeError; -let invalidArgTypeErrorCount = 62; - -if (common.isWindows || rootUser) { - invalidArgTypeError = - common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 42); -} else { - invalidArgTypeError = - common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, - invalidArgTypeErrorCount); -} +const invalidArgTypeError = common.expectsError( + { code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, + common.isWindows || rootUser ? 42 : 62); const invalidRangeError = common.expectsError({ code: 'ERR_OUT_OF_RANGE', type: RangeError }, 20); @@ -79,9 +71,6 @@ if (!common.isWindows) { fail('uid', Infinity, invalidArgTypeError); fail('uid', 3.1, invalidArgTypeError); fail('uid', -3.1, invalidArgTypeError); - } else { - // Decrement invalidArgTypeErrorCount if validation isn't possible - invalidArgTypeErrorCount -= 10; } } @@ -101,9 +90,6 @@ if (!common.isWindows) { fail('gid', Infinity, invalidArgTypeError); fail('gid', 3.1, invalidArgTypeError); fail('gid', -3.1, invalidArgTypeError); - } else { - // Decrement invalidArgTypeErrorCount if validation isn't possible - invalidArgTypeErrorCount -= 10; } } } From dcbcd5c407aa347ecb8ed6072e839cbf311a57ec Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 10 Apr 2018 14:21:33 +0200 Subject: [PATCH 3/3] squash: add windows check to setting of rootUser --- test/parallel/test-child-process-spawnsync-validation-errors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-child-process-spawnsync-validation-errors.js b/test/parallel/test-child-process-spawnsync-validation-errors.js index e150d7b9748139..17545d4af7bf50 100644 --- a/test/parallel/test-child-process-spawnsync-validation-errors.js +++ b/test/parallel/test-child-process-spawnsync-validation-errors.js @@ -3,7 +3,7 @@ const common = require('../common'); const assert = require('assert'); const spawnSync = require('child_process').spawnSync; const signals = process.binding('constants').os.signals; -const rootUser = process.getuid() === 0; +const rootUser = common.isWindows ? false : process.getuid() === 0; const invalidArgTypeError = common.expectsError( { code: 'ERR_INVALID_ARG_TYPE', type: TypeError },