supercov 4.25.0 → 4.27.0
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.
- package/README.md +1 -0
- package/bin/arguments.js +26 -0
- package/bin/supercov.js +2 -1
- package/docs/cli.md +16 -0
- package/docs/workspace-isolation.md +3 -0
- package/package.json +11 -10
- package/runtime/javascript/atomic.mjs +121 -6
- package/runtime/javascript/playwright.mjs +76 -49
- package/runtime/javascript/register.mjs +4 -1
- package/runtime/javascript/runtime.mjs +326 -155
- package/runtime/javascript/snapshots.mjs +47 -0
- package/runtime/javascript/vitest.mjs +14 -5
|
@@ -138,6 +138,17 @@ function backgroundEvidencePath(runId, processId = typeof process === "undefined
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
// dist/runtime.js
|
|
141
|
+
// The collections a probe records into, called through the built-in methods
|
|
142
|
+
// as they were when the runtime loaded: a test that spies on
|
|
143
|
+
// Map.prototype.set counts the calls its own code makes, and Supercov's
|
|
144
|
+
// first hits made three more, failing a test that passes without it.
|
|
145
|
+
var builtinMapGet = Map.prototype.get;
|
|
146
|
+
var builtinMapSet = Map.prototype.set;
|
|
147
|
+
var builtinMapHas = Map.prototype.has;
|
|
148
|
+
var builtinSetAdd = Set.prototype.add;
|
|
149
|
+
var builtinSetHas = Set.prototype.has;
|
|
150
|
+
var builtinWeakMapGet = WeakMap.prototype.get;
|
|
151
|
+
var builtinWeakMapSet = WeakMap.prototype.set;
|
|
141
152
|
var runtimeGlobal = globalThis;
|
|
142
153
|
var runtimeInstanceToken = "__SUPERCOV_RUNTIME_INSTANCE__";
|
|
143
154
|
var runtimeInstance = runtimeInstanceToken === "__SUPERCOV_RUNTIME_INSTANCE__" ? "application" : runtimeInstanceToken;
|
|
@@ -161,16 +172,34 @@ function getFs() {
|
|
|
161
172
|
return void 0;
|
|
162
173
|
}
|
|
163
174
|
}
|
|
175
|
+
function emptyEventLog() {
|
|
176
|
+
return { type: [], id: [], vector: [], timestampMs: [], phaseId: [], environment: [] };
|
|
177
|
+
}
|
|
178
|
+
// The events as they were recorded, each the object hitEvent or
|
|
179
|
+
// decisionEvent built, in their key order.
|
|
180
|
+
function eventObjects(log) {
|
|
181
|
+
const events = new Array(log.id.length);
|
|
182
|
+
for (let position = 0; position < events.length; position += 1) {
|
|
183
|
+
const phaseId = log.phaseId[position];
|
|
184
|
+
events[position] = log.type[position] === "hit" ? hitEvent(log.id[position], log.timestampMs[position], phaseId, log.environment[position]) : decisionEvent(log.id[position], log.vector[position], log.timestampMs[position], phaseId, log.environment[position]);
|
|
185
|
+
}
|
|
186
|
+
return events;
|
|
187
|
+
}
|
|
164
188
|
function createState() {
|
|
165
189
|
var _a8, _b, _c, _d;
|
|
166
190
|
const state2 = {
|
|
167
191
|
decisions: /* @__PURE__ */ new Map(),
|
|
168
192
|
hits: /* @__PURE__ */ new Set(),
|
|
169
|
-
events:
|
|
193
|
+
// The events as columns, one entry per event: a first hit of every point
|
|
194
|
+
// of every test was an object of its own, millions on a large suite,
|
|
195
|
+
// turned into columns again for the evidence (eventColumns).
|
|
196
|
+
eventLog: emptyEventLog(),
|
|
170
197
|
// Per value-position logical expression (`a && b`, `a || b`, `a ?? b`): the distinct
|
|
171
198
|
// (right operand evaluated?, result truthy?) pairs seen, keyed by branch id.
|
|
172
199
|
logicals: /* @__PURE__ */ new Map(),
|
|
173
|
-
|
|
200
|
+
// The events already recorded, by phase: a hit by its id, anything else
|
|
201
|
+
// by its type and what tells it apart (eventSeen).
|
|
202
|
+
eventKeys: /* @__PURE__ */ new Map(),
|
|
174
203
|
bufferedAttempts: /* @__PURE__ */ new Set(),
|
|
175
204
|
serverBuffers: /* @__PURE__ */ new Map(),
|
|
176
205
|
persistedServerRecords: /* @__PURE__ */ new Set(),
|
|
@@ -182,8 +211,13 @@ function createState() {
|
|
|
182
211
|
backgroundSequence: 0,
|
|
183
212
|
runtimeSnapshots: false,
|
|
184
213
|
assertionPhases: /* @__PURE__ */ new Map(),
|
|
214
|
+
// Each registered file, held weakly where the engine can: only the
|
|
215
|
+
// epochs' wrap below reads them, to clear what live files remember.
|
|
185
216
|
probeV2Files: /* @__PURE__ */ new Set(),
|
|
186
|
-
|
|
217
|
+
probeV2FilesSweepAt: 1024,
|
|
218
|
+
// `e` is the epoch: every statement probe reads it by name, and a
|
|
219
|
+
// minifier keeps a property's name, so it is one letter in every bundle.
|
|
220
|
+
probeV2Clock: { e: Number.NaN, fast: false },
|
|
187
221
|
probeV2ContextEpochs: /* @__PURE__ */ new Map(),
|
|
188
222
|
probeV2NextEpoch: 1,
|
|
189
223
|
probeV2HookInstalled: false,
|
|
@@ -205,10 +239,8 @@ function createState() {
|
|
|
205
239
|
}
|
|
206
240
|
for (const id of (_c = stored.hits) != null ? _c : [])
|
|
207
241
|
state2.hits.add(id);
|
|
208
|
-
for (const event of (_d = stored.events) != null ? _d : [])
|
|
209
|
-
state2.
|
|
210
|
-
state2.eventKeys.add(eventKey(event));
|
|
211
|
-
}
|
|
242
|
+
for (const event of (_d = stored.events) != null ? _d : [])
|
|
243
|
+
recordEvent(state2, event.type, event.id, event.vector, event.timestampMs, event.phaseId, event.environment);
|
|
212
244
|
} catch (e) {
|
|
213
245
|
}
|
|
214
246
|
return state2;
|
|
@@ -248,20 +280,20 @@ function probeV2ContextKey(context) {
|
|
|
248
280
|
return `scope\0${attemptKey(context.scope)}\0${phase}`;
|
|
249
281
|
}
|
|
250
282
|
function activateProbeV2Key(key, force = false) {
|
|
251
|
-
let epoch = force ? void 0 : state.probeV2ContextEpochs
|
|
283
|
+
let epoch = force ? void 0 : builtinMapGet.call(state.probeV2ContextEpochs, key);
|
|
252
284
|
if (epoch === void 0) {
|
|
253
285
|
state.probeV2NextEpoch += 1;
|
|
254
286
|
if (state.probeV2NextEpoch >= 4294967295) {
|
|
255
287
|
state.probeV2NextEpoch = 1;
|
|
256
288
|
state.probeV2ContextEpochs.clear();
|
|
257
289
|
state.probeV2EpochGeneration = (state.probeV2EpochGeneration || 0) + 1;
|
|
258
|
-
for (const
|
|
290
|
+
for (const held of state.probeV2Files) {
|
|
291
|
+
const file = typeof held.deref === "function" ? held.deref() : held;
|
|
292
|
+
if (file === void 0)
|
|
293
|
+
continue;
|
|
259
294
|
file.hitEpochs.fill(0);
|
|
260
|
-
file.decisionObservationEpochs.fill(0);
|
|
261
|
-
file.decisionObservationCounts.fill(0);
|
|
262
|
-
file.decisionCompleteEpochs.fill(0);
|
|
263
295
|
for (const vectors of file.decisionEpochs) {
|
|
264
|
-
if (vectors
|
|
296
|
+
if (vectors.size === void 0)
|
|
265
297
|
vectors.fill(0);
|
|
266
298
|
else
|
|
267
299
|
vectors.clear();
|
|
@@ -269,9 +301,9 @@ function activateProbeV2Key(key, force = false) {
|
|
|
269
301
|
}
|
|
270
302
|
}
|
|
271
303
|
epoch = state.probeV2NextEpoch;
|
|
272
|
-
state.probeV2ContextEpochs
|
|
304
|
+
builtinMapSet.call(state.probeV2ContextEpochs, key, epoch);
|
|
273
305
|
}
|
|
274
|
-
state.probeV2Clock.
|
|
306
|
+
state.probeV2Clock.e = epoch;
|
|
275
307
|
return epoch;
|
|
276
308
|
}
|
|
277
309
|
// The async hook activates the current request's context before every
|
|
@@ -292,28 +324,51 @@ function activateProbeV2Context(context) {
|
|
|
292
324
|
state.probeV2ContextEpochCache = /* @__PURE__ */ new WeakMap();
|
|
293
325
|
state.probeV2EpochGeneration = 0;
|
|
294
326
|
}
|
|
295
|
-
const cached = state.probeV2ContextEpochCache
|
|
327
|
+
const cached = builtinWeakMapGet.call(state.probeV2ContextEpochCache, context);
|
|
296
328
|
if (cached !== void 0 && cached.generation === state.probeV2EpochGeneration) {
|
|
297
|
-
state.probeV2Clock.
|
|
329
|
+
state.probeV2Clock.e = cached.epoch;
|
|
298
330
|
return cached.epoch;
|
|
299
331
|
}
|
|
300
332
|
const epoch = activateProbeV2Key(probeV2ContextKey(context));
|
|
301
|
-
state.probeV2ContextEpochCache
|
|
333
|
+
builtinWeakMapSet.call(state.probeV2ContextEpochCache, context, { generation: state.probeV2EpochGeneration, epoch });
|
|
302
334
|
return epoch;
|
|
303
335
|
}
|
|
336
|
+
// While the speed benchmark times a run: how often a server's async hook ran
|
|
337
|
+
// and how often a probe then had to work out its context, said once when the
|
|
338
|
+
// process ends.
|
|
339
|
+
var serverTiming = !isBrowser && typeof process !== "undefined" && process.env && process.env["SUPERCOV_PHASE_TIMING"] === "1" ? { asyncHookCallbacks: 0, contextResolutions: 0 } : void 0;
|
|
340
|
+
if (serverTiming) {
|
|
341
|
+
try {
|
|
342
|
+
process.once("exit", () => {
|
|
343
|
+
if (serverTiming.asyncHookCallbacks || serverTiming.contextResolutions)
|
|
344
|
+
process.stderr.write(`[supercov-timing] server ${process.pid} asyncHookCallbacks=${serverTiming.asyncHookCallbacks} contextResolutions=${serverTiming.contextResolutions}\n`);
|
|
345
|
+
});
|
|
346
|
+
} catch (e) {
|
|
347
|
+
}
|
|
348
|
+
}
|
|
304
349
|
// The context the async hook leaves to a callback's first probe: the
|
|
305
350
|
// request's store, or else the one the environment carries.
|
|
306
351
|
function resolveProbeV2Epoch() {
|
|
307
352
|
var _a8, _b;
|
|
353
|
+
if (serverTiming)
|
|
354
|
+
serverTiming.contextResolutions += 1;
|
|
308
355
|
return activateProbeV2Context((_b = (_a8 = serverPhaseStorage == null ? void 0 : serverPhaseStorage.getStore()) != null ? _a8 : environmentRequestContext()) != null ? _b : emptyProbeV2Context);
|
|
309
356
|
}
|
|
357
|
+
// A statement probe trusts the clock's epoch with no check of `fast`: while
|
|
358
|
+
// the clock is not fast -- no async hook keeps it -- its epoch is NaN wherever
|
|
359
|
+
// instrumented code can run, which no recorded epoch equals, so every probe
|
|
360
|
+
// takes the slow path and works out its context there, as it did when probes
|
|
361
|
+
// checked `fast` first. What sets the epoch while not fast restores it before
|
|
362
|
+
// instrumented code runs, or does not set it.
|
|
310
363
|
function withProbeV2Context(context, callback) {
|
|
311
|
-
|
|
364
|
+
if (!state.probeV2Clock.fast)
|
|
365
|
+
return callback();
|
|
366
|
+
const previous = state.probeV2Clock.e;
|
|
312
367
|
activateProbeV2Context(context);
|
|
313
368
|
try {
|
|
314
369
|
return callback();
|
|
315
370
|
} finally {
|
|
316
|
-
state.probeV2Clock.
|
|
371
|
+
state.probeV2Clock.e = previous;
|
|
317
372
|
}
|
|
318
373
|
}
|
|
319
374
|
function installProbeV2AsyncHook() {
|
|
@@ -333,12 +388,14 @@ function installProbeV2AsyncHook() {
|
|
|
333
388
|
// environment twice and built a key each time: on a Next app's suite,
|
|
334
389
|
// more of the server's time than any of Supercov's other work.
|
|
335
390
|
before() {
|
|
336
|
-
|
|
337
|
-
|
|
391
|
+
if (serverTiming)
|
|
392
|
+
serverTiming.asyncHookCallbacks += 1;
|
|
393
|
+
epochs.push(state.probeV2Clock.e);
|
|
394
|
+
state.probeV2Clock.e = NaN;
|
|
338
395
|
},
|
|
339
396
|
after() {
|
|
340
397
|
var _a9;
|
|
341
|
-
state.probeV2Clock.
|
|
398
|
+
state.probeV2Clock.e = (_a9 = epochs.pop()) != null ? _a9 : state.probeV2Clock.e;
|
|
342
399
|
}
|
|
343
400
|
}).enable();
|
|
344
401
|
state.probeV2HookInstalled = true;
|
|
@@ -366,19 +423,72 @@ function coverageSnapshot() {
|
|
|
366
423
|
return {
|
|
367
424
|
decisions: decisionSnapshot(),
|
|
368
425
|
hits: [...state.hits],
|
|
369
|
-
events: state.
|
|
426
|
+
events: eventObjects(state.eventLog),
|
|
370
427
|
logicals: logicalSnapshot()
|
|
371
428
|
};
|
|
372
429
|
}
|
|
430
|
+
// coverageSnapshot as snapshots.mjs's columnarEvents gives it, built from the
|
|
431
|
+
// columns the events are kept in rather than from an object per event.
|
|
432
|
+
function coverageSnapshotColumns() {
|
|
433
|
+
const log = state.eventLog;
|
|
434
|
+
const decisions = decisionSnapshot();
|
|
435
|
+
const hits = [...state.hits];
|
|
436
|
+
const logicals = logicalSnapshot();
|
|
437
|
+
if (log.id.length === 0)
|
|
438
|
+
return { decisions, hits, events: [], logicals };
|
|
439
|
+
const tables = { types: /* @__PURE__ */ new Map(), phases: /* @__PURE__ */ new Map(), environments: /* @__PURE__ */ new Map() };
|
|
440
|
+
const index = (table, value) => {
|
|
441
|
+
let found = table.get(value);
|
|
442
|
+
if (found === void 0) {
|
|
443
|
+
found = table.size;
|
|
444
|
+
table.set(value, found);
|
|
445
|
+
}
|
|
446
|
+
return found;
|
|
447
|
+
};
|
|
448
|
+
// An event that is one of the hits names it by its position in `hits`
|
|
449
|
+
// (snapshots.mjs's columnarEvents says why).
|
|
450
|
+
const hitAt = /* @__PURE__ */ new Map();
|
|
451
|
+
for (let position = 0; position < hits.length; position += 1)
|
|
452
|
+
hitAt.set(hits[position], position);
|
|
453
|
+
const columns = { id: [], type: [], phase: [], environment: [], t: [], vector: {} };
|
|
454
|
+
let previous = 0;
|
|
455
|
+
for (let position = 0; position < log.id.length; position += 1) {
|
|
456
|
+
const id = log.id[position];
|
|
457
|
+
const at = hitAt.get(id);
|
|
458
|
+
columns.id.push(at === void 0 ? id : at);
|
|
459
|
+
const phaseId = log.phaseId[position];
|
|
460
|
+
columns.type.push(index(tables.types, log.type[position]));
|
|
461
|
+
// An event built without a phase -- phaseId falsy -- has none.
|
|
462
|
+
columns.phase.push(phaseId ? index(tables.phases, phaseId) : -1);
|
|
463
|
+
columns.environment.push(index(tables.environments, log.environment[position]));
|
|
464
|
+
columns.t.push(log.timestampMs[position] - previous);
|
|
465
|
+
previous = log.timestampMs[position];
|
|
466
|
+
if (log.type[position] !== "hit")
|
|
467
|
+
columns.vector[position] = log.vector[position];
|
|
468
|
+
}
|
|
469
|
+
return {
|
|
470
|
+
decisions,
|
|
471
|
+
hits,
|
|
472
|
+
logicals,
|
|
473
|
+
eventColumns: {
|
|
474
|
+
types: [...tables.types.keys()],
|
|
475
|
+
phases: [...tables.phases.keys()],
|
|
476
|
+
environments: [...tables.environments.keys()],
|
|
477
|
+
...columns
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
}
|
|
373
481
|
function resetCoverage(testId2) {
|
|
374
482
|
state.decisions.clear();
|
|
375
483
|
state.hits.clear();
|
|
376
|
-
state.
|
|
484
|
+
state.eventLog = emptyEventLog();
|
|
377
485
|
state.logicals.clear();
|
|
378
486
|
state.eventKeys.clear();
|
|
379
487
|
state.probeV2ContextEpochs.clear();
|
|
380
488
|
state.probeV2EpochGeneration = (state.probeV2EpochGeneration || 0) + 1;
|
|
381
489
|
activateProbeV2Key(`reset\0${state.probeV2NextEpoch}`, true);
|
|
490
|
+
if (!state.probeV2Clock.fast)
|
|
491
|
+
state.probeV2Clock.e = NaN;
|
|
382
492
|
if (testId2)
|
|
383
493
|
runtimeGlobal.__SUPERCOV_MCDC_TEST_ID__ = testId2;
|
|
384
494
|
if (isBrowser) {
|
|
@@ -541,7 +651,7 @@ var persistBrowserListenersInstalled = false;
|
|
|
541
651
|
// How much evidence the document holds. Every part of it only grows until a
|
|
542
652
|
// reset, so the same size twice is the same evidence.
|
|
543
653
|
function evidenceSize() {
|
|
544
|
-
let size = state.hits.size + state.
|
|
654
|
+
let size = state.hits.size + state.eventLog.id.length;
|
|
545
655
|
for (const decision of state.decisions.values())
|
|
546
656
|
size += decision.vectors.size;
|
|
547
657
|
for (const vectors of state.logicals.values())
|
|
@@ -1171,24 +1281,10 @@ function appendServer(record) {
|
|
|
1171
1281
|
var _a8, _b, _c, _d;
|
|
1172
1282
|
if (state.runtimeSnapshots) {
|
|
1173
1283
|
const timestampMs = (_a8 = record.timestampMs) != null ? _a8 : Date.now();
|
|
1174
|
-
if (record.type === "decision")
|
|
1175
|
-
recordBrowserEvent(
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
vector: record.vector,
|
|
1179
|
-
timestampMs
|
|
1180
|
-
}, record.phaseId ? { phaseId: record.phaseId } : {}), {
|
|
1181
|
-
environment: "server"
|
|
1182
|
-
}));
|
|
1183
|
-
} else {
|
|
1184
|
-
recordBrowserEvent(__spreadProps(__spreadValues({
|
|
1185
|
-
type: "hit",
|
|
1186
|
-
id: record.id,
|
|
1187
|
-
timestampMs
|
|
1188
|
-
}, record.phaseId ? { phaseId: record.phaseId } : {}), {
|
|
1189
|
-
environment: "server"
|
|
1190
|
-
}));
|
|
1191
|
-
}
|
|
1284
|
+
if (record.type === "decision")
|
|
1285
|
+
recordBrowserEvent("decision", record.id, record.vector, timestampMs, record.phaseId, "server");
|
|
1286
|
+
else
|
|
1287
|
+
recordBrowserEvent("hit", record.id, void 0, timestampMs, record.phaseId, "server");
|
|
1192
1288
|
return;
|
|
1193
1289
|
}
|
|
1194
1290
|
const fs = getFs();
|
|
@@ -1236,18 +1332,22 @@ function appendServer(record) {
|
|
|
1236
1332
|
throw serverTransportError(runId, cause);
|
|
1237
1333
|
}
|
|
1238
1334
|
}
|
|
1239
|
-
//
|
|
1240
|
-
//
|
|
1241
|
-
|
|
1335
|
+
// The context a parent process gave this one, in SUPERCOV_CONTEXT: read on
|
|
1336
|
+
// every first hit, and fixed for the process's life. Supercov only ever gives
|
|
1337
|
+
// it to a child, at spawn, so it is read once per environment object: a
|
|
1338
|
+
// read of process.env, an interceptor, on every first hit of a large suite's
|
|
1339
|
+
// tests was the runtime's largest cost. A suite that swaps process.env for
|
|
1340
|
+
// another object is read again.
|
|
1341
|
+
var decodedEnvironmentCarrier = { env: void 0, context: void 0 };
|
|
1242
1342
|
function environmentRequestContext() {
|
|
1243
1343
|
if (isBrowser || typeof process === "undefined")
|
|
1244
1344
|
return void 0;
|
|
1245
|
-
const
|
|
1246
|
-
if (
|
|
1345
|
+
const env = process.env;
|
|
1346
|
+
if (env === decodedEnvironmentCarrier.env)
|
|
1247
1347
|
return decodedEnvironmentCarrier.context;
|
|
1248
|
-
const carrier = decodeCoverageCarrier(
|
|
1348
|
+
const carrier = decodeCoverageCarrier(env[COVERAGE_CARRIER_ENV]);
|
|
1249
1349
|
const context = carrier ? __spreadValues(__spreadValues({}, carrier.scope ? { scope: carrier.scope } : {}), carrier.phaseId ? { phaseId: carrier.phaseId } : {}) : void 0;
|
|
1250
|
-
decodedEnvironmentCarrier = {
|
|
1350
|
+
decodedEnvironmentCarrier = { env, context };
|
|
1251
1351
|
return context;
|
|
1252
1352
|
}
|
|
1253
1353
|
function currentRequestContext() {
|
|
@@ -1478,13 +1578,16 @@ function enterCoverageCarrier(carrier) {
|
|
|
1478
1578
|
return () => {
|
|
1479
1579
|
};
|
|
1480
1580
|
const previousStore = serverPhaseStorage.getStore();
|
|
1481
|
-
const previousEpoch = state.probeV2Clock.
|
|
1581
|
+
const previousEpoch = state.probeV2Clock.e;
|
|
1582
|
+
const fast = state.probeV2Clock.fast;
|
|
1482
1583
|
const context = __spreadValues(__spreadValues({}, carrier.scope ? { scope: carrier.scope } : {}), carrier.phaseId ? { phaseId: carrier.phaseId } : {});
|
|
1483
1584
|
serverPhaseStorage.enterWith(context);
|
|
1484
|
-
|
|
1585
|
+
if (fast)
|
|
1586
|
+
activateProbeV2Context(context);
|
|
1485
1587
|
return () => {
|
|
1486
1588
|
serverPhaseStorage.enterWith(previousStore);
|
|
1487
|
-
|
|
1589
|
+
if (fast)
|
|
1590
|
+
state.probeV2Clock.e = previousEpoch;
|
|
1488
1591
|
};
|
|
1489
1592
|
}
|
|
1490
1593
|
var inertAssertionPhase = { close: (value) => value, fail: (error) => error };
|
|
@@ -1942,17 +2045,45 @@ function withRequestPhase(handler, event) {
|
|
|
1942
2045
|
return requestContext !== void 0 || context.scope || context.phaseId ? serverPhaseStorage.run(context, () => withProbeV2Context(context, invoke)) : invoke();
|
|
1943
2046
|
};
|
|
1944
2047
|
}
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
2048
|
+
// Whether `event` was already recorded, recording it if not. Kept per phase,
|
|
2049
|
+
// so a first hit looks up its id alone: one key joining the phase, the type
|
|
2050
|
+
// and the id was built and hashed for every first hit of every test.
|
|
2051
|
+
function eventSeen(seen, type, id, vector, phaseId) {
|
|
2052
|
+
const phase = phaseId != null ? phaseId : "unscoped";
|
|
2053
|
+
let keys = builtinMapGet.call(seen, phase);
|
|
2054
|
+
if (keys === void 0) {
|
|
2055
|
+
keys = /* @__PURE__ */ new Set();
|
|
2056
|
+
builtinMapSet.call(seen, phase, keys);
|
|
2057
|
+
}
|
|
2058
|
+
const key = type === "hit" ? id : `${type}\0${type === "decision" ? `${id}:${vectorKey(vector)}` : id}`;
|
|
2059
|
+
if (builtinSetHas.call(keys, key))
|
|
2060
|
+
return true;
|
|
2061
|
+
builtinSetAdd.call(keys, key);
|
|
2062
|
+
return false;
|
|
2063
|
+
}
|
|
2064
|
+
// The phase eventSeen keys an event under: an event object built without a
|
|
2065
|
+
// falsy phase (hitEvent, decisionEvent) had none, which is "unscoped".
|
|
2066
|
+
function phaseEventKey(phaseId) {
|
|
2067
|
+
return phaseId ? phaseId : void 0;
|
|
2068
|
+
}
|
|
2069
|
+
// An event's fields into the columns, unless it was recorded already; what
|
|
2070
|
+
// hitEvent or decisionEvent would build of them is what coverageSnapshot
|
|
2071
|
+
// gives back.
|
|
2072
|
+
function recordEvent(into, type, id, vector, timestampMs, phaseId, environment) {
|
|
2073
|
+
if (eventSeen(into.eventKeys, type, id, vector, phaseEventKey(phaseId)))
|
|
2074
|
+
return false;
|
|
2075
|
+
const log = into.eventLog;
|
|
2076
|
+
log.type[log.type.length] = type;
|
|
2077
|
+
log.id[log.id.length] = id;
|
|
2078
|
+
log.vector[log.vector.length] = vector;
|
|
2079
|
+
log.timestampMs[log.timestampMs.length] = timestampMs;
|
|
2080
|
+
log.phaseId[log.phaseId.length] = phaseId;
|
|
2081
|
+
log.environment[log.environment.length] = environment;
|
|
2082
|
+
return true;
|
|
1949
2083
|
}
|
|
1950
|
-
function recordBrowserEvent(
|
|
1951
|
-
|
|
1952
|
-
if (state.eventKeys.has(key))
|
|
2084
|
+
function recordBrowserEvent(type, id, vector, timestampMs, phaseId, environment) {
|
|
2085
|
+
if (!recordEvent(state, type, id, vector, timestampMs, phaseId, environment))
|
|
1953
2086
|
return false;
|
|
1954
|
-
state.eventKeys.add(key);
|
|
1955
|
-
state.events.push(event);
|
|
1956
2087
|
workerEvidenceChanged();
|
|
1957
2088
|
return true;
|
|
1958
2089
|
}
|
|
@@ -1962,73 +2093,96 @@ function recordBrowserEvent(event) {
|
|
|
1962
2093
|
// repeat.
|
|
1963
2094
|
function coverageHit(id) {
|
|
1964
2095
|
const clock = state.probeV2Clock;
|
|
1965
|
-
if (clock.fast && state.hitEpochs !== void 0 && state.hitEpochs
|
|
2096
|
+
if (clock.fast && state.hitEpochs !== void 0 && builtinMapGet.call(state.hitEpochs, id) === clock.e)
|
|
1966
2097
|
return;
|
|
1967
2098
|
recordCoverageHit(id);
|
|
1968
2099
|
}
|
|
1969
2100
|
// resetCoverage forces a fresh epoch, so a hit skipped above was recorded in
|
|
1970
2101
|
// this epoch after the last reset and is in state.hits already.
|
|
1971
2102
|
function recordCoverageHit(id) {
|
|
1972
|
-
state.hits
|
|
2103
|
+
builtinSetAdd.call(state.hits, id);
|
|
1973
2104
|
const clock = state.probeV2Clock;
|
|
1974
|
-
let epoch = clock.
|
|
2105
|
+
let epoch = clock.e;
|
|
1975
2106
|
if (!clock.fast) {
|
|
1976
|
-
const previousEpoch = clock.
|
|
2107
|
+
const previousEpoch = clock.e;
|
|
1977
2108
|
activateProbeV2Context(currentRequestContext());
|
|
1978
|
-
epoch = clock.
|
|
1979
|
-
clock.
|
|
2109
|
+
epoch = clock.e;
|
|
2110
|
+
clock.e = previousEpoch;
|
|
1980
2111
|
} else if (epoch !== epoch) {
|
|
1981
2112
|
epoch = resolveProbeV2Epoch();
|
|
1982
2113
|
}
|
|
1983
2114
|
if (!state.hitEpochs)
|
|
1984
2115
|
state.hitEpochs = /* @__PURE__ */ new Map();
|
|
1985
|
-
if (state.hitEpochs
|
|
2116
|
+
if (builtinMapGet.call(state.hitEpochs, id) === epoch)
|
|
1986
2117
|
return;
|
|
1987
|
-
state.hitEpochs
|
|
2118
|
+
builtinMapSet.call(state.hitEpochs, id, epoch);
|
|
1988
2119
|
const timestampMs = Date.now();
|
|
1989
2120
|
const phaseId = currentPhaseId();
|
|
1990
2121
|
if (isBrowser) {
|
|
1991
|
-
if (recordBrowserEvent(
|
|
1992
|
-
type: "hit",
|
|
1993
|
-
id,
|
|
1994
|
-
timestampMs
|
|
1995
|
-
}, phaseId ? { phaseId } : {}), {
|
|
1996
|
-
environment: "browser"
|
|
1997
|
-
})))
|
|
2122
|
+
if (recordBrowserEvent("hit", id, void 0, timestampMs, phaseId, "browser"))
|
|
1998
2123
|
persistBrowser();
|
|
2124
|
+
} else if (state.runtimeSnapshots) {
|
|
2125
|
+
// What appendServer does with a snapshot-kept run's record, without the
|
|
2126
|
+
// record: an object built per first hit only to be read once.
|
|
2127
|
+
recordBrowserEvent("hit", id, void 0, timestampMs, phaseId, "server");
|
|
1999
2128
|
} else {
|
|
2000
|
-
appendServer(
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2129
|
+
appendServer(phaseId ? { type: "hit", id, timestampMs, phaseId } : { type: "hit", id, timestampMs });
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
// A first hit's event, built as one literal in the order the spread helpers
|
|
2133
|
+
// gave its keys: they walked every key of three objects for each first hit
|
|
2134
|
+
// of every statement in every test.
|
|
2135
|
+
function hitEvent(id, timestampMs, phaseId, environment) {
|
|
2136
|
+
return phaseId ? { type: "hit", id, timestampMs, phaseId, environment } : { type: "hit", id, timestampMs, environment };
|
|
2137
|
+
}
|
|
2138
|
+
function decisionEvent(id, vector, timestampMs, phaseId, environment) {
|
|
2139
|
+
return phaseId ? { type: "decision", id, vector, timestampMs, phaseId, environment } : { type: "decision", id, vector, timestampMs, environment };
|
|
2140
|
+
}
|
|
2141
|
+
// A module carries the key of its table of ids, which the manifest holds, and
|
|
2142
|
+
// how many points and decisions it numbers: evidence names a probe by the key
|
|
2143
|
+
// and its place, `~p<key>.<place>` or `~d<key>.<place>`, and the report reads
|
|
2144
|
+
// the id there. A place whose id an earlier place has is named as that one,
|
|
2145
|
+
// as it was one id: a selection's two short outcomes are one point.
|
|
2146
|
+
function probeAliases(flat) {
|
|
2147
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
2148
|
+
for (let index = 0; flat && index + 1 < flat.length; index += 2)
|
|
2149
|
+
aliases.set(flat[index], flat[index + 1]);
|
|
2150
|
+
return aliases;
|
|
2151
|
+
}
|
|
2152
|
+
function probePlaceName(names, aliases, count, kind, key, place) {
|
|
2153
|
+
if (!(place >= 0 && place < count))
|
|
2154
|
+
return void 0;
|
|
2155
|
+
let name = names[place];
|
|
2156
|
+
if (name === void 0) {
|
|
2157
|
+
const first = builtinMapGet.call(aliases, place);
|
|
2158
|
+
name = names[place] = first === void 0 ? `~${kind}${key}.${place}` : probePlaceName(names, aliases, count, kind, key, first);
|
|
2005
2159
|
}
|
|
2160
|
+
return name;
|
|
2161
|
+
}
|
|
2162
|
+
function probePointName(file, place) {
|
|
2163
|
+
return probePlaceName(file.pointNames, file.pointAliases, file.pointCount, "p", file.key, place);
|
|
2006
2164
|
}
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
function listedIds(ids) {
|
|
2010
|
-
return typeof ids === "string" ? ids === "" ? [] : ids.split(" ") : ids;
|
|
2165
|
+
function probeDecisionName(file, place) {
|
|
2166
|
+
return probePlaceName(file.decisionNames, file.decisionAliases, file.decisionWidths.length, "d", file.key, place);
|
|
2011
2167
|
}
|
|
2012
2168
|
function registerProbeV2(definition) {
|
|
2013
2169
|
var _a8, _b;
|
|
2014
|
-
const
|
|
2015
|
-
const pointIds = listedIds(definition.pointIds);
|
|
2170
|
+
const pointCount = definition.points;
|
|
2016
2171
|
const file = {
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2172
|
+
key: definition.key,
|
|
2173
|
+
pointCount,
|
|
2174
|
+
pointNames: [],
|
|
2175
|
+
pointAliases: probeAliases(definition.pointAliases),
|
|
2176
|
+
decisionNames: [],
|
|
2177
|
+
decisionAliases: probeAliases(definition.decisionAliases),
|
|
2020
2178
|
decisionWidths: definition.decisionWidths,
|
|
2021
|
-
pointIds,
|
|
2022
2179
|
clock: state.probeV2Clock,
|
|
2023
|
-
hitEpochs: new Uint32Array(
|
|
2180
|
+
hitEpochs: new Uint32Array(pointCount),
|
|
2181
|
+
// A narrow decision's vectors in an array, a wide one's in a Map, told
|
|
2182
|
+
// apart by `size`, which only the Map has: `instanceof Uint32Array` read
|
|
2183
|
+
// the global on every evaluation, and under Vitest's jsdom environment
|
|
2184
|
+
// each read is a getter call, most of a canvas app's measured unit time.
|
|
2024
2185
|
decisionEpochs: definition.decisionWidths.map((width) => width <= 6 ? new Uint32Array(2 * 3 ** width) : /* @__PURE__ */ new Map()),
|
|
2025
|
-
decisionVectorCounts: decisions.map((_, index) => {
|
|
2026
|
-
var _a9, _b2;
|
|
2027
|
-
return (_b2 = (_a9 = definition.decisionVectorCounts) == null ? void 0 : _a9[index]) != null ? _b2 : 0;
|
|
2028
|
-
}),
|
|
2029
|
-
decisionObservationEpochs: new Uint32Array(decisions.length),
|
|
2030
|
-
decisionObservationCounts: new Uint16Array(decisions.length),
|
|
2031
|
-
decisionCompleteEpochs: new Uint32Array(decisions.length),
|
|
2032
2186
|
pendingDefaults: new Uint32Array(definition.defaultCount || 0),
|
|
2033
2187
|
// A selection's outcomes -- short falsy, short truthy, right falsy, right
|
|
2034
2188
|
// truthy -- are four consecutive points per site from the first index.
|
|
@@ -2039,7 +2193,18 @@ function registerProbeV2(definition) {
|
|
|
2039
2193
|
selectionChoices: (definition.selectionTrees || []).map((tree) => tree[1]),
|
|
2040
2194
|
none: optionalCallEmptySpread
|
|
2041
2195
|
};
|
|
2042
|
-
|
|
2196
|
+
rememberProbeV2File(file);
|
|
2197
|
+
// What a probe calls: this file's hit, by place alone. Outside a loop the
|
|
2198
|
+
// probe is the call alone and this makes its check, so it stays small
|
|
2199
|
+
// enough for V8 to inline where the code is hot. The epoch is NaN wherever
|
|
2200
|
+
// the clock is not fast, which no recorded epoch equals, so the check needs
|
|
2201
|
+
// no `fast` of its own (coverageHitV2's).
|
|
2202
|
+
const hitEpochs = file.hitEpochs;
|
|
2203
|
+
const clock = file.clock;
|
|
2204
|
+
file.hit = (index) => {
|
|
2205
|
+
if (hitEpochs[index] !== clock.e)
|
|
2206
|
+
recordCoverageHitV2(file, index);
|
|
2207
|
+
};
|
|
2043
2208
|
if (isBrowser) {
|
|
2044
2209
|
state.probeV2Clock.fast = true;
|
|
2045
2210
|
activateProbeV2Key(`browser\0${(_a8 = runtimeGlobal.__SUPERCOV_MCDC_TEST_ID__) != null ? _a8 : testId}\0${(_b = runtimeGlobal.__SUPERCOV_PHASE_ID__) != null ? _b : "unscoped"}`);
|
|
@@ -2049,11 +2214,31 @@ function registerProbeV2(definition) {
|
|
|
2049
2214
|
// before any did -- a script's own top level -- found it NaN, which no
|
|
2050
2215
|
// epoch equals, so every probe there took the slow path every time: a
|
|
2051
2216
|
// million-iteration loop ran 1,700 times slower than without Supercov.
|
|
2052
|
-
if (Number.isNaN(state.probeV2Clock.
|
|
2217
|
+
if (state.probeV2Clock.fast && Number.isNaN(state.probeV2Clock.e))
|
|
2053
2218
|
activateProbeV2Context(currentRequestContext());
|
|
2054
2219
|
}
|
|
2055
2220
|
return file;
|
|
2056
2221
|
}
|
|
2222
|
+
// Vitest evaluates a module again for every test file, and each evaluation
|
|
2223
|
+
// registers its file anew: held strongly, every evaluation's arrays stayed
|
|
2224
|
+
// alive for the worker's life, and the collector walked them all. A file no
|
|
2225
|
+
// module holds runs no probe, so the wrap has nothing of it to clear, and the
|
|
2226
|
+
// set is swept of them as it doubles.
|
|
2227
|
+
function rememberProbeV2File(file) {
|
|
2228
|
+
const files = state.probeV2Files;
|
|
2229
|
+
if (typeof WeakRef !== "function") {
|
|
2230
|
+
files.add(file);
|
|
2231
|
+
return;
|
|
2232
|
+
}
|
|
2233
|
+
files.add(new WeakRef(file));
|
|
2234
|
+
if (files.size < state.probeV2FilesSweepAt)
|
|
2235
|
+
return;
|
|
2236
|
+
for (const held of files) {
|
|
2237
|
+
if (held.deref() === void 0)
|
|
2238
|
+
files.delete(held);
|
|
2239
|
+
}
|
|
2240
|
+
state.probeV2FilesSweepAt = Math.max(1024, 2 * files.size);
|
|
2241
|
+
}
|
|
2057
2242
|
// Every repeat of a probe in the same context ends at the first check, so it
|
|
2058
2243
|
// stays small enough for V8 to inline into the instrumented function; the
|
|
2059
2244
|
// rest runs once per context. minimatch's backtracking guard test needs a
|
|
@@ -2061,32 +2246,34 @@ function registerProbeV2(definition) {
|
|
|
2061
2246
|
// at ten times the uninstrumented time.
|
|
2062
2247
|
function coverageHitV2(file, index) {
|
|
2063
2248
|
const clock = file.clock;
|
|
2064
|
-
if (clock.fast && file.hitEpochs[index] === clock.
|
|
2249
|
+
if (clock.fast && file.hitEpochs[index] === clock.e)
|
|
2065
2250
|
return;
|
|
2066
2251
|
recordCoverageHitV2(file, index);
|
|
2067
2252
|
}
|
|
2068
2253
|
function recordCoverageHitV2(file, index) {
|
|
2069
|
-
const id = file
|
|
2254
|
+
const id = probePointName(file, index);
|
|
2070
2255
|
if (!id)
|
|
2071
2256
|
return;
|
|
2072
2257
|
const fallbackEpoch = !file.clock.fast;
|
|
2073
|
-
const previousEpoch = file.clock.
|
|
2258
|
+
const previousEpoch = file.clock.e;
|
|
2074
2259
|
if (fallbackEpoch)
|
|
2075
2260
|
activateProbeV2Context(currentRequestContext());
|
|
2076
2261
|
else if (previousEpoch !== previousEpoch)
|
|
2077
2262
|
resolveProbeV2Epoch();
|
|
2078
2263
|
try {
|
|
2079
|
-
const epoch = file.clock.
|
|
2264
|
+
const epoch = file.clock.e;
|
|
2080
2265
|
if (file.hitEpochs[index] === epoch)
|
|
2081
2266
|
return;
|
|
2082
2267
|
file.hitEpochs[index] = epoch;
|
|
2083
|
-
|
|
2268
|
+
// New in this context for this file: recordCoverageHit makes the check
|
|
2269
|
+
// coverageHit would, across files and aliases, without a second lookup.
|
|
2270
|
+
recordCoverageHit(id);
|
|
2084
2271
|
const selections = file.selectionPoints;
|
|
2085
2272
|
if (selections !== void 0 && index >= selections[0] && index < selections[0] + 4 * selections[1])
|
|
2086
|
-
|
|
2273
|
+
recordLogicalOutcome(id, index - selections[0] & 3);
|
|
2087
2274
|
} finally {
|
|
2088
2275
|
if (fallbackEpoch)
|
|
2089
|
-
file.clock.
|
|
2276
|
+
file.clock.e = previousEpoch;
|
|
2090
2277
|
}
|
|
2091
2278
|
}
|
|
2092
2279
|
function decodeProbeV2Vector(conditionCount, encoded, outcome) {
|
|
@@ -2096,7 +2283,7 @@ function decodeProbeV2Vector(conditionCount, encoded, outcome) {
|
|
|
2096
2283
|
let remaining = encoded;
|
|
2097
2284
|
for (let index = 0; index < conditionCount; index += 1) {
|
|
2098
2285
|
const digit = remaining % 3;
|
|
2099
|
-
values
|
|
2286
|
+
values[index] = digit === 0 ? null : digit === 2;
|
|
2100
2287
|
remaining = Math.floor(remaining / 3);
|
|
2101
2288
|
}
|
|
2102
2289
|
return remaining === 0 ? { values, outcome } : void 0;
|
|
@@ -2109,14 +2296,13 @@ function mcdcEndV2(file, decisionIndex, encoded, value) {
|
|
|
2109
2296
|
const clock = file.clock;
|
|
2110
2297
|
if (clock.fast) {
|
|
2111
2298
|
const seen = file.decisionEpochs[decisionIndex];
|
|
2112
|
-
if (seen
|
|
2299
|
+
if (seen !== void 0 && seen.size === void 0 && seen[encoded * 2 + (value ? 1 : 0)] === clock.e)
|
|
2113
2300
|
return value;
|
|
2114
2301
|
}
|
|
2115
2302
|
return recordMcdcEndV2(file, decisionIndex, encoded, value);
|
|
2116
2303
|
}
|
|
2117
2304
|
function recordMcdcEndV2(file, decisionIndex, encoded, value) {
|
|
2118
|
-
|
|
2119
|
-
const id = file.decisions[decisionIndex];
|
|
2305
|
+
const id = probeDecisionName(file, decisionIndex);
|
|
2120
2306
|
if (!id || !Number.isSafeInteger(encoded) || encoded < 0)
|
|
2121
2307
|
return value;
|
|
2122
2308
|
const outcome = Boolean(value);
|
|
@@ -2124,43 +2310,32 @@ function recordMcdcEndV2(file, decisionIndex, encoded, value) {
|
|
|
2124
2310
|
if (!Number.isSafeInteger(vectorIndex))
|
|
2125
2311
|
return value;
|
|
2126
2312
|
const fallbackEpoch = !file.clock.fast;
|
|
2127
|
-
const previousEpoch = file.clock.
|
|
2313
|
+
const previousEpoch = file.clock.e;
|
|
2128
2314
|
if (fallbackEpoch)
|
|
2129
2315
|
activateProbeV2Context(currentRequestContext());
|
|
2130
2316
|
else if (previousEpoch !== previousEpoch)
|
|
2131
2317
|
resolveProbeV2Epoch();
|
|
2132
2318
|
try {
|
|
2133
|
-
const epoch = file.clock.
|
|
2319
|
+
const epoch = file.clock.e;
|
|
2134
2320
|
const seen = file.decisionEpochs[decisionIndex];
|
|
2135
2321
|
if (!seen)
|
|
2136
2322
|
return value;
|
|
2137
|
-
if (seen
|
|
2323
|
+
if (seen.size === void 0) {
|
|
2138
2324
|
if (seen[vectorIndex] === epoch)
|
|
2139
2325
|
return value;
|
|
2140
2326
|
seen[vectorIndex] = epoch;
|
|
2141
2327
|
} else {
|
|
2142
|
-
if (
|
|
2328
|
+
if (builtinMapGet.call(seen, vectorIndex) === epoch)
|
|
2143
2329
|
return value;
|
|
2144
|
-
|
|
2145
|
-
}
|
|
2146
|
-
const expectedCount = (_a8 = file.decisionVectorCounts[decisionIndex]) != null ? _a8 : 0;
|
|
2147
|
-
if (expectedCount > 0) {
|
|
2148
|
-
if (file.decisionObservationEpochs[decisionIndex] !== epoch) {
|
|
2149
|
-
file.decisionObservationEpochs[decisionIndex] = epoch;
|
|
2150
|
-
file.decisionObservationCounts[decisionIndex] = 0;
|
|
2151
|
-
}
|
|
2152
|
-
const observedCount = ((_b = file.decisionObservationCounts[decisionIndex]) != null ? _b : 0) + 1;
|
|
2153
|
-
file.decisionObservationCounts[decisionIndex] = observedCount;
|
|
2154
|
-
if (observedCount >= expectedCount)
|
|
2155
|
-
file.decisionCompleteEpochs[decisionIndex] = epoch;
|
|
2330
|
+
builtinMapSet.call(seen, vectorIndex, epoch);
|
|
2156
2331
|
}
|
|
2157
|
-
if (!state.decisions
|
|
2158
|
-
state.decisions
|
|
2332
|
+
if (!builtinMapHas.call(state.decisions, id))
|
|
2333
|
+
builtinMapSet.call(state.decisions, id, { id, vectors: /* @__PURE__ */ new Map() });
|
|
2159
2334
|
const vector = decodeProbeV2Vector(file.decisionWidths[decisionIndex], encoded, outcome);
|
|
2160
2335
|
return vector ? mcdcEnd({ id, values: vector.values }, value) : value;
|
|
2161
2336
|
} finally {
|
|
2162
2337
|
if (fallbackEpoch)
|
|
2163
|
-
file.clock.
|
|
2338
|
+
file.clock.e = previousEpoch;
|
|
2164
2339
|
}
|
|
2165
2340
|
}
|
|
2166
2341
|
function selectionBegin(shortId, rightId) {
|
|
@@ -2208,16 +2383,20 @@ function recordSelectionOutcome(id, outcome) {
|
|
|
2208
2383
|
branchId = separator > 0 ? id.slice(0, separator) : null;
|
|
2209
2384
|
selectionBranchIds.set(id, branchId);
|
|
2210
2385
|
}
|
|
2211
|
-
if (branchId
|
|
2212
|
-
|
|
2213
|
-
|
|
2386
|
+
if (branchId !== null)
|
|
2387
|
+
recordLogicalOutcome(branchId, outcome);
|
|
2388
|
+
}
|
|
2389
|
+
// The outcomes of a selection by its branch id, or by the name of its point
|
|
2390
|
+
// that was hit, whose branch the report reads from the point's id.
|
|
2391
|
+
function recordLogicalOutcome(branchId, outcome) {
|
|
2392
|
+
let vectors = builtinMapGet.call(state.logicals, branchId);
|
|
2214
2393
|
if (!vectors) {
|
|
2215
2394
|
vectors = /* @__PURE__ */ new Map();
|
|
2216
|
-
state.logicals
|
|
2395
|
+
builtinMapSet.call(state.logicals, branchId, vectors);
|
|
2217
2396
|
}
|
|
2218
2397
|
const key = selectionOutcomeKeys[outcome];
|
|
2219
|
-
if (!
|
|
2220
|
-
|
|
2398
|
+
if (!builtinMapHas.call(vectors, key)) {
|
|
2399
|
+
builtinMapSet.call(vectors, key, { right: outcome >= 2, truthy: (outcome & 1) === 1 });
|
|
2221
2400
|
workerEvidenceChanged();
|
|
2222
2401
|
}
|
|
2223
2402
|
}
|
|
@@ -2458,31 +2637,21 @@ function mcdcCondition(frame, index, value) {
|
|
|
2458
2637
|
return value;
|
|
2459
2638
|
}
|
|
2460
2639
|
function mcdcEnd(frame, value) {
|
|
2461
|
-
const decision = state.decisions
|
|
2640
|
+
const decision = builtinMapGet.call(state.decisions, frame.id);
|
|
2462
2641
|
if (!decision)
|
|
2463
2642
|
return value;
|
|
2464
2643
|
const vector = { values: frame.values, outcome: Boolean(value) };
|
|
2465
2644
|
const key = vectorKey(vector);
|
|
2466
|
-
decision.vectors
|
|
2645
|
+
builtinMapSet.call(decision.vectors, key, vector);
|
|
2467
2646
|
const timestampMs = Date.now();
|
|
2468
2647
|
const phaseId = currentPhaseId();
|
|
2469
2648
|
if (isBrowser) {
|
|
2470
|
-
if (recordBrowserEvent(
|
|
2471
|
-
type: "decision",
|
|
2472
|
-
id: decision.id,
|
|
2473
|
-
vector,
|
|
2474
|
-
timestampMs
|
|
2475
|
-
}, phaseId ? { phaseId } : {}), {
|
|
2476
|
-
environment: "browser"
|
|
2477
|
-
})))
|
|
2649
|
+
if (recordBrowserEvent("decision", decision.id, vector, timestampMs, phaseId, "browser"))
|
|
2478
2650
|
persistBrowser();
|
|
2651
|
+
} else if (state.runtimeSnapshots) {
|
|
2652
|
+
recordBrowserEvent("decision", decision.id, vector, timestampMs, phaseId, "server");
|
|
2479
2653
|
} else {
|
|
2480
|
-
appendServer(
|
|
2481
|
-
type: "decision",
|
|
2482
|
-
id: decision.id,
|
|
2483
|
-
vector,
|
|
2484
|
-
timestampMs
|
|
2485
|
-
}, phaseId ? { phaseId } : {}));
|
|
2654
|
+
appendServer(phaseId ? { type: "decision", id: decision.id, vector, timestampMs, phaseId } : { type: "decision", id: decision.id, vector, timestampMs });
|
|
2486
2655
|
}
|
|
2487
2656
|
return value;
|
|
2488
2657
|
}
|
|
@@ -2498,6 +2667,7 @@ const directRuntimeApi = {
|
|
|
2498
2667
|
coverageHit,
|
|
2499
2668
|
coverageHitV2,
|
|
2500
2669
|
coverageSnapshot,
|
|
2670
|
+
coverageSnapshotColumns,
|
|
2501
2671
|
decodeProbeV2Vector,
|
|
2502
2672
|
defaultEntered,
|
|
2503
2673
|
defaultEnteredV2,
|
|
@@ -2566,6 +2736,7 @@ export {
|
|
|
2566
2736
|
coverageHit,
|
|
2567
2737
|
coverageHitV2,
|
|
2568
2738
|
coverageSnapshot,
|
|
2739
|
+
coverageSnapshotColumns,
|
|
2569
2740
|
decodeProbeV2Vector,
|
|
2570
2741
|
defaultEntered,
|
|
2571
2742
|
defaultEnteredV2,
|