velocious 1.0.667 → 1.0.668

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +27 -7
  2. package/build/configuration.js +23 -1
  3. package/build/environment-handlers/node/cli/commands/test/timing-manifest/merge.js +2 -48
  4. package/build/environment-handlers/node/cli/commands/test.js +17 -69
  5. package/build/frontend-models/websocket-channel.js +18 -0
  6. package/build/http-server/client/websocket-session.js +41 -4
  7. package/build/http-server/websocket-channel.js +14 -0
  8. package/build/http-server/websocket-event-log-store.js +85 -12
  9. package/build/http-server/websocket-events-host.js +14 -6
  10. package/build/src/configuration.d.ts +18 -1
  11. package/build/src/configuration.d.ts.map +1 -1
  12. package/build/src/configuration.js +22 -2
  13. package/build/src/environment-handlers/node/cli/commands/test/timing-manifest/merge.d.ts.map +1 -1
  14. package/build/src/environment-handlers/node/cli/commands/test/timing-manifest/merge.js +3 -47
  15. package/build/src/environment-handlers/node/cli/commands/test.d.ts +2 -28
  16. package/build/src/environment-handlers/node/cli/commands/test.d.ts.map +1 -1
  17. package/build/src/environment-handlers/node/cli/commands/test.js +10 -61
  18. package/build/src/frontend-models/websocket-channel.d.ts +9 -0
  19. package/build/src/frontend-models/websocket-channel.d.ts.map +1 -1
  20. package/build/src/frontend-models/websocket-channel.js +16 -1
  21. package/build/src/http-server/client/websocket-session.d.ts +25 -2
  22. package/build/src/http-server/client/websocket-session.d.ts.map +1 -1
  23. package/build/src/http-server/client/websocket-session.js +40 -5
  24. package/build/src/http-server/websocket-channel.d.ts +11 -0
  25. package/build/src/http-server/websocket-channel.d.ts.map +1 -1
  26. package/build/src/http-server/websocket-channel.js +14 -1
  27. package/build/src/http-server/websocket-event-log-store.d.ts +60 -41
  28. package/build/src/http-server/websocket-event-log-store.d.ts.map +1 -1
  29. package/build/src/http-server/websocket-event-log-store.js +79 -12
  30. package/build/src/http-server/websocket-events-host.d.ts +10 -3
  31. package/build/src/http-server/websocket-events-host.d.ts.map +1 -1
  32. package/build/src/http-server/websocket-events-host.js +14 -7
  33. package/build/src/testing/test-files-finder.d.ts +13 -116
  34. package/build/src/testing/test-files-finder.d.ts.map +1 -1
  35. package/build/src/testing/test-files-finder.js +26 -296
  36. package/build/src/testing/test-filter-parser.d.ts +32 -22
  37. package/build/src/testing/test-filter-parser.d.ts.map +1 -1
  38. package/build/src/testing/test-filter-parser.js +25 -217
  39. package/build/src/testing/test-profile-activity.d.ts +1 -6
  40. package/build/src/testing/test-profile-activity.d.ts.map +1 -1
  41. package/build/src/testing/test-profile-activity.js +2 -12
  42. package/build/src/testing/test-profile-output.d.ts +1 -40
  43. package/build/src/testing/test-profile-output.d.ts.map +1 -1
  44. package/build/src/testing/test-profile-output.js +2 -217
  45. package/build/src/testing/test-profiler.d.ts +15 -659
  46. package/build/src/testing/test-profiler.d.ts.map +1 -1
  47. package/build/src/testing/test-profiler.js +35 -833
  48. package/build/src/testing/test-runner.d.ts +10 -1
  49. package/build/src/testing/test-runner.d.ts.map +1 -1
  50. package/build/src/testing/test-runner.js +26 -4
  51. package/build/src/testing/test-suite-splitter.d.ts +1 -128
  52. package/build/src/testing/test-suite-splitter.d.ts.map +1 -1
  53. package/build/src/testing/test-suite-splitter.js +2 -259
  54. package/build/src/testing/timing-manifest.d.ts +5 -93
  55. package/build/src/testing/timing-manifest.d.ts.map +1 -1
  56. package/build/src/testing/timing-manifest.js +4 -283
  57. package/build/src/testing/velocious-attempt-executor.d.ts.map +1 -1
  58. package/build/src/testing/velocious-attempt-executor.js +8 -2
  59. package/build/testing/test-files-finder.js +29 -345
  60. package/build/testing/test-filter-parser.js +29 -248
  61. package/build/testing/test-profile-activity.js +1 -12
  62. package/build/testing/test-profile-output.js +8 -253
  63. package/build/testing/test-profiler.js +38 -895
  64. package/build/testing/test-runner.js +33 -9
  65. package/build/testing/test-suite-splitter.js +1 -301
  66. package/build/testing/timing-manifest.js +10 -344
  67. package/build/testing/velocious-attempt-executor.js +7 -1
  68. package/package.json +3 -3
  69. package/scripts/test-browser.js +29 -6
  70. package/scripts/verify-docker-dev-environment.js +13 -1
  71. package/src/configuration.js +23 -1
  72. package/src/environment-handlers/node/cli/commands/test/timing-manifest/merge.js +2 -48
  73. package/src/environment-handlers/node/cli/commands/test.js +17 -69
  74. package/src/frontend-models/websocket-channel.js +18 -0
  75. package/src/http-server/client/websocket-session.js +41 -4
  76. package/src/http-server/websocket-channel.js +14 -0
  77. package/src/http-server/websocket-event-log-store.js +85 -12
  78. package/src/http-server/websocket-events-host.js +14 -6
  79. package/src/testing/test-files-finder.js +29 -345
  80. package/src/testing/test-filter-parser.js +29 -248
  81. package/src/testing/test-profile-activity.js +1 -12
  82. package/src/testing/test-profile-output.js +8 -253
  83. package/src/testing/test-profiler.js +38 -895
  84. package/src/testing/test-runner.js +33 -9
  85. package/src/testing/test-suite-splitter.js +1 -301
  86. package/src/testing/timing-manifest.js +10 -344
  87. package/src/testing/velocious-attempt-executor.js +7 -1
