Open History to see the last commit
1import assert from 'node:assert/strict'
2import { mkdir, readFile, writeFile } from 'node:fs/promises'
3import { createRequire } from 'node:module'
4import { spawnSync } from 'node:child_process'
5import {
6 upstreamTests,
7 supplementalTests,
8} from '../tests/conformance/profile.mjs'
9
10const require = createRequire(import.meta.url)
11const pinned = JSON.parse(
12 await readFile(
13 require.resolve('@durable-streams/server-conformance-tests/package.json'),
14 'utf8'
15 )
16)
17assert.equal(
18 pinned.version,
19 '0.3.7',
20 'Review profile selection when upgrading upstream'
21)
22const target = '.artifacts/native-server-conformance'
23await mkdir(target, { recursive: true })
24const reportPath = `${target}/vitest.json`
25const result = spawnSync(
26 'pnpm',
27 [
28 'exec',
29 'vitest',
30 'run',
31 '--config',
32 'vitest.conformance.config.ts',
33 '--reporter=dot',
34 '--reporter=json',
35 `--outputFile=${reportPath}`,
36 ],
37 { stdio: 'inherit' }
38)
39assert.equal(result.status, 0, 'Native server conformance profile failed')
40const report = JSON.parse(await readFile(reportPath, 'utf8'))
41const assertions = report.testResults.flatMap((file) => file.assertionResults)
42const expected = ['memory', 'objects'].flatMap((backend) => [
43 ...upstreamTests.map(
44 (name) => `production JSON read/store: ${backend} ${name}`
45 ),
46 ...supplementalTests.map((name) => `JSON read profile: ${backend} ${name}`),
47])
48assert.equal(new Set(expected).size, expected.length)
49for (const name of expected) {
50 const selected = assertions.filter((test) => test.fullName === name)
51 assert.equal(
52 selected.length,
53 1,
54 `Missing or duplicate selected test: ${name}`
55 )
56 assert.equal(
57 selected[0].status,
58 'passed',
59 `Required test did not pass: ${name}`
60 )
61}
62assert.equal(
63 assertions.filter((test) => test.status === 'passed').length,
64 expected.length,
65 'Update the reviewed profile inventory for additional tests'
66)
67const excluded = assertions
68 .filter((test) => !expected.includes(test.fullName))
69 .map((test) => test.fullName)
70const summary = {
71 package: `${pinned.name}@${pinned.version}`,
72 scope:
73 'Production JSON read/HEAD/long-poll/SSE and memory/object store profile; test-only producers',
74 upstreamPassed: upstreamTests.length * 2,
75 supplementalPassed: supplementalTests.length * 2,
76 excludedByProfile: excluded.length,
77 selected: expected,
78 excluded,
79}
80await writeFile(
81 `${target}/summary.json`,
82 JSON.stringify(summary, null, 2) + '\n'
83)
84console.log(
85 `Native JSON profile: ${summary.upstreamPassed} upstream + ${summary.supplementalPassed} supplemental passed; ${excluded.length} registered tests excluded by profile; full server conformance is not claimed`
86)