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
|
@@ -106,3 +106,50 @@ export function expandSnapshot(value) {
|
|
|
106
106
|
snapshot[key] = key === "events" ? events : key === "hits" ? hits.map((index) => strings[index]) : rest[key];
|
|
107
107
|
return snapshot;
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* A snapshot's events as columns: each event's type, phase and environment
|
|
111
|
+
* as an index into a table of the distinct ones, its time as the difference
|
|
112
|
+
* from the event before it, and its id, where it is one of the snapshot's
|
|
113
|
+
* hits, as that hit's position in `hits`: every first hit of a test is in
|
|
114
|
+
* both, and writing each id twice was a third of a test's evidence. The
|
|
115
|
+
* reader gives back the same events.
|
|
116
|
+
*/
|
|
117
|
+
export function columnarEvents(snapshot) {
|
|
118
|
+
const events = snapshot?.events;
|
|
119
|
+
if (!Array.isArray(events) || events.length === 0)
|
|
120
|
+
return snapshot;
|
|
121
|
+
const tables = { types: new Map(), phases: new Map(), environments: new Map() };
|
|
122
|
+
const index = (table, value) => {
|
|
123
|
+
let found = table.get(value);
|
|
124
|
+
if (found === undefined) {
|
|
125
|
+
found = table.size;
|
|
126
|
+
table.set(value, found);
|
|
127
|
+
}
|
|
128
|
+
return found;
|
|
129
|
+
};
|
|
130
|
+
const hitAt = new Map();
|
|
131
|
+
(snapshot.hits ?? []).forEach((id, position) => hitAt.set(id, position));
|
|
132
|
+
const columns = { id: [], type: [], phase: [], environment: [], t: [], vector: {} };
|
|
133
|
+
let previous = 0;
|
|
134
|
+
events.forEach((event, position) => {
|
|
135
|
+
const at = hitAt.get(event.id);
|
|
136
|
+
columns.id.push(at === undefined ? event.id : at);
|
|
137
|
+
columns.type.push(index(tables.types, event.type));
|
|
138
|
+
columns.phase.push(event.phaseId == null ? -1 : index(tables.phases, event.phaseId));
|
|
139
|
+
columns.environment.push(index(tables.environments, event.environment));
|
|
140
|
+
columns.t.push(event.timestampMs - previous);
|
|
141
|
+
previous = event.timestampMs;
|
|
142
|
+
if (event.vector !== undefined)
|
|
143
|
+
columns.vector[position] = event.vector;
|
|
144
|
+
});
|
|
145
|
+
const { events: _events, ...rest } = snapshot;
|
|
146
|
+
return {
|
|
147
|
+
...rest,
|
|
148
|
+
eventColumns: {
|
|
149
|
+
types: [...tables.types.keys()],
|
|
150
|
+
phases: [...tables.phases.keys()],
|
|
151
|
+
environments: [...tables.environments.keys()],
|
|
152
|
+
...columns,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { relative, resolve, sep } from "node:path";
|
|
3
|
-
import { afterEach, beforeEach } from "vitest";
|
|
4
|
-
import { coverageSnapshot as localCoverageSnapshot, activateCoverageScope as localActivateCoverageScope, enableRuntimeSnapshotEvidence as localEnableRuntimeSnapshotEvidence, resetCoverage as localResetCoverage, takeNodeAssertionPhases as localTakeNodeAssertionPhases, } from "./runtime.mjs";
|
|
3
|
+
import { afterAll, afterEach, beforeEach } from "vitest";
|
|
4
|
+
import { coverageSnapshot as localCoverageSnapshot, coverageSnapshotColumns as localCoverageSnapshotColumns, activateCoverageScope as localActivateCoverageScope, enableRuntimeSnapshotEvidence as localEnableRuntimeSnapshotEvidence, resetCoverage as localResetCoverage, takeNodeAssertionPhases as localTakeNodeAssertionPhases, } from "./runtime.mjs";
|
|
5
5
|
import { inferTestProvenance, testTags } from "./provenance.mjs";
|
|
6
|
-
import { appendEvidenceRecord } from "./atomic.mjs";
|
|
6
|
+
import { appendEvidenceRecord, installCompileCache, saveCompileCache } from "./atomic.mjs";
|
|
7
7
|
const evidenceDirectory = process.env["SUPERCOV_EVIDENCE_DIR"];
|
|
8
8
|
const emittedSetupFiles = new Set();
|
|
9
9
|
const attempts = new Map();
|
|
@@ -12,6 +12,7 @@ const runtimeGlobal = globalThis;
|
|
|
12
12
|
const runtime = runtimeGlobal.__SUPERCOV_DIRECT_RUNTIME__ ?? {
|
|
13
13
|
activateCoverageScope: localActivateCoverageScope,
|
|
14
14
|
coverageSnapshot: localCoverageSnapshot,
|
|
15
|
+
coverageSnapshotColumns: localCoverageSnapshotColumns,
|
|
15
16
|
enableRuntimeSnapshotEvidence: localEnableRuntimeSnapshotEvidence,
|
|
16
17
|
resetCoverage: localResetCoverage,
|
|
17
18
|
takeNodeAssertionPhases: localTakeNodeAssertionPhases,
|
|
@@ -20,6 +21,10 @@ const runtime = runtimeGlobal.__SUPERCOV_DIRECT_RUNTIME__ ?? {
|
|
|
20
21
|
// events through the server JSONL transport would be both redundant and
|
|
21
22
|
// unattributed, and turns hot unit-test loops into synchronous filesystem IO.
|
|
22
23
|
runtime.enableRuntimeSnapshotEvidence();
|
|
24
|
+
// Each worker compiles the instrumented modules from what the workers before
|
|
25
|
+
// it compiled, and leaves what it compiled for the ones after.
|
|
26
|
+
installCompileCache(process.env["SUPERCOV_COMPILE_CACHE"]);
|
|
27
|
+
afterAll(saveCompileCache);
|
|
23
28
|
function attemptStatus(state) {
|
|
24
29
|
if (state === "pass")
|
|
25
30
|
return "passed";
|
|
@@ -50,7 +55,8 @@ beforeEach((context) => {
|
|
|
50
55
|
.join("/");
|
|
51
56
|
if (!emittedSetupFiles.has(testFile)) {
|
|
52
57
|
emittedSetupFiles.add(testFile);
|
|
53
|
-
|
|
58
|
+
// The snapshot as its evidence carries it, its events as columns.
|
|
59
|
+
const setupSnapshot = runtime.coverageSnapshotColumns();
|
|
54
60
|
if (setupSnapshot.hits.length || setupSnapshot.decisions.length) {
|
|
55
61
|
writeEvidence({
|
|
56
62
|
testId: `vitest:${task.file.id}:setup`,
|
|
@@ -112,7 +118,10 @@ afterEach((context) => {
|
|
|
112
118
|
tags: testTags(task.tags, [...titlePath(task)]),
|
|
113
119
|
}),
|
|
114
120
|
...(scope ? { phases: runtime.takeNodeAssertionPhases(scope) } : {}),
|
|
115
|
-
|
|
121
|
+
// Its events as columns, as Playwright's are written: a test's first
|
|
122
|
+
// hits written as objects repeated every key and phase for each, and
|
|
123
|
+
// serializing them was most of what a test's teardown cost.
|
|
124
|
+
runtime: [runtime.coverageSnapshotColumns()],
|
|
116
125
|
browser: [],
|
|
117
126
|
server: [],
|
|
118
127
|
};
|