Browse Source

fix: test

imccyu 1 day ago
parent
commit
1bfe2c4559
2 changed files with 19 additions and 18 deletions
  1. 1 1
      apps/cli/tests/built-bin.e2e.ts
  2. 18 17
      apps/cli/tests/profiles/sdk/keyless-smoke.e2e.ts

+ 1 - 1
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 {
     try {
       await waitForFile(fixture.ready)
       await waitForFile(fixture.ready)
       expect(readFileSync(fixture.echo, 'utf8')).toBe('bundle-default')
       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)
       requestProfileShutdown(child, fixture)
       expect((await child).exitCode).toBe(0)
       expect((await child).exitCode).toBe(0)
     } finally {
     } finally {

+ 18 - 17
apps/cli/tests/profiles/sdk/keyless-smoke.e2e.ts

@@ -5,11 +5,15 @@ import { join } from 'node:path'
 import { fileURLToPath } from 'node:url'
 import { fileURLToPath } from 'node:url'
 import { promisify } from 'node:util'
 import { promisify } from 'node:util'
 import { zstdDecompress } from 'node:zlib'
 import { zstdDecompress } from 'node:zlib'
+import { resolveExampleLaunch } from '@deepseek-ai/dsh-loader-smoke'
 import { execa } from 'execa'
 import { execa } from 'execa'
 import { describe, expect, it } from 'vitest'
 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 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)
 const decompress = promisify(zstdDecompress)
 
 
 /** Frame one text or tool response from the local Messages endpoint. */
 /** 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')
     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;
     // The line-predicate protocol driving below is the genuinely custom part;
     // execa owns spawn, the deadline, and exit settlement around it.
     // 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',
       '--profile',
       'sdk',
       'sdk',
       ...(editorEnabled ? ['--patch', editorPatch] : []),
       ...(editorEnabled ? ['--patch', editorPatch] : []),
     ], {
     ], {
       cwd: repoRoot,
       cwd: repoRoot,
       env: {
       env: {
+        ...launch.env,
         DSH_HOME: join(root, '.dsh'),
         DSH_HOME: join(root, '.dsh'),
         DSH_PERMISSION_MODE: 'danger-full-access',
         DSH_PERMISSION_MODE: 'danger-full-access',
         DSH_TELEMETRY_DISABLED: '1',
         DSH_TELEMETRY_DISABLED: '1',
@@ -236,16 +239,15 @@ describe('Python SDK dsh profile keyless smoke', () => {
     await new Promise<void>(resolve => modelServer.listen(0, '127.0.0.1', resolve))
     await new Promise<void>(resolve => modelServer.listen(0, '127.0.0.1', resolve))
     const address = modelServer.address()
     const address = modelServer.address()
     if (address === null || typeof address === 'string') throw new Error('model server did not bind a TCP port')
     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',
       '--profile',
       'sdk-minimal',
       'sdk-minimal',
       ...(editorEnabled ? ['--patch', editorPatch] : []),
       ...(editorEnabled ? ['--patch', editorPatch] : []),
     ], {
     ], {
       cwd: repoRoot,
       cwd: repoRoot,
       env: {
       env: {
+        ...launch.env,
         DSH_HOME: join(root, '.dsh'),
         DSH_HOME: join(root, '.dsh'),
         DSH_SYSTEM_PROMPT: 'Minimal allowlist prompt.',
         DSH_SYSTEM_PROMPT: 'Minimal allowlist prompt.',
         DEEPSEEK_API_KEY: 'keyless-smoke-no-call',
         DEEPSEEK_API_KEY: 'keyless-smoke-no-call',
@@ -285,7 +287,7 @@ describe('Python SDK dsh profile keyless smoke', () => {
         const event = params?.event as Record<string, unknown> | undefined
         const event = params?.event as Record<string, unknown> | undefined
         return params?.sessionId === 'minimal' && event?.type === 'turn/end'
         return params?.sessionId === 'minimal' && event?.type === 'turn/end'
       }, () => stderr)
       }, () => stderr)
-      expect(turnEnd).toMatchObject({
+      expect(turnEnd, `${JSON.stringify(turnEnd)}\n${stderr}`).toMatchObject({
         params: { event: { data: { reason: { kind: 'completed' } } } },
         params: { event: { data: { reason: { kind: 'completed' } } } },
       })
       })
 
 
@@ -341,11 +343,11 @@ describe('Python SDK dsh profile keyless smoke', () => {
     await mkdir(home)
     await mkdir(home)
     if (blocked) await writeFile(join(home, 'logs'), 'blocked')
     if (blocked) await writeFile(join(home, 'logs'), 'blocked')
     await writeFile(patch, '- id: agent-loop\n  config:\n    maxParallelToolCalls: 0\n')
     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,
       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',
       stdin: 'pipe',
       stripFinalNewline: false,
       stripFinalNewline: false,
       timeout: 25_000,
       timeout: 25_000,
@@ -378,15 +380,14 @@ describe('Python SDK dsh profile keyless smoke', () => {
   it('rejects an invalid max-token success env value', async () => {
   it('rejects an invalid max-token success env value', async () => {
     const root = await mkdtemp(join(tmpdir(), 'dsh-python-sdk-runtime-invalid-'))
     const root = await mkdtemp(join(tmpdir(), 'dsh-python-sdk-runtime-invalid-'))
     try {
     try {
-      const { exitCode, stdout, stderr } = await execa(process.execPath, [
-        '--import',
-        'tsx/esm',
-        binScript,
+      const { exitCode, stdout, stderr } = await execa(launch.command, [
+        ...launch.args,
         '--profile',
         '--profile',
         'sdk',
         'sdk',
       ], {
       ], {
         cwd: repoRoot,
         cwd: repoRoot,
         env: {
         env: {
+          ...launch.env,
           DSH_HOME: join(root, '.dsh'),
           DSH_HOME: join(root, '.dsh'),
           DEEPSEEK_API_KEY: 'keyless-smoke-no-call',
           DEEPSEEK_API_KEY: 'keyless-smoke-no-call',
           DSH_MAX_TOKENS_AS_SUCCESS: 'sometimes',
           DSH_MAX_TOKENS_AS_SUCCESS: 'sometimes',