Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1329eb4

Browse filesBrowse files
cjihrigItalo A. Casas
authored andcommitted
test: allow testing uid and gid separately
This commit lets the uid and gid options of spawn() to be tested independently of one another based on the user's uid and gid. Fixes: #10646 PR-URL: #10647 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 4aa32c1 commit 1329eb4
Copy full SHA for 1329eb4

File tree

Expand file treeCollapse file tree

1 file changed

+10
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-12
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-child-process-uid-gid.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-uid-gid.js
+10-12Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22
const common = require('../common');
33
const assert = require('assert');
44
const spawn = require('child_process').spawn;
5-
6-
if (!common.isWindows && process.getuid() === 0) {
7-
common.skip('as this test should not be run as `root`');
8-
return;
9-
}
10-
115
const expectedError = common.isWindows ? /\bENOTSUP\b/ : /\bEPERM\b/;
126

13-
assert.throws(() => {
14-
spawn('echo', ['fhqwhgads'], {uid: 0});
15-
}, expectedError);
7+
if (common.isWindows || process.getuid() !== 0) {
8+
assert.throws(() => {
9+
spawn('echo', ['fhqwhgads'], {uid: 0});
10+
}, expectedError);
11+
}
1612

17-
assert.throws(() => {
18-
spawn('echo', ['fhqwhgads'], {gid: 0});
19-
}, expectedError);
13+
if (common.isWindows || !process.getgroups().some((gid) => gid === 0)) {
14+
assert.throws(() => {
15+
spawn('echo', ['fhqwhgads'], {gid: 0});
16+
}, expectedError);
17+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.