mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
test(tui): make cwd coverage location-independent
formatCwd has distinct branches for the home directory itself, a descendant of home, an unset cwd, and a path outside home. The descendant branch was exercised only indirectly because the test harness defaulted to process.cwd(), so the per-file coverage gate changed with the checkout location and failed in detached worktrees under /private/tmp even though every behavior assertion passed. Derive the home-root case from homedir() and add an explicit synthetic child with platform-aware path joins. Keep the unset and outside-home cases unchanged. The suite now drives every formatting branch regardless of where the repository is checked out, and the expected child form follows the host path separator on macOS, Linux, and Windows.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { homedir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { Context } from 'cordis'
|
||||
import type { Terminal } from '@earendil-works/pi-tui'
|
||||
@@ -341,8 +343,9 @@ describe('pi-tui chat lifecycle and transcript', () => {
|
||||
})
|
||||
|
||||
it('formats large token totals and cwd variants', async () => {
|
||||
const home = homedir()
|
||||
const homeResult = await setup({
|
||||
cwd: process.env.HOME ?? process.cwd(),
|
||||
cwd: home,
|
||||
beforeMount(session) {
|
||||
appendAssistant(session, [{ type: 'text', text: 'home' }], { inputTokens: 25_000, outputTokens: 10_000 })
|
||||
},
|
||||
@@ -350,6 +353,10 @@ describe('pi-tui chat lifecycle and transcript', () => {
|
||||
expect(homeResult.terminal.output).toContain('~ ↑25k ↓10k')
|
||||
await dispose(homeResult)
|
||||
|
||||
const childResult = await setup({ cwd: join(home, 'projects', 'dsh-tui') })
|
||||
expect(childResult.terminal.output).toContain(join('~', 'projects', 'dsh-tui'))
|
||||
await dispose(childResult)
|
||||
|
||||
const unsetResult = await setup({ cwd: null })
|
||||
expect(unsetResult.terminal.output).toContain('cwd unset')
|
||||
await dispose(unsetResult)
|
||||
|
||||
Reference in New Issue
Block a user