GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: getgroups() may contain duplicate GIDs · nodejs/node@a1cb699

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-process-getgroups.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-process-getgroups.js‎

Copy file name to clipboard
+12-6Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
'use strict';
22
const common = require('../common');
3-
const assert = require('assert');
4-
const exec = require('child_process').exec;
3+
4+
// Check `id -G` and `process.getgroups()` return same groups.
55

66
if (common.isOSX) {
77
common.skip('Output of `id -G` is unreliable on Darwin.');
88
return;
99
}
10+
const assert = require('assert');
11+
const exec = require('child_process').exec;
1012

1113
if (typeof process.getgroups === 'function') {
12-
const groups = process.getgroups();
14+
const groups = unique(process.getgroups());
1315
assert(Array.isArray(groups));
1416
assert(groups.length > 0);
1517
exec('id -G', function(err, stdout) {
16-
if (err) throw err;
17-
const real_groups = stdout.match(/\d+/g).map(Number);
18-
assert.strictEqual(groups.length, real_groups.length);
18+
assert.ifError(err);
19+
const real_groups = unique(stdout.match(/\d+/g).map(Number));
20+
assert.deepStrictEqual(groups, real_groups);
1921
check(groups, real_groups);
2022
check(real_groups, groups);
2123
});
@@ -24,3 +26,7 @@ if (typeof process.getgroups === 'function') {
2426
function check(a, b) {
2527
for (let i = 0; i < a.length; ++i) assert.notStrictEqual(b.indexOf(a[i]), -1);
2628
}
29+
30+
function unique(groups) {
31+
return [...new Set(groups)].sort();
32+
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.