From ced5f905f5703756d58d1c5e1f32c93ec49a9970 Mon Sep 17 00:00:00 2001 From: haosenwang1018 <1293965075@qq.com> Date: Mon, 1 Jun 2026 18:25:53 +0800 Subject: [PATCH] test(native): derive path expectations with node path helpers --- .../native-path-helper-test-portability.md | 4 +++ .../test/scripts/native/paths.test.ts | 30 ++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 .changeset/native-path-helper-test-portability.md diff --git a/.changeset/native-path-helper-test-portability.md b/.changeset/native-path-helper-test-portability.md new file mode 100644 index 00000000..edb1301d --- /dev/null +++ b/.changeset/native-path-helper-test-portability.md @@ -0,0 +1,4 @@ +--- +--- + +Test-only Windows portability fix for native path helper expectations. diff --git a/apps/kimi-code/test/scripts/native/paths.test.ts b/apps/kimi-code/test/scripts/native/paths.test.ts index 80209f45..ecac7e7e 100644 --- a/apps/kimi-code/test/scripts/native/paths.test.ts +++ b/apps/kimi-code/test/scripts/native/paths.test.ts @@ -1,3 +1,5 @@ +import { resolve } from 'node:path'; + import { describe, expect, it } from 'vitest'; import { @@ -18,6 +20,10 @@ import { SEA_SENTINEL_FUSE, } from '../../../scripts/native/paths.mjs'; +function underAppRoot(...parts: string[]): string { + return resolve(appRoot, ...parts); +} + describe('targetTriple', () => { it('returns platform-arch when env unset', () => { expect(targetTriple({ platform: 'darwin', arch: 'arm64', env: {} })).toBe('darwin-arm64'); @@ -49,27 +55,29 @@ describe('executableName', () => { describe('path helpers', () => { it('returns absolute intermediates dir under app root', () => { - expect(nativeIntermediatesDir()).toBe(`${appRoot}/dist-native/intermediates`); + expect(nativeIntermediatesDir()).toBe(underAppRoot('dist-native', 'intermediates')); }); it('returns absolute bin dir per target', () => { - expect(nativeBinDir('darwin-arm64')).toBe(`${appRoot}/dist-native/bin/darwin-arm64`); + expect(nativeBinDir('darwin-arm64')).toBe(underAppRoot('dist-native', 'bin', 'darwin-arm64')); }); it('returns absolute bin path with executable name', () => { expect(nativeBinPath('darwin-arm64', 'darwin')).toBe( - `${appRoot}/dist-native/bin/darwin-arm64/kimi`, + underAppRoot('dist-native', 'bin', 'darwin-arm64', 'kimi'), ); expect(nativeBinPath('win32-x64', 'win32')).toBe( - `${appRoot}/dist-native/bin/win32-x64/kimi.exe`, + underAppRoot('dist-native', 'bin', 'win32-x64', 'kimi.exe'), ); }); it('returns intermediate artifact paths', () => { - expect(nativeJsBundlePath()).toBe(`${appRoot}/dist-native/intermediates/main.cjs`); - expect(nativeBlobPath()).toBe(`${appRoot}/dist-native/intermediates/kimi.blob`); + expect(nativeJsBundlePath()).toBe( + underAppRoot('dist-native', 'intermediates', 'main.cjs'), + ); + expect(nativeBlobPath()).toBe(underAppRoot('dist-native', 'intermediates', 'kimi.blob')); expect(nativeSeaConfigPath()).toBe( - `${appRoot}/dist-native/intermediates/sea-config.json`, + underAppRoot('dist-native', 'intermediates', 'sea-config.json'), ); }); @@ -78,21 +86,21 @@ describe('path helpers', () => { }); it('returns native dist root', () => { - expect(nativeDistRoot()).toBe(`${appRoot}/dist-native`); + expect(nativeDistRoot()).toBe(underAppRoot('dist-native')); }); it('returns manifest dir for target', () => { expect(nativeManifestDir('darwin-arm64')).toBe( - `${appRoot}/dist-native/intermediates/native-assets/darwin-arm64`, + underAppRoot('dist-native', 'intermediates', 'native-assets', 'darwin-arm64'), ); }); it('returns artifacts dir', () => { - expect(nativeArtifactsDir()).toBe(`${appRoot}/dist-native/artifacts`); + expect(nativeArtifactsDir()).toBe(underAppRoot('dist-native', 'artifacts')); }); it('returns smoke home', () => { - expect(nativeSmokeHome()).toBe(`${appRoot}/dist-native/smoke-home`); + expect(nativeSmokeHome()).toBe(underAppRoot('dist-native', 'smoke-home')); }); it('has correct SEA sentinel fuse value', () => {