@@ -1,346 +1,12 @@
1
1
  // @ts-check
2
2
 
3
- import sha256Hex from "../utils/sha256-hex.js"
4
-
5
- /** @typedef {Record<string, number>} TimingManifest */
6
-
7
- /**
8
- * ValidatedProfileShard type.
9
- * @typedef {object} ValidatedProfileShard
10
- * @property {number} discoveredFileCount - Complete pre-shard file count.
11
- * @property {number} fileCount - Selected post-shard file count.
12
- * @property {number} groupNumber - One-indexed shard number.
13
- * @property {number} groups - Complete shard count.
14
- * @property {string} pathBase - Profiling path-base semantics.
15
- * @property {string} testFileSetHash - Complete canonical file-set identity.
16
- * @property {TimingManifest} timingManifest - Canonical shard timing map.
17
- */
18
-
19
- /**
20
- * TestProfileTimingManifestInput type.
21
- * @typedef {object} TestProfileTimingManifestInput
22
- * @property {ReturnType<typeof JSON.parse>} profile - Parsed rich test profile.
23
- * @property {string} source - Human-readable input source for validation errors.
24
- */
25
-
26
- /**
27
- * Canonicalizes a timing-manifest path relative to its profiling base.
28
- * @param {string} filePath - Candidate relative path.
29
- * @returns {string} - Portable canonical path.
30
- */
31
- export function canonicalTimingManifestPath(filePath) {
32
- if (typeof filePath !== "string" || filePath.length === 0) {
33
- throw new Error("Timing manifest keys must be non-empty relative paths")
34
- }
35
-
36
- const portablePath = filePath.replaceAll("\\", "/")
37
-
38
- if (portablePath.startsWith("/") || /^[A-Za-z]:/.test(portablePath)) {
39
- throw new Error(`Timing manifest key must be a relative path: ${filePath}`)
40
- }
41
-
42
- const segments = []
43
-
44
- for (const segment of portablePath.split("/")) {
45
- if (!segment || segment === ".") continue
46
-
47
- if (segment === "..") {
48
- if (segments.length === 0) {
49
- throw new Error(`Timing manifest key must be a non-escaping relative path: ${filePath}`)
50
- }
51
-
52
- segments.pop()
53
- continue
54
- }
55
-
56
- segments.push(segment)
57
- }
58
-
59
- if (segments.length === 0) {
60
- throw new Error(`Timing manifest key must be a non-empty relative path: ${filePath}`)
61
- }
62
-
63
- return segments.join("/")
64
- }
65
-
66
- /**
67
- * Compares timing-manifest paths by JavaScript code units without locale rules.
68
- * @param {string} filePathA - First path.
69
- * @param {string} filePathB - Second path.
70
- * @returns {number} - Negative, zero, or positive ordering result.
71
- */
72
- export function compareTimingManifestPaths(filePathA, filePathB) {
73
- if (filePathA === filePathB) return 0
74
-
75
- return filePathA < filePathB ? -1 : 1
76
- }
77
-
78
- /**
79
- * Validates and sorts a plain timing manifest.
80
- * @param {ReturnType<typeof JSON.parse>} timingManifest - Parsed timing manifest.
81
- * @param {{source?: string}} [options] - Validation context.
82
- * @returns {TimingManifest} - Canonical sorted timing manifest.
83
- */
84
- export function validateTimingManifest(timingManifest, {source = "timing manifest"} = {}) {
85
- if (!timingManifest || typeof timingManifest !== "object" || Array.isArray(timingManifest)) {
86
- throw new Error(`${source} must be a plain JSON object mapping relative paths to durations`)
87
- }
88
-
89
- /** @type {Map<string, {duration: number, originalPath: string}>} */
90
- const entries = new Map()
91
-
92
- for (const [originalPath, duration] of Object.entries(timingManifest)) {
93
- if (typeof duration !== "number" || !Number.isFinite(duration) || duration < 0) {
94
- throw new Error(`${source} has an invalid duration for ${originalPath}`)
95
- }
96
-
97
- const canonicalPath = canonicalTimingManifestPath(originalPath)
98
- const existing = entries.get(canonicalPath)
99
-
100
- if (existing) {
101
- throw new Error(`${source} has a normalized path collision between ${existing.originalPath} and ${originalPath}`)
102
- }
103
-
104
- entries.set(canonicalPath, {duration, originalPath})
105
- }
106
-
107
- return Object.fromEntries(
108
- [...entries.entries()]
109
- .sort(([filePathA], [filePathB]) => compareTimingManifestPaths(filePathA, filePathB))
110
- .map(([filePath, entry]) => [filePath, entry.duration])
111
- )
112
- }
113
-
114
- /**
115
- * Returns an opaque deterministic identity for a complete canonical test-file set.
116
- * @param {string[]} filePaths - Paths relative to one profiling base.
117
- * @returns {string} - SHA-256 file-set identity.
118
- */
119
- export function timingManifestFileSetHash(filePaths) {
120
- const pathManifest = Object.fromEntries(filePaths.map((filePath) => [filePath, 0]))
121
- const canonicalPaths = Object.keys(validateTimingManifest(pathManifest, {source: "test file set"}))
122
- const identity = `velocious.test-file-set.v1\0${canonicalPaths.join("\0")}`
123
-
124
- return `sha256:${sha256Hex(identity)}`
125
- }
126
-
127
- /**
128
- * Validates that a parsed JSON value is a non-array object.
129
- * @param {ReturnType<typeof JSON.parse>} value - Candidate object.
130
- * @param {string} message - Validation error message.
131
- * @returns {void}
132
- */
133
- function assertJsonObject(value, message) {
134
- if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(message)
135
- }
136
-
137
- /**
138
- * Requires unfiltered, non-focused profile selection metadata.
139
- * @param {ReturnType<typeof JSON.parse>} selection - Rich profile selection.
140
- * @param {string} source - Input source.
141
- * @returns {void}
142
- */
143
- function assertCompleteSelection(selection, source) {
144
- if (selection.focused !== false) throw new Error(`${source} must not be a focused test profile`)
145
-
146
- const selectionFilters = [
147
- [selection.includeTagCount, 0],
148
- [selection.excludeTagCount, 0],
149
- [selection.hasExampleFilters, false],
150
- [selection.hasLineFilters, false]
151
- ]
152
-
153
- if (selectionFilters.some(([value, expected]) => value !== expected)) {
154
- throw new Error(`${source} must not be a filtered test profile`)
155
- }
156
- }
157
-
158
- /**
159
- * Validates shard numbering metadata.
160
- * @param {ReturnType<typeof JSON.parse>} shard - Candidate shard selection.
161
- * @param {string} source - Input source.
162
- * @returns {{groupNumber: number, groups: number}} - Validated shard numbers.
163
- */
164
- function validatedShardNumbers(shard, source) {
165
- assertJsonObject(shard, `${source} is missing shard metadata`)
166
-
167
- if (!Number.isInteger(shard.groups) || shard.groups < 1) {
168
- throw new Error(`${source} has an invalid shard group count`)
169
- }
170
-
171
- if (!Number.isInteger(shard.groupNumber) || shard.groupNumber < 1 || shard.groupNumber > shard.groups) {
172
- throw new Error(`${source} has an invalid shard number`)
173
- }
174
-
175
- return {groupNumber: shard.groupNumber, groups: shard.groups}
176
- }
177
-
178
- /**
179
- * Validates a non-negative integer selection count.
180
- * @param {ReturnType<typeof JSON.parse>} value - Candidate count.
181
- * @param {string} message - Validation error message.
182
- * @returns {number} - Validated count.
183
- */
184
- function validatedSelectionCount(value, message) {
185
- if (!Number.isInteger(value) || value < 0) throw new Error(message)
186
-
187
- return value
188
- }
189
-
190
- /**
191
- * Validates the selection identity used across shard profiles.
192
- * @param {ReturnType<typeof JSON.parse>} selection - Rich profile selection.
193
- * @param {string} source - Input source.
194
- * @returns {{pathBase: string, testFileSetHash: string}} - Validated identity.
195
- */
196
- function validatedSelectionIdentity(selection, source) {
197
- if (!["configuration-directory", "test-directory"].includes(selection.pathBase)) {
198
- throw new Error(`${source} has an invalid timing manifest path base`)
199
- }
200
-
201
- if (typeof selection.testFileSetHash !== "string" || !/^sha256:[a-f0-9]{64}$/.test(selection.testFileSetHash)) {
202
- throw new Error(`${source} has an invalid test file set identity`)
203
- }
204
-
205
- return {pathBase: selection.pathBase, testFileSetHash: selection.testFileSetHash}
206
- }
207
-
208
- /**
209
- * Validates one rich profile and returns its aggregation contract.
210
- * @param {TestProfileTimingManifestInput} input - Profile input.
211
- * @returns {ValidatedProfileShard} - Validated shard contract.
212
- */
213
- function validatedProfileShard(input) {
214
- const {profile, source} = input
215
-
216
- assertJsonObject(profile, `${source} must be a rich Velocious test profile`)
217
-
218
- if (profile.schema !== "velocious.test-profile" || profile.schemaVersion !== 1) {
219
- throw new Error(`${source} has an incompatible Velocious test profile schema`)
220
- }
221
-
222
- if (profile.status !== "passed") throw new Error(`${source} must have passed status for timing aggregation`)
223
-
224
- const selection = profile.selection
225
-
226
- assertJsonObject(selection, `${source} is missing test profile selection metadata`)
227
- assertCompleteSelection(selection, source)
228
- const {groupNumber, groups} = validatedShardNumbers(selection.shard, source)
229
- const discoveredFileCount = validatedSelectionCount(
230
- selection.discoveredFileCount,
231
- `${source} has an invalid pre-shard discovered file count`
232
- )
233
- const fileCount = validatedSelectionCount(
234
- selection.fileCount,
235
- `${source} has an invalid post-shard file count`
236
- )
237
- const {pathBase, testFileSetHash} = validatedSelectionIdentity(selection, source)
238
-
239
- const timingManifest = validateTimingManifest(profile.timingManifest, {source: `${source} timing manifest`})
240
-
241
- if (Object.keys(timingManifest).length !== fileCount) {
242
- throw new Error(`${source} timing manifest does not match its post-shard file count`)
243
- }
244
-
245
- return {
246
- discoveredFileCount,
247
- fileCount,
248
- groupNumber,
249
- groups,
250
- pathBase,
251
- testFileSetHash,
252
- timingManifest
253
- }
254
- }
255
-
256
- /**
257
- * Requires one shard to describe the same complete selection as the first.
258
- * @param {ValidatedProfileShard} shard - Candidate shard.
259
- * @param {ValidatedProfileShard} expected - First shard contract.
260
- * @param {string} source - Candidate source.
261
- * @returns {void}
262
- */
263
- function assertCompatibleShard(shard, expected, source) {
264
- if (shard.groups !== expected.groups) throw new Error(`${source} has a different shard group count`)
265
- if (shard.pathBase !== expected.pathBase) throw new Error(`${source} has a different timing manifest path base`)
266
- if (shard.discoveredFileCount !== expected.discoveredFileCount) throw new Error(`${source} has a different discovered file count`)
267
- if (shard.testFileSetHash !== expected.testFileSetHash) throw new Error(`${source} has a different test file set identity`)
268
- }
269
-
270
- /**
271
- * Adds one validated shard timing map without allowing duplicate canonical keys.
272
- * @param {object} args - Merge state.
273
- * @param {Map<string, {duration: number, source: string}>} args.mergedEntries - Destination timing entries.
274
- * @param {ValidatedProfileShard} args.shard - Candidate shard.
275
- * @param {string} args.source - Candidate source.
276
- * @returns {void}
277
- */
278
- function mergeShardTimingManifest({mergedEntries, shard, source}) {
279
- for (const [filePath, duration] of Object.entries(shard.timingManifest)) {
280
- const existingEntry = mergedEntries.get(filePath)
281
-
282
- if (existingEntry) {
283
- throw new Error(`Duplicate timing path ${filePath} in ${existingEntry.source} and ${source}`)
284
- }
285
-
286
- mergedEntries.set(filePath, {duration, source})
287
- }
288
- }
289
-
290
- /**
291
- * Merges a complete compatible set of rich Velocious shard profiles.
292
- * @param {TestProfileTimingManifestInput[]} inputs - Parsed profile documents and sources.
293
- * @returns {TimingManifest} - Complete sorted plain timing manifest.
294
- */
295
- export function mergeTestProfileTimingManifests(inputs) {
296
- if (inputs.length === 0) throw new Error("At least one rich test profile is required")
297
-
298
- const shards = inputs.map((input) => validatedProfileShard(input))
299
- const expected = shards[0]
300
- /** @type {Map<number, string>} */
301
- const shardSources = new Map()
302
- /** @type {Map<string, {duration: number, source: string}>} */
303
- const mergedEntries = new Map()
304
- let selectedFileCount = 0
305
-
306
- for (let index = 0; index < shards.length; index++) {
307
- const shard = shards[index]
308
- const source = inputs[index].source
309
-
310
- assertCompatibleShard(shard, expected, source)
311
-
312
- const existingShardSource = shardSources.get(shard.groupNumber)
313
-
314
- if (existingShardSource) {
315
- throw new Error(`Duplicate shard ${shard.groupNumber} in ${existingShardSource} and ${source}`)
316
- }
317
-
318
- shardSources.set(shard.groupNumber, source)
319
- selectedFileCount += shard.fileCount
320
- mergeShardTimingManifest({mergedEntries, shard, source})
321
- }
322
-
323
- const missingShardNumbers = []
324
-
325
- for (let groupNumber = 1; groupNumber <= expected.groups; groupNumber++) {
326
- if (!shardSources.has(groupNumber)) missingShardNumbers.push(groupNumber)
327
- }
328
-
329
- if (missingShardNumbers.length > 0) {
330
- throw new Error(`Missing shard profiles: ${missingShardNumbers.join(", ")}`)
331
- }
332
-
333
- if (selectedFileCount !== expected.discoveredFileCount || mergedEntries.size !== expected.discoveredFileCount) {
334
- throw new Error("Merged timing manifest does not cover the complete file universe")
335
- }
336
-
337
- const merged = Object.fromEntries(
338
- [...mergedEntries].map(([filePath, entry]) => [filePath, entry.duration])
339
- )
340
-
341
- if (timingManifestFileSetHash(Object.keys(merged)) !== expected.testFileSetHash) {
342
- throw new Error("Merged timing manifest does not match the complete file universe")
343
- }
344
-
345
- return validateTimingManifest(merged, {source: "merged timing manifest"})
346
- }
3
+ /** @typedef {import("@velocious/testing/node").TimingManifest} TimingManifest */
4
+ /** @typedef {import("@velocious/testing/node").TestProfileTimingManifestInput} TestProfileTimingManifestInput */
5
+
6
+ export {
7
+ canonicalTimingManifestPath,
8
+ compareTimingManifestPaths,
9
+ mergeTestProfileTimingManifests,
10
+ timingManifestFileSetHash,
11
+ validateTimingManifest
12
+ } from "@velocious/testing/node"
@@ -148,10 +148,16 @@ export default class VelociousAttemptExecutor {
148
148
  await testRunner.registerTransactionalTenant(args, transactionalTenantRegistrations)
149
149
  }
150
150
  const profiler = testRunner._profiler
151
+ const profileTestData = {
152
+ ...test,
153
+ filePath: testData.filePath,
154
+ line: testData.line,
155
+ ownerFilePath: testData.ownerFilePath ?? metadata.ownerFilePath
156
+ }
151
157
  const profileAttempt = profiler?.startAttempt({
152
158
  descriptions,
153
159
  attemptNumber,
154
- testData,
160
+ testData: profileTestData,
155
161
  testDescription
156
162
  })
157
163