mirror of
https://github.com/stablyai/orca.git
synced 2026-11-13 17:37:40 +00:00
* refactor(tooling): organize test runtime and maintenance owners * test(tooling): preserve relocated runtime fixture dependency edges * refactor(tooling): preserve xterm routing owner checks * ci(tooling): include routing owner in sparse checkout * test(tooling): preserve copied workflow dependency closures * fix(tooling): normalize hashed JSON assets in release parity * fix(tooling): distinguish asset aliases from literal references * fix(tooling): frame normalized asset reference payloads * fix(tooling): normalize decoded JSON asset references * refactor(tooling): organize build, CI and release owners * fix(tooling): align moved generator and workflow path contracts * fix(tooling): update generated plugin bundle owner banners * test(tooling): create relocated mobile verifier fixture directories * test(tooling): copy headless detector dependency closure * test(tooling): align native batch policy fixtures with owner path * fix(tooling): link moved reliability command to historical evidence * fix(tooling): preserve nested sandbox owners and canonical guide source * fix(tooling): target release version owners in checkout fixture
50 lines
2.1 KiB
JavaScript
50 lines
2.1 KiB
JavaScript
import { existsSync, mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import path from 'node:path'
|
|
import { afterEach, expect, it } from 'vitest'
|
|
import { writeWorktreeProfileMarker } from '../development/instance-isolation/dev-instance-isolation.mjs'
|
|
import { reclaimDevWorktreeProfiles } from './reclaim-dev-worktree-profiles.mjs'
|
|
|
|
const roots = []
|
|
afterEach(() => {
|
|
for (const root of roots.splice(0)) {
|
|
rmSync(root, { recursive: true, force: true })
|
|
}
|
|
})
|
|
|
|
it('removes only idle profiles whose worktree of this repository is gone', async () => {
|
|
const root = realpathSync(mkdtempSync(path.join(tmpdir(), 'orca-dev-profiles-')))
|
|
roots.push(root)
|
|
const commonDirectory = path.join(root, 'repo', '.git')
|
|
const otherCommonDirectory = path.join(root, 'other', '.git')
|
|
const liveWorktree = path.join(root, 'live')
|
|
mkdirSync(commonDirectory, { recursive: true })
|
|
mkdirSync(otherCommonDirectory, { recursive: true })
|
|
mkdirSync(liveWorktree)
|
|
const profilesRoot = path.join(root, 'orca-dev-wt')
|
|
const profile = (name, repoRoot, gitCommonDir) => {
|
|
const dir = path.join(profilesRoot, name)
|
|
writeWorktreeProfileMarker(dir, { repoRoot, instanceKey: repoRoot, gitCommonDir })
|
|
return dir
|
|
}
|
|
const removed = profile('aaaaaaaaaa', path.join(root, 'removed'), commonDirectory)
|
|
const live = profile('bbbbbbbbbb', liveWorktree, commonDirectory)
|
|
const otherRepo = profile('cccccccccc', path.join(root, 'gone-other'), otherCommonDirectory)
|
|
const running = profile('dddddddddd', path.join(root, 'removed-running'), commonDirectory)
|
|
writeFileSync(path.join(running, 'orca-runtime.json'), JSON.stringify({ pid: 4242 }))
|
|
|
|
const result = await reclaimDevWorktreeProfiles({
|
|
apply: true,
|
|
profilesRoot,
|
|
repository: { commonDirectory, worktrees: [liveWorktree] },
|
|
isAlive: (pid) => pid === 4242,
|
|
report: () => {}
|
|
})
|
|
|
|
expect(result).toEqual({ entries: 1, protected: 1 })
|
|
expect(existsSync(removed)).toBe(false)
|
|
expect(existsSync(live)).toBe(true)
|
|
expect(existsSync(otherRepo)).toBe(true)
|
|
expect(existsSync(running)).toBe(true)
|
|
})
|