@specter-automation/test 1.0.136 → 1.0.138
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.
|
@@ -16,13 +16,18 @@ export type BehaviorTrailEvent =
|
|
|
16
16
|
path: string[];
|
|
17
17
|
from: string;
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* A blackboard key changed value. A key that kept changing (one set every frame, like a distance) is one event:
|
|
21
|
+
* `from` its first value `to` its latest, with `changes` how many there were and `until` when the last one was.
|
|
22
|
+
*/
|
|
20
23
|
| {
|
|
21
24
|
t: number;
|
|
22
25
|
kind: 'blackboard';
|
|
23
26
|
key: string;
|
|
24
27
|
from: string;
|
|
25
28
|
to: string;
|
|
29
|
+
changes?: number;
|
|
30
|
+
until?: number;
|
|
26
31
|
}
|
|
27
32
|
/** The tree it runs changed (started, stopped, or swapped for another) */
|
|
28
33
|
| {
|
|
@@ -33,8 +33,10 @@ function describeEvent(event) {
|
|
|
33
33
|
switch (event.kind) {
|
|
34
34
|
case 'active':
|
|
35
35
|
return `▸ ${describeNodePath(event.path)}`;
|
|
36
|
-
case 'blackboard':
|
|
37
|
-
|
|
36
|
+
case 'blackboard': {
|
|
37
|
+
const repeated = event.changes && event.changes > 1 ? ` (${event.changes} changes until ${(event.until ?? event.t).toFixed(2)}s)` : '';
|
|
38
|
+
return `${event.key}: ${clip(event.from)} → ${clip(event.to)}${repeated}`;
|
|
39
|
+
}
|
|
38
40
|
case 'tree':
|
|
39
41
|
if (!event.to)
|
|
40
42
|
return `Stopped running ${event.from}`;
|
|
@@ -1202,7 +1202,7 @@ class SpecterWorld {
|
|
|
1202
1202
|
const portTag = this.transport.friendlyPortTag;
|
|
1203
1203
|
const stepTitle = `${portTag}Measure performance: ${name}`;
|
|
1204
1204
|
return await test_1.default.step(stepTitle, async () => {
|
|
1205
|
-
await this.transport.sendCommand({ command: 'StartPerfCapture', payload: { name, hitchMs, timelinePreview: options.timelinePreview ??
|
|
1205
|
+
await this.transport.sendCommand({ command: 'StartPerfCapture', payload: { name, hitchMs, timelinePreview: options.timelinePreview ?? true } });
|
|
1206
1206
|
let failed = false;
|
|
1207
1207
|
let failure;
|
|
1208
1208
|
try {
|
|
@@ -110,8 +110,9 @@ export interface MeasurePerformanceOptions {
|
|
|
110
110
|
/** Frames slower than this many milliseconds count as hitches. Default: 50. */
|
|
111
111
|
hitchMs?: number;
|
|
112
112
|
/**
|
|
113
|
-
* Keep recording the runner's timeline preview frames while measuring
|
|
114
|
-
*
|
|
113
|
+
* Keep recording the runner's timeline preview frames while measuring, so the timeline shows what happened during
|
|
114
|
+
* the measurement. Default: true (each preview frame costs a GPU readback and a small JPEG encode).
|
|
115
|
+
* Turn it off for the strictest numbers: the timeline then holds the last frame from before the measurement.
|
|
115
116
|
*/
|
|
116
117
|
timelinePreview?: boolean;
|
|
117
118
|
}
|
|
@@ -3,6 +3,11 @@ export default class SpecterReporter implements Reporter {
|
|
|
3
3
|
private ws;
|
|
4
4
|
private isConnected;
|
|
5
5
|
private queue;
|
|
6
|
+
/** Connection attempts since the last one that opened (the engine may not be listening yet) */
|
|
7
|
+
private connectAttempts;
|
|
8
|
+
private reconnectTimer;
|
|
9
|
+
/** Set when the run has ended: no more reconnecting */
|
|
10
|
+
private runEnded;
|
|
6
11
|
private testStepCounters;
|
|
7
12
|
private stepIdMap;
|
|
8
13
|
/** Playwright's outer `Expect "<matcher>"` steps for Specter matchers. They are shown under their wrapper step's name. */
|
|
@@ -24,6 +29,15 @@ export default class SpecterReporter implements Reporter {
|
|
|
24
29
|
private runFrameFolders;
|
|
25
30
|
constructor();
|
|
26
31
|
private connect;
|
|
32
|
+
/**
|
|
33
|
+
* The engine isn't always listening when the run starts: a run started from the editor starts PIE at the same
|
|
34
|
+
* time, and the game's server only opens once PIE is up. Keep trying (every half second, for two minutes) so the
|
|
35
|
+
* run's events, queued meanwhile, still reach it. Without this the runner, the AI trail and the performance panel
|
|
36
|
+
* heard nothing from runs that started PIE themselves.
|
|
37
|
+
*/
|
|
38
|
+
private scheduleReconnect;
|
|
39
|
+
private static readonly RECONNECT_DELAY_MS;
|
|
40
|
+
private static readonly MAX_CONNECT_ATTEMPTS;
|
|
27
41
|
/**
|
|
28
42
|
* The engine broadcasts everything to every client, so most messages here are other clients' command
|
|
29
43
|
* responses. Only the ones about the run's replay and the tests' preview frames matter to the reporter.
|
|
@@ -134,6 +134,11 @@ class SpecterReporter {
|
|
|
134
134
|
ws = null;
|
|
135
135
|
isConnected = false;
|
|
136
136
|
queue = [];
|
|
137
|
+
/** Connection attempts since the last one that opened (the engine may not be listening yet) */
|
|
138
|
+
connectAttempts = 0;
|
|
139
|
+
reconnectTimer = null;
|
|
140
|
+
/** Set when the run has ended: no more reconnecting */
|
|
141
|
+
runEnded = false;
|
|
137
142
|
testStepCounters = new Map();
|
|
138
143
|
stepIdMap = new WeakMap();
|
|
139
144
|
/** Playwright's outer `Expect "<matcher>"` steps for Specter matchers. They are shown under their wrapper step's name. */
|
|
@@ -162,6 +167,7 @@ class SpecterReporter {
|
|
|
162
167
|
this.ws = socket;
|
|
163
168
|
socket.on('open', () => {
|
|
164
169
|
this.isConnected = true;
|
|
170
|
+
this.connectAttempts = 0;
|
|
165
171
|
// Send any queued messages
|
|
166
172
|
while (this.queue.length > 0) {
|
|
167
173
|
const msg = this.queue.shift();
|
|
@@ -174,13 +180,39 @@ class SpecterReporter {
|
|
|
174
180
|
});
|
|
175
181
|
socket.on('close', () => {
|
|
176
182
|
this.isConnected = false;
|
|
177
|
-
|
|
183
|
+
if (this.ws === socket) {
|
|
184
|
+
this.ws = null;
|
|
185
|
+
}
|
|
186
|
+
// Nothing more will arrive on this connection: stop waiting for the replay
|
|
178
187
|
this.releaseReplayWaiters();
|
|
188
|
+
this.scheduleReconnect();
|
|
179
189
|
});
|
|
180
190
|
socket.on('message', (data) => {
|
|
181
191
|
this.handleEngineMessage(data);
|
|
182
192
|
});
|
|
183
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* The engine isn't always listening when the run starts: a run started from the editor starts PIE at the same
|
|
196
|
+
* time, and the game's server only opens once PIE is up. Keep trying (every half second, for two minutes) so the
|
|
197
|
+
* run's events, queued meanwhile, still reach it. Without this the runner, the AI trail and the performance panel
|
|
198
|
+
* heard nothing from runs that started PIE themselves.
|
|
199
|
+
*/
|
|
200
|
+
scheduleReconnect() {
|
|
201
|
+
if (this.runEnded || this.reconnectTimer || this.connectAttempts >= SpecterReporter.MAX_CONNECT_ATTEMPTS) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
this.connectAttempts++;
|
|
205
|
+
this.reconnectTimer = setTimeout(() => {
|
|
206
|
+
this.reconnectTimer = null;
|
|
207
|
+
if (!this.runEnded) {
|
|
208
|
+
this.connect();
|
|
209
|
+
}
|
|
210
|
+
}, SpecterReporter.RECONNECT_DELAY_MS);
|
|
211
|
+
// Waiting to reconnect never keeps the run's process alive
|
|
212
|
+
this.reconnectTimer.unref?.();
|
|
213
|
+
}
|
|
214
|
+
static RECONNECT_DELAY_MS = 500;
|
|
215
|
+
static MAX_CONNECT_ATTEMPTS = 240;
|
|
184
216
|
/**
|
|
185
217
|
* The engine broadcasts everything to every client, so most messages here are other clients' command
|
|
186
218
|
* responses. Only the ones about the run's replay and the tests' preview frames matter to the reporter.
|
|
@@ -1004,6 +1036,11 @@ class SpecterReporter {
|
|
|
1004
1036
|
}
|
|
1005
1037
|
});
|
|
1006
1038
|
await this.saveRunTrace(result);
|
|
1039
|
+
this.runEnded = true;
|
|
1040
|
+
if (this.reconnectTimer) {
|
|
1041
|
+
clearTimeout(this.reconnectTimer);
|
|
1042
|
+
this.reconnectTimer = null;
|
|
1043
|
+
}
|
|
1007
1044
|
}
|
|
1008
1045
|
}
|
|
1009
1046
|
exports.default = SpecterReporter;
|