修正 POSIX sccache 绕过日志
明确记录 Linux 和 macOS 本地开发实际绕过 sccache 补充 POSIX 日志回归测试并更新排障文档
This commit is contained in:
+11
-5
@@ -623,12 +623,18 @@ function buildLocalRustProcessEnv(env, options = {}) {
|
||||
mergedEnv.RUSTC_WRAPPER = rustcWrapper;
|
||||
mergedEnv.CARGO_BUILD_RUSTC_WRAPPER = rustcWrapper;
|
||||
if (options.log !== false) {
|
||||
const isPosixSccacheBypass =
|
||||
configuredWrapper &&
|
||||
isSccacheRustcWrapper(configuredWrapper) &&
|
||||
process.platform !== 'win32';
|
||||
console.warn(
|
||||
rustcWrapper
|
||||
? '[dev:rust] 本地 dev 构建启用 sccache wrapper。'
|
||||
: configuredWrapper
|
||||
? '[dev:rust] sccache wrapper 探测失败,回退到直接 rustc。'
|
||||
: '[dev:rust] 未显式配置 Rust wrapper,使用直接 rustc。',
|
||||
isPosixSccacheBypass
|
||||
? '[dev:rust] POSIX 本地 dev 构建绕过 sccache,使用直接 rustc。'
|
||||
: rustcWrapper
|
||||
? '[dev:rust] 本地 dev 构建启用 sccache wrapper。'
|
||||
: configuredWrapper
|
||||
? '[dev:rust] sccache wrapper 探测失败,回退到直接 rustc。'
|
||||
: '[dev:rust] 未显式配置 Rust wrapper,使用直接 rustc。',
|
||||
);
|
||||
}
|
||||
return mergedEnv;
|
||||
|
||||
@@ -679,6 +679,32 @@ describe('dev scheduler Rust build env', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('POSIX 显式配置 sccache 时日志说明实际绕过', () => {
|
||||
const originalPlatform = Object.getOwnPropertyDescriptor(
|
||||
process,
|
||||
'platform',
|
||||
);
|
||||
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
||||
Object.defineProperty(process, 'platform', {
|
||||
configurable: true,
|
||||
value: 'linux',
|
||||
});
|
||||
try {
|
||||
const env = buildLocalRustProcessEnv(
|
||||
{ RUSTC_WRAPPER: 'sccache', CARGO_BUILD_RUSTC_WRAPPER: 'sccache' },
|
||||
{ log: true },
|
||||
);
|
||||
expect(env.RUSTC_WRAPPER).toBe('/usr/bin/env');
|
||||
expect(warn).toHaveBeenCalledWith(
|
||||
'[dev:rust] POSIX 本地 dev 构建绕过 sccache,使用直接 rustc。',
|
||||
);
|
||||
} finally {
|
||||
warn.mockRestore();
|
||||
if (originalPlatform)
|
||||
Object.defineProperty(process, 'platform', originalPlatform);
|
||||
}
|
||||
});
|
||||
|
||||
test('local dev Rust env enables available sccache wrapper', () => {
|
||||
const originalPlatform = Object.getOwnPropertyDescriptor(
|
||||
process,
|
||||
|
||||
Reference in New Issue
Block a user