From 1bfe2c4559afb96e5fc446f4f7b87ea84bfefb93 Mon Sep 17 00:00:00 2001 From: imccyu <276526105+imccyu@users.noreply.github.com> Date: Thu, 17 Sep 2026 20:46:35 +0800 Subject: [PATCH] fix: test --- apps/cli/tests/built-bin.e2e.ts | 2 +- .../tests/profiles/sdk/keyless-smoke.e2e.ts | 35 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/apps/cli/tests/built-bin.e2e.ts b/apps/cli/tests/built-bin.e2e.ts index 781396262a..dbaf904569 100644 --- a/apps/cli/tests/built-bin.e2e.ts +++ b/apps/cli/tests/built-bin.e2e.ts @@ -984,7 +984,7 @@ describe.skipIf(!existsSync(dshBin))('dsh BUILT bin (node lib/bin.js, no tsx)', try { await waitForFile(fixture.ready) expect(readFileSync(fixture.echo, 'utf8')).toBe('bundle-default') - expect(existsSync(join(fixture.home, 'profiles', 'node_modules'))).toBe(true) + expect(existsSync(join(fixture.home, 'profiles', 'node_modules'))).toBe(false) requestProfileShutdown(child, fixture) expect((await child).exitCode).toBe(0) } finally { diff --git a/apps/cli/tests/profiles/sdk/keyless-smoke.e2e.ts b/apps/cli/tests/profiles/sdk/keyless-smoke.e2e.ts index 3601745871..7019b87f71 100644 --- a/apps/cli/tests/profiles/sdk/keyless-smoke.e2e.ts +++ b/apps/cli/tests/profiles/sdk/keyless-smoke.e2e.ts @@ -5,11 +5,15 @@ import { join } from 'node:path' import { fileURLToPath } from 'node:url' import { promisify } from 'node:util' import { zstdDecompress } from 'node:zlib' +import { resolveExampleLaunch } from '@deepseek-ai/dsh-loader-smoke' import { execa } from 'execa' import { describe, expect, it } from 'vitest' -const binScript = fileURLToPath(new URL('../../../src/bin.ts', import.meta.url)) const repoRoot = fileURLToPath(new URL('../../../../../', import.meta.url)) +const launch = resolveExampleLaunch({ + srcBin: fileURLToPath(new URL('../../../src/bin.ts', import.meta.url)), + mode: 'lib', +}) const decompress = promisify(zstdDecompress) /** Frame one text or tool response from the local Messages endpoint. */ @@ -86,16 +90,15 @@ describe('Python SDK dsh profile keyless smoke', () => { if (address === null || typeof address === 'string') throw new Error('model server did not bind a TCP port') // The line-predicate protocol driving below is the genuinely custom part; // execa owns spawn, the deadline, and exit settlement around it. - const child = execa(process.execPath, [ - '--import', - 'tsx/esm', - binScript, + const child = execa(launch.command, [ + ...launch.args, '--profile', 'sdk', ...(editorEnabled ? ['--patch', editorPatch] : []), ], { cwd: repoRoot, env: { + ...launch.env, DSH_HOME: join(root, '.dsh'), DSH_PERMISSION_MODE: 'danger-full-access', DSH_TELEMETRY_DISABLED: '1', @@ -236,16 +239,15 @@ describe('Python SDK dsh profile keyless smoke', () => { await new Promise(resolve => modelServer.listen(0, '127.0.0.1', resolve)) const address = modelServer.address() if (address === null || typeof address === 'string') throw new Error('model server did not bind a TCP port') - const child = execa(process.execPath, [ - '--import', - 'tsx/esm', - binScript, + const child = execa(launch.command, [ + ...launch.args, '--profile', 'sdk-minimal', ...(editorEnabled ? ['--patch', editorPatch] : []), ], { cwd: repoRoot, env: { + ...launch.env, DSH_HOME: join(root, '.dsh'), DSH_SYSTEM_PROMPT: 'Minimal allowlist prompt.', DEEPSEEK_API_KEY: 'keyless-smoke-no-call', @@ -285,7 +287,7 @@ describe('Python SDK dsh profile keyless smoke', () => { const event = params?.event as Record | undefined return params?.sessionId === 'minimal' && event?.type === 'turn/end' }, () => stderr) - expect(turnEnd).toMatchObject({ + expect(turnEnd, `${JSON.stringify(turnEnd)}\n${stderr}`).toMatchObject({ params: { event: { data: { reason: { kind: 'completed' } } } }, }) @@ -341,11 +343,11 @@ describe('Python SDK dsh profile keyless smoke', () => { await mkdir(home) if (blocked) await writeFile(join(home, 'logs'), 'blocked') await writeFile(patch, '- id: agent-loop\n config:\n maxParallelToolCalls: 0\n') - const child = execa(process.execPath, [ - '--import', 'tsx/esm', binScript, '--profile', 'sdk', '--patch', patch, + const child = execa(launch.command, [ + ...launch.args, '--profile', 'sdk', '--patch', patch, ], { cwd: repoRoot, - env: { DSH_HOME: home, DSH_TELEMETRY_DISABLED: '1', DEEPSEEK_API_KEY: 'keyless-no-call' }, + env: { ...launch.env, DSH_HOME: home, DSH_TELEMETRY_DISABLED: '1', DEEPSEEK_API_KEY: 'keyless-no-call' }, stdin: 'pipe', stripFinalNewline: false, timeout: 25_000, @@ -378,15 +380,14 @@ describe('Python SDK dsh profile keyless smoke', () => { it('rejects an invalid max-token success env value', async () => { const root = await mkdtemp(join(tmpdir(), 'dsh-python-sdk-runtime-invalid-')) try { - const { exitCode, stdout, stderr } = await execa(process.execPath, [ - '--import', - 'tsx/esm', - binScript, + const { exitCode, stdout, stderr } = await execa(launch.command, [ + ...launch.args, '--profile', 'sdk', ], { cwd: repoRoot, env: { + ...launch.env, DSH_HOME: join(root, '.dsh'), DEEPSEEK_API_KEY: 'keyless-smoke-no-call', DSH_MAX_TOKENS_AS_SUCCESS: 'sometimes',