优化
This commit is contained in:
@@ -5,6 +5,8 @@ import test from 'node:test'
|
||||
|
||||
const source = readFileSync(new URL('./agents-index-contract.ps1', import.meta.url), 'utf8').replaceAll('\r\n', '\n')
|
||||
const registry = readFileSync(new URL('../../docs/独立任务协作登记.md', import.meta.url), 'utf8')
|
||||
const currentGroup = registry.match(/^## 2026-10-04 用户确认的三个独立执行对话(当前派工)\r?\n[\s\S]*?(?=^## |$(?![\s\S]))/m)?.[0]
|
||||
assert.ok(currentGroup, 'mutations must target their own authorized group')
|
||||
const contract = source.split('# BEGIN CURRENT TEST REGISTRY CONTRACT\n')[1]?.split('# END CURRENT TEST REGISTRY CONTRACT')[0]
|
||||
assert.ok(contract, 'test exercises the production PowerShell registry validator')
|
||||
function failures(text) {
|
||||
@@ -17,7 +19,10 @@ function Assert-NotContains([string]$text,[string]$needle,[string]$scope){if($te
|
||||
${contract}
|
||||
Assert-TestTaskRegistry ([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${encoded}')))
|
||||
ConvertTo-Json -InputObject @($script:failures) -Compress`
|
||||
return JSON.parse(execFileSync('pwsh', ['-NoProfile', '-NonInteractive', '-Command', command], { encoding: 'utf8' }))
|
||||
// Large registries exceed Windows command-line limits; the generated harness is passed over stdin.
|
||||
return JSON.parse(execFileSync('pwsh', ['-NoProfile', '-NonInteractive', '-Command',
|
||||
'$registryHarness = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String([Console]::In.ReadToEnd())); & ([ScriptBlock]::Create($registryHarness))'],
|
||||
{ encoding: 'utf8', input: Buffer.from(command).toString('base64') }))
|
||||
}
|
||||
test('actual explicitly authorized TEST registry passes the production validator', () => {
|
||||
assert.deepEqual(failures(registry), [])
|
||||
@@ -32,4 +37,5 @@ for (const [name, mutate] of [
|
||||
['obsolete empty status', s => s + '\n当前无登记任务'],
|
||||
['foreign project identity', s => s + '\n6f874ec3-d3b2-49bd-8625-327f4d685f98'],
|
||||
['retired controller', s => s + '\n01a0194a-259c-7171-8967-074731a27618'],
|
||||
]) test(`production validator rejects ${name}`, () => assert.ok(failures(mutate(registry)).length > 0))
|
||||
]) test(`production validator rejects ${name}`, () =>
|
||||
assert.ok(failures(registry.replace(currentGroup, mutate(currentGroup))).length > 0))
|
||||
|
||||
Reference in New Issue
Block a user