diff --git a/scripts/dev.test.ts b/scripts/dev.test.ts index 0d059b7ed..5907efebe 100644 --- a/scripts/dev.test.ts +++ b/scripts/dev.test.ts @@ -658,16 +658,31 @@ describe('dev scheduler local worker cleanup', () => { describe('dev scheduler Rust build env', () => { test('local dev Rust env enables available sccache wrapper', () => { - const env = buildLocalRustProcessEnv( - { - RUSTC_WRAPPER: '/usr/bin/sccache', - CARGO_BUILD_RUSTC_WRAPPER: 'sccache', - }, - { log: false, sccacheAvailable: true }, + const originalPlatform = Object.getOwnPropertyDescriptor( + process, + 'platform', ); + Object.defineProperty(process, 'platform', { + configurable: true, + value: 'win32', + }); - expect(env.RUSTC_WRAPPER).toBe('sccache'); - expect(env.CARGO_BUILD_RUSTC_WRAPPER).toBe(env.RUSTC_WRAPPER); + try { + const env = buildLocalRustProcessEnv( + { + RUSTC_WRAPPER: '/usr/bin/sccache', + CARGO_BUILD_RUSTC_WRAPPER: 'sccache', + }, + { log: false, sccacheAvailable: true }, + ); + + expect(env.RUSTC_WRAPPER).toBe('sccache'); + expect(env.CARGO_BUILD_RUSTC_WRAPPER).toBe(env.RUSTC_WRAPPER); + } finally { + if (originalPlatform) { + Object.defineProperty(process, 'platform', originalPlatform); + } + } }); test('local dev Rust env keeps healthy custom wrapper untouched', () => {