test(docs): avoid duplicate fixture cleanup

This commit is contained in:
Tianyi Cui 2026-08-23 15:55:46 +08:00
parent 4bc6f4bdf7
commit 97938582e5

View file

@ -3,18 +3,12 @@
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { dirname, join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import { describe, expect, it, onTestFinished } from 'vitest'
import { auditSubsystemPages } from './verify-subsystem-pages.ts'
const roots: string[] = []
afterEach(() => {
for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true })
})
function fixture(): string {
const root = mkdtempSync(join(tmpdir(), 'dsh-subsystem-pages-'))
roots.push(root)
onTestFinished(() => rmSync(root, { recursive: true, force: true }))
return root
}