test(session): keep persistence fixture inventory keys portable

The accepted-baseline tests inventory temporary files with keys produced by
the host path.join. On Windows those keys contain backslashes, but the status
lookup and acknowledgement-preservation filters use repository-style slash
paths. Windows coverage therefore reads undefined for the status assertion;
the filtered preservation loops also select no files on that platform.

Use posix.join for logical inventory keys while keeping native path.join for
filesystem access. All platforms now exercise the same status lookup and
preservation assertions. This is confined to the test helper and changes no
production admission rule, compatibility policy, schema, or recorded fixture.
This commit is contained in:
Tianyi Cui committed 2026-09-19 00:07:18 +08:00
1 parent e134ba8765
commit bd5b1cd44f
1 file changed
+2 -2
+2 -2
View File
@@ -3,7 +3,7 @@
import { spawnSync } from 'node:child_process'
import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join, resolve } from 'node:path'
import { join, posix, resolve } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import { canonicalizeSchema, schemaDigest } from './persistence-schema-model.ts'
import type { PersistenceRoot, PersistenceSchemaInventory, SchemaNode, SchemaProperty, SourceCompatibility } from './persistence-schema-model.ts'
@@ -179,7 +179,7 @@ function contents(root: string): Record<string, string> {
const files: Record<string, string> = {}
const visit = (directory: string): void => {
for (const entry of readdirSync(join(root, directory), { withFileTypes: true })) {
const path = join(directory, entry.name)
const path = posix.join(directory, entry.name)
if (entry.isDirectory()) visit(path)
else files[path] = readFileSync(join(root, path), 'utf8')
}