Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changeset/native-path-helper-test-portability.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

Test-only Windows portability fix for native path helper expectations.
30 changes: 19 additions & 11 deletions apps/kimi-code/test/scripts/native/paths.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { resolve } from 'node:path';

import { describe, expect, it } from 'vitest';

import {
Expand All @@ -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');
Expand Down Expand Up @@ -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'),
);
});

Expand All @@ -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', () => {
Expand Down