fix: skip repeated OpenCode binary validation
OpenCode startup on Linux ARM could run a --version probe before launching the configured Runtime and recheck registered remote binary metadata. Execution now trusts the selected path and registered manifest identity after setup-time verification, so switching and cold launch avoid duplicate binary work. Release note: 优化 Linux ARM 上切换 OpenCode 的启动速度;已安装或已登记的 Runtime 在执行时不再重复启动或检查二进制。
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { EventEmitter } from 'node:events'
|
||||
import { realpath } from 'node:fs/promises'
|
||||
import { basename, dirname } from 'node:path'
|
||||
import { basename, dirname, resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
@@ -93,6 +93,29 @@ describe('runtime discovery', () => {
|
||||
expect(detection.version).toMatch(/^\d+\.\d+\.\d+/u)
|
||||
})
|
||||
|
||||
it('trusts a configured execution path without reading or launching it', async () => {
|
||||
process.env.PATH = ''
|
||||
process.env.Path = ''
|
||||
const candidate = resolve(
|
||||
dirname(fileURLToPath(import.meta.url)),
|
||||
'runtime-that-does-not-exist'
|
||||
)
|
||||
|
||||
const detection = await detectRuntimeBinary({
|
||||
binaryPath: candidate,
|
||||
validation: 'path-only',
|
||||
binaryNames: ['binary-that-does-not-exist'],
|
||||
label: 'Managed Runtime'
|
||||
})
|
||||
|
||||
expect(detection).toEqual({
|
||||
available: true,
|
||||
path: candidate,
|
||||
source: 'configured',
|
||||
detail: 'Managed Runtime 已就绪'
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects relative configured paths without resolving them from cwd', async () => {
|
||||
process.env.PATH = ''
|
||||
process.env.Path = ''
|
||||
|
||||
Reference in New Issue
Block a user