From 596f714a7eb2add5f60139f154cf8a86d72e3b14 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Wed, 10 Dec 2025 09:05:34 -0800 Subject: [PATCH] fix(NODE-7311): Replace process.platform with os.platform() --- src/cmap/auth/gssapi.ts | 3 ++- src/cmap/handshake/client_metadata.ts | 2 +- test/benchmarks/driver_bench/src/main.mts | 2 +- .../node-specific/examples/change_streams.test.js | 3 ++- test/integration/node-specific/ipv6.test.ts | 4 ++-- test/integration/uri-options/uri.test.ts | 3 ++- test/manual/kerberos.test.ts | 3 ++- test/manual/tls_support.test.ts | 3 ++- test/tools/runner/filters/client_encryption_filter.ts | 3 ++- test/tools/runner/filters/os_filter.ts | 4 +++- test/tools/runner/hooks/configuration.ts | 3 ++- test/unit/cmap/handshake/client_metadata.test.ts | 10 +++++----- 12 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/cmap/auth/gssapi.ts b/src/cmap/auth/gssapi.ts index 430b97d213f..d18cb6b360e 100644 --- a/src/cmap/auth/gssapi.ts +++ b/src/cmap/auth/gssapi.ts @@ -1,4 +1,5 @@ import * as dns from 'dns'; +import * as os from 'os'; import { getKerberos, type Kerberos, type KerberosClient } from '../../deps'; import { MongoInvalidArgumentError, MongoMissingCredentialsError } from '../../error'; @@ -97,7 +98,7 @@ async function makeKerberosClient(authContext: AuthContext): Promise `\n- cpu: ${platform.name}`, `- cores: ${platform.cores}`, `- arch: ${os.arch()}`, - `- os: ${process.platform} (${os.release()})`, + `- os: ${os.platform()} (${os.release()})`, `- ram: ${platform.ram}`, `- node: ${process.version}`, `- running ${total} benchmarks`, diff --git a/test/integration/node-specific/examples/change_streams.test.js b/test/integration/node-specific/examples/change_streams.test.js index 90737e2ddfc..90020f33d5e 100644 --- a/test/integration/node-specific/examples/change_streams.test.js +++ b/test/integration/node-specific/examples/change_streams.test.js @@ -4,9 +4,10 @@ const { setTimeout } = require('timers'); const setupDatabase = require('../../shared').setupDatabase; const expect = require('chai').expect; +const os = require('os'); // TODO: NODE-3819: Unskip flaky MacOS/Windows tests. -const maybeDescribe = process.platform !== 'linux' ? describe.skip : describe; +const maybeDescribe = os.platform() !== 'linux' ? describe.skip : describe; maybeDescribe('examples(change-stream):', function () { let client; let db; diff --git a/test/integration/node-specific/ipv6.test.ts b/test/integration/node-specific/ipv6.test.ts index b3b76c85176..09157633b87 100644 --- a/test/integration/node-specific/ipv6.test.ts +++ b/test/integration/node-specific/ipv6.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import * as net from 'net'; -import * as process from 'process'; +import * as os from 'os'; import * as sinon from 'sinon'; import { @@ -16,7 +16,7 @@ describe('IPv6 Addresses', () => { beforeEach(async function () { if ( - process.platform === 'linux' || + os.platform() === 'linux' || this.configuration.topologyType !== TopologyType.ReplicaSetWithPrimary ) { if (this.currentTest) { diff --git a/test/integration/uri-options/uri.test.ts b/test/integration/uri-options/uri.test.ts index dde75c48f00..6734a6ccb32 100644 --- a/test/integration/uri-options/uri.test.ts +++ b/test/integration/uri-options/uri.test.ts @@ -1,4 +1,5 @@ import { expect } from 'chai'; +import * as os from 'os'; import * as sinon from 'sinon'; import { Topology } from '../../../src/sdam/topology'; @@ -45,7 +46,7 @@ describe('URI', function () { metadata: { requires: { topology: 'single' } }, test: async function () { - if (process.platform === 'win32') { + if (os.platform() === 'win32') { return; } diff --git a/test/manual/kerberos.test.ts b/test/manual/kerberos.test.ts index 92111b25853..24007128f2c 100644 --- a/test/manual/kerberos.test.ts +++ b/test/manual/kerberos.test.ts @@ -1,5 +1,6 @@ import * as chai from 'chai'; import { promises as dns } from 'dns'; +import * as os from 'os'; import * as sinon from 'sinon'; import { MongoClient } from '../../src'; @@ -50,7 +51,7 @@ describe('Kerberos', function () { context('when passing in CANONICALIZE_HOST_NAME', function () { beforeEach(function () { - if (process.platform === 'darwin') { + if (os.platform() === 'darwin') { this.currentTest.skipReason = 'DNS does not resolve with proper CNAME record on evergreen MacOS'; this.skip(); diff --git a/test/manual/tls_support.test.ts b/test/manual/tls_support.test.ts index 4db67b1203c..4c3bffd54f8 100644 --- a/test/manual/tls_support.test.ts +++ b/test/manual/tls_support.test.ts @@ -4,6 +4,7 @@ import * as tls from 'node:tls'; import { expect } from 'chai'; import { promises as fs } from 'fs'; import ConnectionString from 'mongodb-connection-string-url'; +import * as os from 'os'; import * as sinon from 'sinon'; import { MongoClient, type MongoClientOptions, MongoServerSelectionError } from '../../src'; @@ -36,7 +37,7 @@ describe('TLS Support', function () { beforeEach(function () { if ( this.currentTest?.title === 'should connect with tls via url options' && - process.platform === 'win32' + os.platform() === 'win32' ) { this.currentTest.skipReason = 'TODO(NODE-5803): Un-skip Windows TLS tests via URL'; return this.skip(); diff --git a/test/tools/runner/filters/client_encryption_filter.ts b/test/tools/runner/filters/client_encryption_filter.ts index 8f51f3ab2f1..5a168816831 100644 --- a/test/tools/runner/filters/client_encryption_filter.ts +++ b/test/tools/runner/filters/client_encryption_filter.ts @@ -1,4 +1,5 @@ import { readFile } from 'fs/promises'; +import * as os from 'os'; import { dirname, resolve } from 'path'; import * as process from 'process'; import { satisfies } from 'semver'; @@ -74,7 +75,7 @@ export class ClientSideEncryptionFilter extends Filter { } // TODO(NODE-3401): unskip csfle tests on windows - if (process.env.TEST_CSFLE && process.platform !== 'win32') { + if (process.env.TEST_CSFLE && os.platform() !== 'win32') { if (this.version == null) { throw new Error('FLE tests must run, but mongodb client encryption was not installed.'); } diff --git a/test/tools/runner/filters/os_filter.ts b/test/tools/runner/filters/os_filter.ts index 50e6201ed1e..9137db9e4d3 100755 --- a/test/tools/runner/filters/os_filter.ts +++ b/test/tools/runner/filters/os_filter.ts @@ -1,3 +1,5 @@ +import * as os from 'os'; + import { Filter } from './filter'; /** @@ -17,7 +19,7 @@ export class OSFilter extends Filter { constructor() { super(); // Get environmental variables that are known - this.platform = process.platform; + this.platform = os.platform(); } filter(test: { metadata?: MongoDBMetadataUI }) { diff --git a/test/tools/runner/hooks/configuration.ts b/test/tools/runner/hooks/configuration.ts index 9fdc5c6c91c..d8c7d375dbe 100644 --- a/test/tools/runner/hooks/configuration.ts +++ b/test/tools/runner/hooks/configuration.ts @@ -5,6 +5,7 @@ require('source-map-support').install({ hookRequire: true }); +import * as os from 'os'; import { MongoClient } from '../../../../src'; import { AlpineTestConfiguration, AstrolabeTestConfiguration, TestConfiguration } from '../config'; import { getEnvironmentalOptions } from '../../utils'; @@ -151,7 +152,7 @@ const testConfigBeforeHook = async function () { topology: this.configuration.topologyType, version: this.configuration.buildInfo.version, node: process.version, - os: process.platform, + os: os.platform(), alpineLinux: Boolean(process.env.ALPINE), cryptdUri: process.env.MONGOCRYPTD_URI, pid: process.pid, diff --git a/test/unit/cmap/handshake/client_metadata.test.ts b/test/unit/cmap/handshake/client_metadata.test.ts index 87069dacc30..afdd47cad2d 100644 --- a/test/unit/cmap/handshake/client_metadata.test.ts +++ b/test/unit/cmap/handshake/client_metadata.test.ts @@ -153,7 +153,7 @@ describe('client metadata module', () => { }, os: { type: os.type(), - name: process.platform, + name: os.platform(), architecture: process.arch, version: os.release() }, @@ -179,7 +179,7 @@ describe('client metadata module', () => { }, os: { type: os.type(), - name: process.platform, + name: os.platform(), architecture: process.arch, version: os.release() }, @@ -203,7 +203,7 @@ describe('client metadata module', () => { }, os: { type: os.type(), - name: process.platform, + name: os.platform(), architecture: process.arch, version: os.release() }, @@ -229,7 +229,7 @@ describe('client metadata module', () => { }, os: { type: os.type(), - name: process.platform, + name: os.platform(), architecture: process.arch, version: os.release() }, @@ -248,7 +248,7 @@ describe('client metadata module', () => { }, os: { type: os.type(), - name: process.platform, + name: os.platform(), architecture: process.arch, version: os.release() },