mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
test(wsl-hosts): prove mapped-drive moves on real Windows; Git reason first
- A repo the Git-for-Windows check refuses shows that reason even when its drive changed or doesn't answer (checked through the last-known share), and a start no longer lists it as left behind. - New real-Windows lane test, run in the WSL orcad E2E job: maps a free drive letter to the test distro's share with `net use`, then checks the real drive lookups, move scope, Linux path/id mapping, and that a worktree made by real Git for Windows is refused while WSL-made and plain repos pass. Co-authored-by: Neil <neil@stably.ai>
This commit is contained in:
@@ -36,6 +36,7 @@ on:
|
||||
- '!**/*.test.tsx'
|
||||
- 'src/main/wsl/orcad/wsl-orcad-real-distro-lane.test.ts'
|
||||
- 'src/main/wsl/orcad/wsl-orcad-real-distro-idle-release-lane.test.ts'
|
||||
- 'src/main/wsl/filesystem/wsl-mapped-drive-real-distro-lane.test.ts'
|
||||
- '.github/workflows/wsl-orcad-e2e.yml'
|
||||
- 'config/ci/wsl-lifecycle/**'
|
||||
- 'config/ci/windows-lifecycle-receipt.ps1'
|
||||
@@ -350,6 +351,17 @@ jobs:
|
||||
run: |
|
||||
node node_modules/vitest/vitest.mjs run --config config/vitest.config.ts src/main/wsl/orcad/wsl-orcad-real-distro-idle-release-lane.test.ts --reporter=verbose 2>&1 | Tee-Object (Join-Path $env:ORCA_WSL_ORCAD_LANE_RECEIPTS 'idle-release.log')
|
||||
if ($global:LASTEXITCODE -ne 0) { throw "idle-release phase failed: $global:LASTEXITCODE" }
|
||||
# Its own repos in the plain distro; runs even when a phase above failed.
|
||||
- name: Mapped-drive projects on the distro share
|
||||
if: ${{ !cancelled() && steps.import.outcome == 'success' }}
|
||||
timeout-minutes: 8
|
||||
env:
|
||||
ORCA_RUN_WSL_ORCAD_LANE: '1'
|
||||
ORCA_WSL_ORCAD_LANE_PLAIN_DISTRO: ${{ env.PLAIN_DISTRO }}
|
||||
run: |
|
||||
New-Item -ItemType Directory -Force $env:ORCA_WSL_ORCAD_LANE_RECEIPTS | Out-Null
|
||||
node node_modules/vitest/vitest.mjs run --config config/vitest.config.ts src/main/wsl/filesystem/wsl-mapped-drive-real-distro-lane.test.ts --reporter=verbose 2>&1 | Tee-Object (Join-Path $env:ORCA_WSL_ORCAD_LANE_RECEIPTS 'mapped-drive.log')
|
||||
if ($global:LASTEXITCODE -ne 0) { throw "mapped-drive lane failed: $global:LASTEXITCODE" }
|
||||
- name: Real desktop agent configuration is unchanged
|
||||
if: always()
|
||||
run: |
|
||||
|
||||
@@ -18,8 +18,8 @@ import type { WslMappedDrive } from '../../../../shared/wsl-move/wsl-mapped-driv
|
||||
import {
|
||||
journaledWslMoveDrives,
|
||||
readWslMoveSourceDrives,
|
||||
wslMoveDroppedForDrives,
|
||||
wslMoveStartDriveRefusal
|
||||
wslMoveStartDriveRefusal,
|
||||
wslMoveStartDroppedProjects
|
||||
} from './wsl-move-driver-source-drives'
|
||||
import { listWslMoveCutoverChain } from '../cutover-recovery/wsl-move-cutover-journal'
|
||||
|
||||
@@ -303,7 +303,14 @@ export async function prepareWslMove(
|
||||
return changedDrives
|
||||
}
|
||||
const droppedForDrives = expectedMappedDrives
|
||||
? wslMoveDroppedForDrives(catalog, drives.mappedDrives, expectedMappedDrives, plan)
|
||||
? await wslMoveStartDroppedProjects(
|
||||
deps,
|
||||
catalog,
|
||||
request.distro,
|
||||
drives.mappedDrives,
|
||||
expectedMappedDrives,
|
||||
plan
|
||||
)
|
||||
: []
|
||||
const scope: WslMoveTerminalScope = {
|
||||
workspaceIds: exported.workspaceIds,
|
||||
|
||||
+33
-4
@@ -51,19 +51,21 @@ export async function readWslMoveSourceDrives(
|
||||
): Promise<WslMoveSourceDrives> {
|
||||
const read = deps.driveShares
|
||||
? await readWslMoveMappedDrives(catalog, request.distro, deps.driveShares)
|
||||
: { mappedDrives: [], unverifiableLetters: [], unknownLetters: [] }
|
||||
: { mappedDrives: [], unansweredDrives: [], unknownLetters: [] }
|
||||
const named = namedLetters(catalog, request) ?? []
|
||||
// An unclassified drive (an offline share, say) is this distro's to list only when picked.
|
||||
const unverifiableLetters = [
|
||||
...read.unverifiableLetters,
|
||||
...read.unansweredDrives.map((drive) => drive.letter),
|
||||
...read.unknownLetters.filter((letter) => named.includes(letter))
|
||||
]
|
||||
// An unanswered drive's repos are checked through their last share, so a Git reason shows.
|
||||
const gitDrives = [...read.mappedDrives, ...read.unansweredDrives]
|
||||
const windowsGitRefusals =
|
||||
deps.windowsGitVerdict && read.mappedDrives.length > 0
|
||||
deps.windowsGitVerdict && gitDrives.length > 0
|
||||
? await findWindowsGitRefusals(
|
||||
catalog.repos,
|
||||
request.distro,
|
||||
read.mappedDrives,
|
||||
gitDrives,
|
||||
deps.windowsGitVerdict
|
||||
)
|
||||
: new Map<string, WslMoveScopeRefusal>()
|
||||
@@ -150,3 +152,30 @@ export function wslMoveDroppedForDrives(
|
||||
.map((folder) => ({ kind: 'folder' as const, id: folder.id, name: folder.name }))
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* `wslMoveDroppedForDrives`, less the repos the Git-for-Windows check refuses through the share
|
||||
* the preview read: the preview showed those with Git's reason, never as moving.
|
||||
*/
|
||||
export async function wslMoveStartDroppedProjects(
|
||||
deps: Pick<WslMoveDriverDeps, 'windowsGitVerdict'>,
|
||||
catalog: WslMoveCatalogRows,
|
||||
distro: string,
|
||||
fresh: readonly WslMappedDrive[],
|
||||
expected: readonly WslMappedDrive[],
|
||||
moving: { repoIds: readonly string[]; folderWorkspaceIds: readonly string[] }
|
||||
): Promise<WslMoveDroppedProject[]> {
|
||||
const dropped = wslMoveDroppedForDrives(catalog, fresh, expected, moving)
|
||||
const repos = catalog.repos.filter((repo) =>
|
||||
dropped.some((project) => project.kind === 'repo' && project.id === repo.id)
|
||||
)
|
||||
if (!deps.windowsGitVerdict || repos.length === 0) {
|
||||
return dropped
|
||||
}
|
||||
const refused = await findWindowsGitRefusals(repos, distro, expected, deps.windowsGitVerdict)
|
||||
const gitReason = (id: string): boolean => {
|
||||
const reason = refused.get(id)
|
||||
return reason === 'windows-git-worktrees' || reason === 'windows-git-dir'
|
||||
}
|
||||
return dropped.filter((project) => project.kind !== 'repo' || !gitReason(project.id))
|
||||
}
|
||||
|
||||
+34
@@ -125,3 +125,37 @@ describe('a whole-distro start whose previewed drive now points elsewhere', () =
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('a repo the Git-for-Windows check refuses', () => {
|
||||
beforeEach(() => {
|
||||
rig.world.repos = [project('repo-1', UNC), project('repo-w', 'W:\\home\\dev\\other')]
|
||||
rig.world.deps.windowsGitVerdict = async (path) =>
|
||||
path.endsWith('other') ? 'windows-git-worktrees' : 'ok'
|
||||
})
|
||||
|
||||
it('shows Git’s reason even while its drive does not answer', async () => {
|
||||
shares = { W: 'unverifiable' }
|
||||
const preview = await previewWslMove(rig.world.deps, { distro: 'Ubuntu' })
|
||||
expect(preview.outcome === 'ready' ? preview.refused : null).toEqual([
|
||||
{ kind: 'repo', id: 'repo-w', reason: 'windows-git-worktrees' }
|
||||
])
|
||||
})
|
||||
|
||||
it('is not named as left behind when its drive points elsewhere at start', async () => {
|
||||
rig.world.repos.push({
|
||||
...project('repo-w2', 'W:\\home\\dev\\movable'),
|
||||
displayName: 'movable'
|
||||
})
|
||||
const preview = await previewWslMove(rig.world.deps, { distro: 'Ubuntu' })
|
||||
expect(preview).toMatchObject({ outcome: 'ready', mappedDrives: [W] })
|
||||
shares = { W: { share: '\\\\wsl.localhost\\Debian' } }
|
||||
const result = await moveProjectsToWslHost(rig.world.deps, {
|
||||
distro: 'Ubuntu',
|
||||
mappedDrives: preview.outcome === 'ready' ? (preview.mappedDrives ?? []) : []
|
||||
})
|
||||
expect(result).toMatchObject({
|
||||
outcome: 'moved',
|
||||
droppedForMappedDrives: [{ kind: 'repo', id: 'repo-w2', name: 'movable' }]
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -23,8 +23,8 @@ export type WslMoveDriveShares = {
|
||||
|
||||
export type WslMoveMappedDrivesRead = {
|
||||
mappedDrives: WslMappedDrive[]
|
||||
/** Letters last known to map into this distro that Windows did not answer for now. */
|
||||
unverifiableLetters: string[]
|
||||
/** Drives last known to map into this distro, with that share, that didn't answer now. */
|
||||
unansweredDrives: WslMappedDrive[]
|
||||
/** Letters never classified (the lookup timed out): they may map anywhere, or nowhere. */
|
||||
unknownLetters: string[]
|
||||
}
|
||||
@@ -48,7 +48,11 @@ export function wslMoveDriveLettersInUse(rows: {
|
||||
return [...letters].sort()
|
||||
}
|
||||
|
||||
type LetterRead = { mapped: WslMappedDrive } | 'unverifiable' | 'unknown' | 'elsewhere'
|
||||
type LetterRead =
|
||||
| { mapped: WslMappedDrive }
|
||||
| { unanswered: WslMappedDrive }
|
||||
| 'unknown'
|
||||
| 'elsewhere'
|
||||
|
||||
async function readLetter(
|
||||
letter: string,
|
||||
@@ -65,7 +69,9 @@ async function readLetter(
|
||||
const read = await shares.readNow(letter).catch((): WslMappedDriveRead => 'unverifiable')
|
||||
if (read === 'unverifiable') {
|
||||
// Last known in another distro: its projects aren't this move's to list.
|
||||
return wslMappedDriveMatches(known.share, distro, undefined) ? 'unverifiable' : 'elsewhere'
|
||||
return wslMappedDriveMatches(known.share, distro, undefined)
|
||||
? { unanswered: { letter, share: known.share } }
|
||||
: 'elsewhere'
|
||||
}
|
||||
return wslMappedDriveMatches(read.share, distro, undefined)
|
||||
? { mapped: { letter, share: read.share } }
|
||||
@@ -83,11 +89,11 @@ export async function readWslMoveMappedDrives(
|
||||
)
|
||||
return {
|
||||
mappedDrives: reads.flatMap(({ read }) =>
|
||||
typeof read === 'object' ? [{ ...read.mapped }] : []
|
||||
typeof read === 'object' && 'mapped' in read ? [{ ...read.mapped }] : []
|
||||
),
|
||||
unansweredDrives: reads.flatMap(({ read }) =>
|
||||
typeof read === 'object' && 'unanswered' in read ? [{ ...read.unanswered }] : []
|
||||
),
|
||||
unverifiableLetters: reads
|
||||
.filter(({ read }) => read === 'unverifiable')
|
||||
.map(({ letter }) => letter),
|
||||
unknownLetters: reads.filter(({ read }) => read === 'unknown').map(({ letter }) => letter)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,12 @@ export function collectWslMoveScope(
|
||||
for (const repo of state.repos) {
|
||||
const paths = wslMoveMappedRepoPaths(repo, mappedDrives)
|
||||
const local = getRepoExecutionHostId(repo) === 'local'
|
||||
const git = drives.windowsGitRefusals?.get(repo.id)
|
||||
// Git's reason holds whatever the drive does now: it is what the user must fix.
|
||||
if (local && (git === 'windows-git-worktrees' || git === 'windows-git-dir')) {
|
||||
scope.refused.push({ kind: 'repo', id: repo.id, reason: git })
|
||||
continue
|
||||
}
|
||||
if (local && unverifiable(repo.path)) {
|
||||
scope.refused.push({ kind: 'repo', id: repo.id, reason: 'mapped-drive-unverifiable' })
|
||||
continue
|
||||
@@ -74,8 +80,7 @@ export function collectWslMoveScope(
|
||||
if (!paths.some((path) => toLinux(path) !== null)) {
|
||||
continue
|
||||
}
|
||||
const reason =
|
||||
refusalFor(paths, toLinux, !local) ?? drives.windowsGitRefusals?.get(repo.id) ?? null
|
||||
const reason = refusalFor(paths, toLinux, !local) ?? git ?? null
|
||||
if (reason) {
|
||||
scope.refused.push({ kind: 'repo', id: repo.id, reason })
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
// A drive letter mapped to a real WSL2 distro's share (`net use X: \\wsl.localhost\<distro>`),
|
||||
// read by the mover's real pieces: drive reads, scope, path and identity mapping, and the
|
||||
// Git-for-Windows worktree gate against real Git for Windows and real WSL Git. wsl-orcad-e2e.yml
|
||||
// runs it after its lanes. Run: ORCA_RUN_WSL_ORCAD_LANE=1 pnpm test <this file> (Windows only).
|
||||
import { existsSync, readFileSync, readdirSync } from 'node:fs'
|
||||
import { join, win32 } from 'node:path'
|
||||
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock('electron', () => ({
|
||||
app: { getAppPath: () => process.cwd(), getPath: () => process.cwd() }
|
||||
}))
|
||||
|
||||
import { runProcess } from '@orca/process-host'
|
||||
import { parseWslUncPath } from '../../../shared/file-access/wsl-paths'
|
||||
import type { Repo } from '../../../shared/repository/repo-types'
|
||||
import { buildWslExecArgs } from '../../../shared/shell/wsl/wsl-login-shell-command'
|
||||
import {
|
||||
toWslDistroUncPath,
|
||||
type WslMappedDrive
|
||||
} from '../../../shared/wsl-move/wsl-mapped-drive-paths'
|
||||
import { rewriteOrcadMigrationWorktreeId } from '../../persistence/migrating-orcad-catalog/path-rewrite/orcad-migration-path-rewrite'
|
||||
import { createWslMoveStringNormalizer } from '../../persistence/moving-wsl-projects/manifest-scope/wsl-move-canonical-form'
|
||||
import { readWslMoveMappedDrives } from '../../persistence/moving-wsl-projects/manifest-scope/wsl-move-mapped-drives'
|
||||
import { createUncToLinuxPathRewriter } from '../../persistence/moving-wsl-projects/manifest-scope/wsl-move-path-rewriter'
|
||||
import { collectWslMoveScope } from '../../persistence/moving-wsl-projects/manifest-scope/wsl-move-scope'
|
||||
import {
|
||||
findWindowsGitRefusals,
|
||||
windowsGitWorktreeVerdict
|
||||
} from '../../persistence/moving-wsl-projects/manifest-scope/wsl-move-windows-git-worktrees'
|
||||
import { resolveWslExecutablePath } from '../execution/wsl-executable-path'
|
||||
import { resolveWslInteropSpawnCwd } from '../execution/wsl-interop-spawn-directory'
|
||||
import {
|
||||
classifyWslMappedDrive,
|
||||
readWslMappedDriveShareNow,
|
||||
resolveWslMappedDrivePath,
|
||||
wslMappedDriveMatches
|
||||
} from './wsl-mapped-drive-share'
|
||||
|
||||
const RUN = process.env.ORCA_RUN_WSL_ORCAD_LANE === '1' && process.platform === 'win32'
|
||||
const DISTRO = process.env.ORCA_WSL_ORCAD_LANE_PLAIN_DISTRO ?? 'orca-lane-plain'
|
||||
const SHARE = `\\\\wsl.localhost\\${DISTRO}`
|
||||
const LANE_DIR = 'orca-mapped-drive-lane'
|
||||
// A cold distro boots on the first share read; WSL itself answers in seconds once it runs.
|
||||
const SHARE_TIMEOUT_MS = 60_000
|
||||
|
||||
const net = join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'net.exe')
|
||||
const gitForWindows = join(process.env.ProgramFiles ?? 'C:\\Program Files', 'Git', 'cmd', 'git.exe')
|
||||
|
||||
let letter = ''
|
||||
let linuxBase = ''
|
||||
let mapped = false
|
||||
|
||||
async function run(program: string, args: string[], cwd?: string): Promise<string> {
|
||||
const result = await runProcess({ program, args, cwd, timeoutMs: 120_000 })
|
||||
const output = `${result.stdout}${result.stderr}`.trim()
|
||||
if (result.code !== 0) {
|
||||
throw new Error(`${win32.basename(program)} ${args.join(' ')} exited ${result.code}: ${output}`)
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
/** As the distro's default user (orca), through `--exec` so no argument is rewritten. */
|
||||
function guest(script: string): Promise<string> {
|
||||
return run(
|
||||
resolveWslExecutablePath(),
|
||||
buildWslExecArgs(DISTRO, ['sh', '-c', script]),
|
||||
resolveWslInteropSpawnCwd()
|
||||
)
|
||||
}
|
||||
|
||||
const drivePath = (...parts: string[]): string =>
|
||||
`${letter}:${linuxBase.replace(/\//g, '\\')}\\${parts.join('\\')}`
|
||||
const linuxPath = (...parts: string[]): string => [linuxBase, ...parts].join('/')
|
||||
const repoRow = (id: string, path: string): Repo => ({
|
||||
id,
|
||||
path,
|
||||
displayName: id,
|
||||
badgeColor: '#000',
|
||||
addedAt: 0
|
||||
})
|
||||
const drives = (): WslMappedDrive[] => [{ letter, share: SHARE }]
|
||||
|
||||
describe.runIf(RUN)('a drive letter mapped to a real WSL2 distro share', () => {
|
||||
beforeAll(async () => {
|
||||
const home = await guest('printf %s "$HOME"')
|
||||
linuxBase = `${home}/${LANE_DIR}`
|
||||
const commit = 'git -c user.email=lane@orca -c user.name=lane commit -q --allow-empty -m init'
|
||||
// App: no worktrees. LinuxTree: a worktree WSL Git created. WinTree: one Git for Windows adds below.
|
||||
await guest(
|
||||
`set -e; rm -rf "${linuxBase}"; mkdir -p "${linuxBase}"; cd "${linuxBase}"; ` +
|
||||
`for r in App LinuxTree WinTree; do git init -q "$r"; (cd "$r" && ${commit}); done; ` +
|
||||
`(cd LinuxTree && git worktree add -q "${linuxBase}/LinuxTree-wt")`
|
||||
)
|
||||
letter = [...'ZYXWVUTSRQPONM'].find((candidate) => !existsSync(`${candidate}:\\`)) ?? ''
|
||||
expect(letter, 'no free drive letter on this runner').not.toBe('')
|
||||
await run(net, ['use', `${letter}:`, SHARE, '/persistent:no'])
|
||||
mapped = true
|
||||
console.log(`[mapped-drive-lane] ${letter}: -> ${SHARE}; repos under ${linuxBase}`)
|
||||
}, SHARE_TIMEOUT_MS * 3)
|
||||
|
||||
afterAll(async () => {
|
||||
if (mapped) {
|
||||
await run(net, ['use', `${letter}:`, '/delete', '/y']).catch((error: unknown) =>
|
||||
console.warn(error)
|
||||
)
|
||||
}
|
||||
if (linuxBase) {
|
||||
await guest(`rm -rf "${linuxBase}"`).catch((error: unknown) => console.warn(error))
|
||||
}
|
||||
}, SHARE_TIMEOUT_MS)
|
||||
|
||||
it('sees the distro repo through the drive letter', () => {
|
||||
expect(
|
||||
existsSync(drivePath('App', '.git')),
|
||||
`${drivePath('App', '.git')} is not readable through ${letter}:`
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
it(
|
||||
'resolves the letter to the distro share with every reader',
|
||||
async () => {
|
||||
const fresh = await readWslMappedDriveShareNow(letter, undefined, SHARE_TIMEOUT_MS)
|
||||
console.log(`[mapped-drive-lane] fresh read: ${JSON.stringify(fresh)}`)
|
||||
expect(fresh, 'the fresh read did not answer').not.toBe('unverifiable')
|
||||
const share = fresh === 'unverifiable' ? null : fresh.share
|
||||
expect(
|
||||
wslMappedDriveMatches(share, DISTRO, undefined),
|
||||
`fresh share ${share} is not in ${DISTRO}`
|
||||
).toBe(true)
|
||||
expect(parseWslUncPath(share ?? '')?.linuxPath ?? '/', 'the drive maps the distro root').toBe(
|
||||
'/'
|
||||
)
|
||||
const classified = await classifyWslMappedDrive(letter)
|
||||
expect(wslMappedDriveMatches(classified?.share ?? null, DISTRO, undefined), 'classify').toBe(
|
||||
true
|
||||
)
|
||||
const viaResolver = await resolveWslMappedDrivePath(drivePath('App'))
|
||||
expect(parseWslUncPath(viaResolver ?? '')?.linuxPath, 'the cached resolver').toBe(
|
||||
linuxPath('App')
|
||||
)
|
||||
const read = await readWslMoveMappedDrives(
|
||||
{ repos: [repoRow('app', drivePath('App'))], folderWorkspaces: [] },
|
||||
DISTRO,
|
||||
{
|
||||
classify: (l) => classifyWslMappedDrive(l),
|
||||
readNow: (l) => readWslMappedDriveShareNow(l)
|
||||
}
|
||||
)
|
||||
expect(
|
||||
read.mappedDrives.map((drive) => drive.letter),
|
||||
'the mover reads the mapping'
|
||||
).toEqual([letter])
|
||||
},
|
||||
SHARE_TIMEOUT_MS * 2
|
||||
)
|
||||
|
||||
it('puts the drive-letter repo in the move scope only with the mapping', () => {
|
||||
const state = {
|
||||
repos: [repoRow('app', drivePath('App'))],
|
||||
folderWorkspaces: [],
|
||||
projectGroups: []
|
||||
}
|
||||
expect(collectWslMoveScope(state, DISTRO, { mappedDrives: drives() }).repoIds).toEqual(['app'])
|
||||
expect(
|
||||
collectWslMoveScope(state, DISTRO).repoIds,
|
||||
'unmapped, the drive path is not WSL'
|
||||
).toEqual([])
|
||||
})
|
||||
|
||||
it('maps drive paths and worktree ids to the Linux paths the host holds', () => {
|
||||
const rewriter = createUncToLinuxPathRewriter(DISTRO, drives())
|
||||
expect(rewriter.path(drivePath('App', 'src'), 'absolute')).toBe(linuxPath('App', 'src'))
|
||||
expect(rewriteOrcadMigrationWorktreeId(`app::${drivePath('App')}`, rewriter)).toBe(
|
||||
`app::${linuxPath('App')}`
|
||||
)
|
||||
expect(toWslDistroUncPath(drivePath('App'), drives())).toBe(
|
||||
`${SHARE}${linuxPath('App').replace(/\//g, '\\')}`
|
||||
)
|
||||
const normalize = createWslMoveStringNormalizer({
|
||||
distro: DISTRO,
|
||||
hostAliases: [],
|
||||
mappedDrives: drives()
|
||||
})
|
||||
expect(normalize(`app::${drivePath('App')}`)).toBe(
|
||||
normalize(`app::${toWslDistroUncPath(drivePath('App'), drives())}`)
|
||||
)
|
||||
})
|
||||
|
||||
it(
|
||||
'refuses a repo whose worktree Git for Windows added, and passes WSL Git’s',
|
||||
async () => {
|
||||
const git = existsSync(gitForWindows) ? gitForWindows : 'git.exe'
|
||||
// The share's owner is not this Windows user; the gate reads links, not ownership.
|
||||
await run(
|
||||
git,
|
||||
['-c', 'safe.directory=*', 'worktree', 'add', '--quiet', drivePath('WinTree-wt')],
|
||||
drivePath('WinTree')
|
||||
)
|
||||
const admin = drivePath('WinTree', '.git', 'worktrees')
|
||||
const links = readdirSync(admin).map((entry) =>
|
||||
readFileSync(join(admin, entry, 'gitdir'), 'utf8').trim()
|
||||
)
|
||||
console.log(`[mapped-drive-lane] Git for Windows wrote: ${JSON.stringify(links)}`)
|
||||
const share = (name: string): string => toWslDistroUncPath(drivePath(name), drives())
|
||||
expect(
|
||||
await windowsGitWorktreeVerdict(share('WinTree'), DISTRO),
|
||||
'Git for Windows worktree'
|
||||
).toBe('windows-git-worktrees')
|
||||
expect(await windowsGitWorktreeVerdict(share('LinuxTree'), DISTRO), 'WSL Git worktree').toBe(
|
||||
'ok'
|
||||
)
|
||||
expect(await windowsGitWorktreeVerdict(share('App'), DISTRO), 'no worktrees').toBe('ok')
|
||||
const refusals = await findWindowsGitRefusals(
|
||||
[
|
||||
repoRow('win', drivePath('WinTree')),
|
||||
repoRow('linux', drivePath('LinuxTree')),
|
||||
repoRow('app', drivePath('App'))
|
||||
],
|
||||
DISTRO,
|
||||
drives(),
|
||||
windowsGitWorktreeVerdict
|
||||
)
|
||||
expect(Object.fromEntries(refusals)).toEqual({ win: 'windows-git-worktrees' })
|
||||
},
|
||||
SHARE_TIMEOUT_MS * 2
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user