1'use strict'; 2const common = require('../common'); 3const assert = require('assert'); 4const spawn = require('child_process').spawn; 5const expectedError = common.isWindows ? /\bENOTSUP\b/ : /\bEPERM\b/; 6 7if (common.isIBMi) 8 common.skip('IBMi has a different behavior'); 9 10if (common.isWindows || process.getuid() !== 0) { 11 assert.throws(() => { 12 spawn('echo', ['fhqwhgads'], { uid: 0 }); 13 }, expectedError); 14} 15 16if (common.isWindows || !process.getgroups().some((gid) => gid === 0)) { 17 assert.throws(() => { 18 spawn('echo', ['fhqwhgads'], { gid: 0 }); 19 }, expectedError); 20} 21