From 2315883b1f1f2c3befbc67815d703e1817a54f38 Mon Sep 17 00:00:00 2001 From: Linghong Date: Mon, 14 Sep 2026 05:56:28 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20sccache=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=9A=84=E5=B9=B3=E5=8F=B0=E9=9A=94=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为启用 sccache 的用例补充 Windows platform mock 确保 POSIX 环境下测试不会误走 env wrapper 分支 --- scripts/dev.test.ts | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/scripts/dev.test.ts b/scripts/dev.test.ts index 884e2fa72..4bf5cc82d 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', () => {