ravensight-playtest 0.8.3 → 0.10.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 +280 -66
- package/addons/ravensight_driver/driver.gd +666 -21
- package/docs/ADAPTERS.md +11 -7
- package/docs/NATIVE_RUNNER.md +3 -1
- package/docs/godot-driver.md +127 -13
- package/package.json +8 -6
- package/src/api/client.js +4 -3
- package/src/cli.js +84 -25
- package/src/commands/check.js +30 -4
- package/src/commands/fakeCore.js +1 -0
- package/src/commands/hosted.js +41 -12
- package/src/commands/init.js +17 -1
- package/src/commands/run.js +209 -14
- package/src/commands/upload.js +6 -2
- package/src/commands/validate.js +1 -1
- package/src/commands/validateHosted.js +50 -5
- package/src/config.js +33 -2
- package/src/hosted/archivePreflight.js +7 -7
- package/src/hosted/buildUpload.js +89 -8
- package/src/hosted/recordedRun.js +141 -26
- package/src/hosted/status.js +19 -10
- package/src/run/actionSelector.js +14 -3
- package/src/run/aggregate.js +57 -3
- package/src/run/anygame/controlbook.js +179 -0
- package/src/run/anygame/genre.js +179 -0
- package/src/run/anygame/index.js +258 -0
- package/src/run/anygame/language.js +336 -0
- package/src/run/anygame/memory.js +330 -0
- package/src/run/anygame/shared-hashes.json +10 -0
- package/src/run/anygame/shared.js +24 -0
- package/src/run/anygame/sound.js +342 -0
- package/src/run/args.js +75 -8
- package/src/run/choiceCheck.js +312 -0
- package/src/run/context.js +254 -13
- package/src/run/drivers/godot-observation.js +93 -6
- package/src/run/drivers/godot.js +769 -46
- package/src/run/drivers/recording.js +24 -4
- package/src/run/drivers/web.js +1242 -77
- package/src/run/edgePass.js +731 -0
- package/src/run/fixLoop.js +5 -4
- package/src/run/focus.js +65 -0
- package/src/run/gamepad.js +108 -0
- package/src/run/godotEdgePass.js +235 -0
- package/src/run/godotTesterProbes.js +192 -0
- package/src/run/headings.js +21 -0
- package/src/run/honesty.js +544 -0
- package/src/run/inputs.js +256 -0
- package/src/run/marks.js +142 -0
- package/src/run/personaLoop.js +1000 -79
- package/src/run/phone.js +7 -0
- package/src/run/pixels.js +215 -0
- package/src/run/playClock.js +162 -0
- package/src/run/readiness.js +585 -0
- package/src/run/refusal.js +67 -0
- package/src/run/regions.js +119 -0
- package/src/run/report.js +14 -2
- package/src/run/reportChecks.js +472 -0
- package/src/run/resume.js +3 -2
- package/src/run/screenshots.js +161 -0
- package/src/run/strip.js +114 -0
- package/src/run/testerLedger.js +312 -0
- package/src/run/testerProbes.js +584 -0
- package/src/run/thinRun.js +102 -0
- package/src/run/timeFreeze.js +79 -0
- package/src/run/tools.js +454 -29
- package/src/runDefaults.js +24 -2
package/src/run/fixLoop.js
CHANGED
|
@@ -76,10 +76,11 @@ const CACHE_BREAKPOINT = Object.freeze({ type: 'ephemeral' });
|
|
|
76
76
|
* The prefix written on turn N is exactly the prefix read on turn N+1, because
|
|
77
77
|
* these two loops only ever APPEND to `messages`. Nothing rewrites an earlier
|
|
78
78
|
* turn, so the bytes ahead of the marker are identical from one call to the
|
|
79
|
-
* next. (`personaLoop`
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
79
|
+
* next. (`personaLoop` does rewrite earlier turns: older observations become
|
|
80
|
+
* stubs and an older picture becomes a placeholder. It keeps its prefix stable
|
|
81
|
+
* another way, stubbing a block of observations at a time and keeping the
|
|
82
|
+
* picture after its own breakpoint; see ./context.js and its
|
|
83
|
+
* `withPlayCacheBreakpoint`.)
|
|
83
84
|
*
|
|
84
85
|
* Applied to a COPY, leaving the stored conversation unmarked, for two
|
|
85
86
|
* reasons. A request may carry at most four breakpoints, so a marker left
|
package/src/run/focus.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A run's focus, for a local playtest: goals to play towards and things to
|
|
3
|
+
* stay out of (`--focus`, `--avoid`), and where a web build opens (`--start`).
|
|
4
|
+
*
|
|
5
|
+
* A persona reads the expectations brief as JSON in its instructions, so the
|
|
6
|
+
* focus rides in a copy of the brief under one plainly named key. The brief
|
|
7
|
+
* itself is never changed, and nothing here goes to the server's copy.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** The focus block for the brief, or null when the run names none. */
|
|
11
|
+
export function focusBlock({ focus = [], avoid = [] } = {}) {
|
|
12
|
+
const lines = list => (Array.isArray(list) ? list.map(line => String(line).trim()).filter(Boolean).slice(0, 5) : []);
|
|
13
|
+
const towards = lines(focus), out = lines(avoid);
|
|
14
|
+
if (!towards.length && !out.length) return null;
|
|
15
|
+
return {
|
|
16
|
+
note: 'The studio set this for this run. Play towards the goals first, before anything else in this brief, and never enter or use what is listed to stay out of.',
|
|
17
|
+
...(towards.length ? { play_towards: towards } : {}),
|
|
18
|
+
...(out.length ? { stay_out_of: out } : {})
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A copy of the brief with this run's focus in it, or the brief itself when
|
|
24
|
+
* the run names no focus (or there is no brief to carry one).
|
|
25
|
+
*
|
|
26
|
+
* @param {Object|null} brief
|
|
27
|
+
* @param {{focus?: string[], avoid?: string[]}} options
|
|
28
|
+
* @returns {Object|null}
|
|
29
|
+
*/
|
|
30
|
+
export function briefWithFocus(brief, options = {}) {
|
|
31
|
+
const block = focusBlock(options);
|
|
32
|
+
if (!block || !brief || typeof brief !== 'object') return brief;
|
|
33
|
+
const fields = brief.fields && typeof brief.fields === 'object' ? brief.fields : null;
|
|
34
|
+
return fields ? { ...brief, fields: { ...fields, this_run_focus: block } } : { ...brief, this_run_focus: block };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The lines the run prints before its price, so the focus is said out loud. */
|
|
38
|
+
export function focusLines({ focus = [], avoid = [], start } = {}) {
|
|
39
|
+
const block = focusBlock({ focus, avoid });
|
|
40
|
+
return [
|
|
41
|
+
...(start ? [`Start: ${start}`] : []),
|
|
42
|
+
...(block?.play_towards ? [`Focus: ${block.play_towards.join('; ')}`] : []),
|
|
43
|
+
...(block?.stay_out_of ? [`Avoid: ${block.stay_out_of.join('; ')}`] : [])
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A web build's address with `--start` applied: a query replaces the
|
|
49
|
+
* address's own query, a hash its own hash, and nothing else moves.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} url
|
|
52
|
+
* @param {string} [start]
|
|
53
|
+
* @returns {string}
|
|
54
|
+
*/
|
|
55
|
+
export function withStart(url, start) {
|
|
56
|
+
if (!start || typeof url !== 'string') return url;
|
|
57
|
+
let parsed;
|
|
58
|
+
try { parsed = new URL(url); } catch { return url; }
|
|
59
|
+
const hashAt = start.indexOf('#');
|
|
60
|
+
if (start.startsWith('?')) { parsed.search = hashAt === -1 ? start : start.slice(0, hashAt); if (hashAt !== -1) parsed.hash = start.slice(hashAt); }
|
|
61
|
+
else parsed.hash = start;
|
|
62
|
+
return parsed.href;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default { focusBlock, briefWithFocus, focusLines, withStart };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A virtual gamepad for a game in a browser.
|
|
3
|
+
*
|
|
4
|
+
* Many web games read `navigator.getGamepads()`; a runner with no controller
|
|
5
|
+
* could only say so. This puts one standard gamepad behind that call, which
|
|
6
|
+
* the persona presses and holds through the `gamepad` tool. It stays
|
|
7
|
+
* disconnected until the first use, so a game that changes its prompts when a
|
|
8
|
+
* controller is plugged in looks to a keyboard player as it always did.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Button names, at the standard mapping's indexes. */
|
|
12
|
+
export const GAMEPAD_BUTTONS = Object.freeze(['A', 'B', 'X', 'Y', 'LB', 'RB', 'LT', 'RT', 'Back', 'Start', 'LS', 'RS', 'DPadUp', 'DPadDown', 'DPadLeft', 'DPadRight', 'Home']);
|
|
13
|
+
|
|
14
|
+
const ALIASES = Object.freeze({
|
|
15
|
+
cross: 'A', circle: 'B', square: 'X', triangle: 'Y', l1: 'LB', r1: 'RB', l2: 'LT', r2: 'RT', select: 'Back', share: 'Back', view: 'Back', options: 'Start', menu: 'Start',
|
|
16
|
+
l3: 'LS', r3: 'RS', up: 'DPadUp', down: 'DPadDown', left: 'DPadLeft', right: 'DPadRight', dpadup: 'DPadUp', dpaddown: 'DPadDown', dpadleft: 'DPadLeft', dpadright: 'DPadRight',
|
|
17
|
+
guide: 'Home', ps: 'Home', leftbumper: 'LB', rightbumper: 'RB', lefttrigger: 'LT', righttrigger: 'RT', leftstick: 'LS', rightstick: 'RS'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/** How long a press lasts when no hold is given: a few frames, so a game polling each frame sees it. */
|
|
21
|
+
export const GAMEPAD_TAP_MS = 100;
|
|
22
|
+
|
|
23
|
+
/** The longest the pad is held in one action. */
|
|
24
|
+
export const GAMEPAD_MAX_HOLD_MS = 5000;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A button name as the standard mapping's index, or -1.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} name
|
|
30
|
+
* @returns {number}
|
|
31
|
+
*/
|
|
32
|
+
export function gamepadButtonIndex(name) {
|
|
33
|
+
const text = String(name == null ? '' : name).trim();
|
|
34
|
+
const exact = GAMEPAD_BUTTONS.findIndex(button => button.toLowerCase() === text.toLowerCase());
|
|
35
|
+
if (exact >= 0) return exact;
|
|
36
|
+
const alias = ALIASES[text.toLowerCase().replace(/[\s_-]+/g, '')];
|
|
37
|
+
return alias ? GAMEPAD_BUTTONS.indexOf(alias) : -1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const axis = value => Math.min(1, Math.max(-1, Number(value) || 0));
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A `gamepad` tool input as what the page is set to, or the reason it cannot be.
|
|
44
|
+
*
|
|
45
|
+
* @param {Object} input
|
|
46
|
+
* @returns {{buttons: Array<number>, axes: Array<number>, holdMs: number, names: Array<string>}|{error: string}}
|
|
47
|
+
*/
|
|
48
|
+
export function gamepadState(input = {}) {
|
|
49
|
+
const names = Array.isArray(input.buttons) ? input.buttons : typeof input.buttons === 'string' ? [input.buttons] : [];
|
|
50
|
+
const buttons = [];
|
|
51
|
+
for (const name of names) {
|
|
52
|
+
const index = gamepadButtonIndex(name);
|
|
53
|
+
if (index < 0) return { error: `"${String(name)}" is not a gamepad button; the buttons are ${GAMEPAD_BUTTONS.join(', ')}` };
|
|
54
|
+
if (!buttons.includes(index)) buttons.push(index);
|
|
55
|
+
}
|
|
56
|
+
const stick = value => (value && typeof value === 'object' ? [axis(value.x), axis(value.y)] : [0, 0]);
|
|
57
|
+
const axes = [...stick(input.left_stick ?? input.leftStick), ...stick(input.right_stick ?? input.rightStick)];
|
|
58
|
+
if (buttons.length === 0 && axes.every(value => value === 0)) return { error: 'a gamepad action needs buttons, left_stick or right_stick' };
|
|
59
|
+
const hold = Math.round(Number(input.hold_ms ?? input.holdMs) || 0);
|
|
60
|
+
return { buttons, axes, holdMs: Math.min(Math.max(hold, 0), GAMEPAD_MAX_HOLD_MS) || GAMEPAD_TAP_MS, names: buttons.map(index => GAMEPAD_BUTTONS[index]) };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* c8 ignore start */
|
|
64
|
+
/** Serialised by Playwright into every document, so it closes over nothing. */
|
|
65
|
+
export function virtualGamepadInit() {
|
|
66
|
+
if (window.__rsPad) return;
|
|
67
|
+
const state = { connected: false, buttons: new Array(17).fill(0), axes: [0, 0, 0, 0], timestamp: 0 };
|
|
68
|
+
const real = typeof navigator.getGamepads === 'function' ? navigator.getGamepads.bind(navigator) : () => [];
|
|
69
|
+
const pad = () => ({
|
|
70
|
+
id: 'Ravensight Virtual Gamepad (STANDARD GAMEPAD)',
|
|
71
|
+
index: 0,
|
|
72
|
+
connected: true,
|
|
73
|
+
mapping: 'standard',
|
|
74
|
+
timestamp: state.timestamp,
|
|
75
|
+
axes: state.axes.slice(),
|
|
76
|
+
buttons: state.buttons.map(value => ({ pressed: value > 0.5, touched: value > 0, value })),
|
|
77
|
+
vibrationActuator: null,
|
|
78
|
+
hapticActuators: []
|
|
79
|
+
});
|
|
80
|
+
const read = () => (state.connected ? [pad(), null, null, null] : real());
|
|
81
|
+
try { navigator.getGamepads = read; } catch { /* read only here */ }
|
|
82
|
+
try { Object.defineProperty(Navigator.prototype, 'getGamepads', { configurable: true, writable: true, value: read }); } catch { /* read only here */ }
|
|
83
|
+
const announce = type => {
|
|
84
|
+
const event = new Event(type);
|
|
85
|
+
Object.defineProperty(event, 'gamepad', { value: pad() });
|
|
86
|
+
window.dispatchEvent(event);
|
|
87
|
+
};
|
|
88
|
+
Object.defineProperty(window, '__rsPad', { value: Object.freeze({
|
|
89
|
+
set(buttons, axes) {
|
|
90
|
+
state.buttons = new Array(17).fill(0);
|
|
91
|
+
for (const index of buttons || []) if (index >= 0 && index < 17) state.buttons[index] = 1;
|
|
92
|
+
state.axes = [0, 1, 2, 3].map(i => Number((axes || [])[i]) || 0);
|
|
93
|
+
state.timestamp = performance.now();
|
|
94
|
+
if (!state.connected) { state.connected = true; announce('gamepadconnected'); }
|
|
95
|
+
return true;
|
|
96
|
+
},
|
|
97
|
+
release() {
|
|
98
|
+
state.buttons = new Array(17).fill(0);
|
|
99
|
+
state.axes = [0, 0, 0, 0];
|
|
100
|
+
state.timestamp = performance.now();
|
|
101
|
+
return true;
|
|
102
|
+
},
|
|
103
|
+
get connected() { return state.connected; }
|
|
104
|
+
}), enumerable: false });
|
|
105
|
+
}
|
|
106
|
+
/* c8 ignore stop */
|
|
107
|
+
|
|
108
|
+
export default { virtualGamepadInit, gamepadState, gamepadButtonIndex, GAMEPAD_BUTTONS };
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// The edge behaviour pass for a Godot game: the checks ./edgePass.js makes on
|
|
2
|
+
// a web page, made through the driver addon (1.5.0) where it can make them.
|
|
3
|
+
// Scripted, after the last screen of play is saved, with no model call.
|
|
4
|
+
//
|
|
5
|
+
// What each check is, and what it is not:
|
|
6
|
+
//
|
|
7
|
+
// - focus: the game is TOLD its window lost focus and got it back (the
|
|
8
|
+
// engine's own focus notifications, to every node). The desktop's real
|
|
9
|
+
// focus is left alone, because a lockstep window never takes it.
|
|
10
|
+
// - resize: the window is resized to three sizes; a control a player presses
|
|
11
|
+
// that ends up outside the window is measured.
|
|
12
|
+
// - rapid: the keys the persona used, pressed as fast as the game ticks.
|
|
13
|
+
// - idle: five seconds of game time with no input.
|
|
14
|
+
// - restart: when the game has written files under user://, it is started a
|
|
15
|
+
// second time on the same save folder, without a window, to see that it
|
|
16
|
+
// comes up and that the files are still there. Only on a run with a save
|
|
17
|
+
// folder of its own (not --realtime).
|
|
18
|
+
//
|
|
19
|
+
// A check says ok, problem (a finding of the runner, with a screenshot), note
|
|
20
|
+
// or not_checked with the reason. A problem is only what was measured.
|
|
21
|
+
import { screenDelta, significant } from './pixels.js';
|
|
22
|
+
import { flatShare, BLANK_SHARE } from './honesty.js';
|
|
23
|
+
import { EDGE_SIZES, heldKeyOf, usedKeysOf } from './edgePass.js';
|
|
24
|
+
|
|
25
|
+
export const GODOT_EDGE_TIMING = Object.freeze({ holdMs: 400, awayMs: 1500, settleMs: 300, idleMs: 5000, burstKeys: 40, burstGapMs: 20, sizeSettleMs: 400 });
|
|
26
|
+
|
|
27
|
+
/** A key as the addon names it. */
|
|
28
|
+
const addonKey = key => (key === ' ' ? 'Space' : String(key));
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Files that were there before a second start and are gone or emptied after.
|
|
32
|
+
*
|
|
33
|
+
* @param {Array<{path: string, size: number}>} before
|
|
34
|
+
* @param {Array<{path: string, size: number}>} after
|
|
35
|
+
* @returns {{lost: Array<string>, emptied: Array<string>, kept: Array<string>}}
|
|
36
|
+
*/
|
|
37
|
+
export function saveDiff(before = [], after = []) {
|
|
38
|
+
const now = new Map((after || []).map(file => [file.path, file.size]));
|
|
39
|
+
const lost = [];
|
|
40
|
+
const emptied = [];
|
|
41
|
+
const kept = [];
|
|
42
|
+
for (const file of before || []) {
|
|
43
|
+
if (!now.has(file.path)) lost.push(file.path);
|
|
44
|
+
else if (file.size > 0 && now.get(file.path) === 0) emptied.push(file.path);
|
|
45
|
+
else kept.push(file.path);
|
|
46
|
+
}
|
|
47
|
+
return { lost, emptied, kept };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {Object} args
|
|
52
|
+
* @param {Object} args.driver a launched GodotDriver
|
|
53
|
+
* @returns {Promise<{checks: Array<Object>, restored: boolean, elapsedMs: number}>}
|
|
54
|
+
*/
|
|
55
|
+
export async function runGodotEdgePass({ driver, actionRecords = [], screenshots = [], observation = null, signal = null, log = () => {}, timing = GODOT_EDGE_TIMING, sizes = EDGE_SIZES }) {
|
|
56
|
+
const started = Date.now();
|
|
57
|
+
const checks = [];
|
|
58
|
+
const add = check => { checks.push(check); };
|
|
59
|
+
const stopped = () => Boolean(signal && signal.aborted) || Boolean(driver.gameEnded && driver.gameEnded());
|
|
60
|
+
const call = (method, params = {}) => driver.rpc.call(method, params);
|
|
61
|
+
const probe = () => driver._probe().catch(() => null);
|
|
62
|
+
const blank = async () => {
|
|
63
|
+
const share = flatShare(await probe());
|
|
64
|
+
return share !== null && share >= BLANK_SHARE;
|
|
65
|
+
};
|
|
66
|
+
/** Script errors the game logged since the last call. */
|
|
67
|
+
const errors = async () => (await driver.consoleErrors().catch(() => [])).filter(entry => entry && entry.kind === 'error').map(entry => String(entry.text || '').slice(0, 200));
|
|
68
|
+
const shot = async (name, reason) => {
|
|
69
|
+
try {
|
|
70
|
+
const saved = await driver.screenshot(name);
|
|
71
|
+
if (saved && saved.relativePath) {
|
|
72
|
+
screenshots.push({ ...saved, edge: true, reason: `edge check: ${reason} (saved by the runner)`, ...(Number.isInteger(observation) ? { observation } : {}), at: Date.now(), order: Number.MAX_SAFE_INTEGER - 100 + screenshots.length });
|
|
73
|
+
return saved.relativePath;
|
|
74
|
+
}
|
|
75
|
+
} catch {
|
|
76
|
+
// No picture is still a check.
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
};
|
|
80
|
+
/** Whether the screen moved over a stretch of game time with no input. */
|
|
81
|
+
const movedOver = async ms => {
|
|
82
|
+
const before = await probe();
|
|
83
|
+
await driver.runFor(ms);
|
|
84
|
+
const after = await probe();
|
|
85
|
+
return Boolean(before && after && significant(screenDelta(before, after)));
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
await errors();
|
|
89
|
+
const original = await call('window_size', {}).then(answer => answer.size, () => null);
|
|
90
|
+
let restored = true;
|
|
91
|
+
|
|
92
|
+
// Focus lost and returned, with a key held.
|
|
93
|
+
if (!stopped()) {
|
|
94
|
+
const title = 'Focus lost and returned';
|
|
95
|
+
const key = addonKey(heldKeyOf(actionRecords));
|
|
96
|
+
try {
|
|
97
|
+
const movingBefore = await movedOver(timing.settleMs);
|
|
98
|
+
await driver.sendKey(key, true, timing.holdMs);
|
|
99
|
+
const away = await call('edge_focus', { focused: false });
|
|
100
|
+
const movedAway = await movedOver(timing.awayMs);
|
|
101
|
+
await driver.sendKey(key, false, 0);
|
|
102
|
+
const back = await call('edge_focus', { focused: true });
|
|
103
|
+
await driver.runFor(timing.settleMs);
|
|
104
|
+
const thrown = await errors();
|
|
105
|
+
const empty = await blank();
|
|
106
|
+
const layout = await call('edge_layout', {}).catch(() => null);
|
|
107
|
+
const stillPaused = Boolean(layout && layout.paused) && !away.paused;
|
|
108
|
+
if (thrown.length > 0) {
|
|
109
|
+
const picture = await shot('edge-focus', 'the game after it was told it lost focus and got it back');
|
|
110
|
+
add({ name: 'focus', title, status: 'problem', detail: `the game logged an error when it was told its window lost focus and got it back: ${thrown[0]}`, screenshot: picture, finding: { severity: 'major', title: 'The game logs an error when its window loses focus', description: `With ${key} held, the game was told its window lost focus, left for ${timing.awayMs / 1000} seconds of game time, and told it had focus again. It logged: ${thrown.slice(0, 3).join(' | ')}.` } });
|
|
111
|
+
} else if (empty) {
|
|
112
|
+
const picture = await shot('edge-focus', 'the game after it was told it lost focus and got it back');
|
|
113
|
+
add({ name: 'focus', title, status: 'problem', detail: 'the screen was blank after the game was told it had focus again', screenshot: picture, finding: { severity: 'major', title: 'The game shows a blank screen after its window loses focus and gets it back', description: `With ${key} held, the game was told its window lost focus and, ${timing.awayMs / 1000} seconds of game time later, that it had focus again. The screen was then one flat colour.` } });
|
|
114
|
+
} else {
|
|
115
|
+
add({ name: 'focus', title, status: 'note', detail: `the game was told its window lost focus with ${key} held, and that it had focus again ${timing.awayMs / 1000} seconds of game time later; it logged no error and drew its screen. While away ${back.paused || away.paused ? 'it paused itself' : movedAway ? 'the screen kept moving, so the game does not pause when it loses focus' : movingBefore ? 'the screen stood still, so the game stops when it loses focus' : 'the screen stood still, as it did before'}${stillPaused ? '. It was still paused after focus came back; whether it shows a way to resume was not judged' : ''}. The desktop's real focus was not changed, so a key the engine itself lets go of on a real focus loss was not tested` });
|
|
116
|
+
}
|
|
117
|
+
} catch (error) {
|
|
118
|
+
if (stopped()) throw error;
|
|
119
|
+
add({ name: 'focus', title, status: 'not_checked', detail: `the check could not be made (${String(error && error.message).slice(0, 120)})` });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// The window at three sizes.
|
|
124
|
+
if (!stopped() && original) {
|
|
125
|
+
const title = 'Window resized';
|
|
126
|
+
const problems = [];
|
|
127
|
+
const seen = [];
|
|
128
|
+
let picture = null;
|
|
129
|
+
try {
|
|
130
|
+
for (const size of sizes) {
|
|
131
|
+
if (stopped()) break;
|
|
132
|
+
const set = await call('window_size', { width: size.width, height: size.height });
|
|
133
|
+
await driver.runFor(timing.sizeSettleMs);
|
|
134
|
+
const got = set.size || [size.width, size.height];
|
|
135
|
+
// A desktop that will not give the window this size is not the game's doing.
|
|
136
|
+
const reached = Math.abs(got[0] - size.width) <= 4 && Math.abs(got[1] - size.height) <= 4;
|
|
137
|
+
const now = await call('window_size', {}).then(answer => answer.size, () => got);
|
|
138
|
+
if (!reached || Math.abs(now[0] - size.width) > 4 || Math.abs(now[1] - size.height) > 4) { seen.push(`${size.label}: the desktop did not give the window this size`); continue; }
|
|
139
|
+
const layout = await call('edge_layout', {});
|
|
140
|
+
const empty = await blank();
|
|
141
|
+
if (empty) {
|
|
142
|
+
picture = picture || await shot(`edge-resize-${size.width}x${size.height}`, `the game at ${size.label}`);
|
|
143
|
+
problems.push({ size, text: 'the screen was blank' });
|
|
144
|
+
} else if (layout.cut.length > 0) {
|
|
145
|
+
picture = picture || await shot(`edge-resize-${size.width}x${size.height}`, `the game at ${size.label}`);
|
|
146
|
+
const names = layout.cut.slice(0, 5).map(entry => (entry.text ? `"${entry.text}"` : entry.name)).join(', ');
|
|
147
|
+
problems.push({ size, text: `${layout.cut.length} of ${layout.pressable} controls a player presses lay outside the window (${names})` });
|
|
148
|
+
} else seen.push(`${size.label}: every control a player presses was inside the window`);
|
|
149
|
+
}
|
|
150
|
+
} finally {
|
|
151
|
+
await call('window_size', { width: original[0], height: original[1] }).catch(() => { restored = false; });
|
|
152
|
+
await driver.runFor(timing.sizeSettleMs).catch(() => {});
|
|
153
|
+
const back = await call('window_size', {}).then(answer => answer.size, () => null);
|
|
154
|
+
if (!back || back[0] !== original[0] || back[1] !== original[1]) restored = false;
|
|
155
|
+
}
|
|
156
|
+
const thrown = await errors();
|
|
157
|
+
if (problems.length > 0) {
|
|
158
|
+
const worst = problems[0];
|
|
159
|
+
add({ name: 'resize', title, status: 'problem', detail: problems.map(problem => `at ${problem.size.label} ${problem.text}`).join('; '), screenshot: picture, finding: { severity: problems.some(problem => problem.size.desktop) ? 'major' : 'minor', title: worst.text === 'the screen was blank' ? `The game shows a blank screen in a window of ${worst.size.label}` : `Controls fall outside the window at ${worst.size.label}`, description: `The game window was resized after play. ${problems.map(problem => `At ${problem.size.label} ${problem.text}.`).join(' ')} A player with a window that size cannot reach them.` } });
|
|
160
|
+
} else if (seen.length === 0) add({ name: 'resize', title, status: 'not_checked', detail: 'the window could not be resized' });
|
|
161
|
+
else add({ name: 'resize', title, status: seen.every(line => /did not give/.test(line)) ? 'not_checked' : 'ok', detail: `${seen.join('; ')}${thrown.length > 0 ? `. It logged while resizing: ${thrown[0]}` : ''}. How the game looks at each size was not judged` });
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// The keys the persona used, as fast as the game ticks.
|
|
165
|
+
if (!stopped()) {
|
|
166
|
+
const title = 'Rapid input';
|
|
167
|
+
const keys = usedKeysOf(actionRecords).map(addonKey);
|
|
168
|
+
try {
|
|
169
|
+
for (let i = 0; i < timing.burstKeys; i += 1) {
|
|
170
|
+
const key = keys[i % keys.length];
|
|
171
|
+
await driver.sendKey(key, true, timing.burstGapMs);
|
|
172
|
+
await driver.sendKey(key, false, 0);
|
|
173
|
+
}
|
|
174
|
+
await driver.runFor(timing.settleMs);
|
|
175
|
+
const thrown = await errors();
|
|
176
|
+
const empty = await blank();
|
|
177
|
+
if (thrown.length > 0 || empty) {
|
|
178
|
+
const picture = await shot('edge-rapid', 'the game after a burst of key presses');
|
|
179
|
+
add({ name: 'rapid', title, status: 'problem', detail: empty ? 'the screen was blank after a burst of key presses' : `the game logged an error during a burst of key presses: ${thrown[0]}`, screenshot: picture, finding: { severity: 'major', title: empty ? 'The game shows a blank screen after rapid key presses' : 'The game logs an error under rapid key presses', description: `${timing.burstKeys} presses of the keys the session used (${keys.join(', ')}) were sent ${timing.burstGapMs} ms of game time apart. ${empty ? 'The screen was then one flat colour.' : `The game logged: ${thrown.slice(0, 3).join(' | ')}.`}` } });
|
|
180
|
+
} else add({ name: 'rapid', title, status: 'ok', detail: `${timing.burstKeys} presses of ${keys.join(', ')} ${timing.burstGapMs} ms of game time apart: the game logged no error and drew its screen` });
|
|
181
|
+
} catch (error) {
|
|
182
|
+
if (stopped()) throw error;
|
|
183
|
+
add({ name: 'rapid', title, status: 'not_checked', detail: `the check could not be made (${String(error && error.message).slice(0, 120)})` });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Left alone.
|
|
188
|
+
if (!stopped()) {
|
|
189
|
+
const title = 'Left alone for five seconds';
|
|
190
|
+
try {
|
|
191
|
+
const moved = await movedOver(timing.idleMs);
|
|
192
|
+
const thrown = await errors();
|
|
193
|
+
const empty = await blank();
|
|
194
|
+
if (thrown.length > 0 || empty) {
|
|
195
|
+
const picture = await shot('edge-idle', 'the game after five seconds with no input');
|
|
196
|
+
add({ name: 'idle', title, status: 'problem', detail: empty ? 'the screen was blank after five seconds with no input' : `the game logged an error while left alone: ${thrown[0]}`, screenshot: picture, finding: { severity: 'major', title: empty ? 'The game shows a blank screen when left alone' : 'The game logs an error when left alone', description: `The game was left with no input for ${timing.idleMs / 1000} seconds of game time. ${empty ? 'The screen was then one flat colour.' : `It logged: ${thrown.slice(0, 3).join(' | ')}.`}` } });
|
|
197
|
+
} else add({ name: 'idle', title, status: 'ok', detail: `${timing.idleMs / 1000} seconds of game time with no input: the game logged no error and drew its screen${moved ? ', which moved on its own meanwhile' : ', which did not change'}` });
|
|
198
|
+
} catch (error) {
|
|
199
|
+
if (stopped()) throw error;
|
|
200
|
+
add({ name: 'idle', title, status: 'not_checked', detail: `the check could not be made (${String(error && error.message).slice(0, 120)})` });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// A second start on the same save folder.
|
|
205
|
+
if (!stopped()) {
|
|
206
|
+
const title = 'Started again on its save data';
|
|
207
|
+
try {
|
|
208
|
+
const stored = await call('user_files', {}).then(answer => answer.files || [], () => null);
|
|
209
|
+
if (stored === null) add({ name: 'restart', title, status: 'not_checked', detail: 'the driver addon in this project is older than 1.5.0 and cannot list what the game saved' });
|
|
210
|
+
else if (stored.length === 0) add({ name: 'restart', title, status: 'note', detail: 'the game wrote nothing under user:// during this session, so there was no save to start again from' });
|
|
211
|
+
else {
|
|
212
|
+
const second = await driver.restartCheck();
|
|
213
|
+
if (second === null) add({ name: 'restart', title, status: 'not_checked', detail: `the game wrote ${stored.length} file(s) under user:// (${stored.slice(0, 4).map(file => file.path).join(', ')}); a second start is only made on a run with a save folder of its own, which a --realtime run does not have` });
|
|
214
|
+
else if (!second.booted) {
|
|
215
|
+
const picture = await shot('edge-restart', 'the game as the session left it, before the second start failed');
|
|
216
|
+
add({ name: 'restart', title, status: 'problem', detail: `started a second time on the files this session saved, ${second.error}`, screenshot: picture, finding: { severity: 'blocker', title: 'The game does not start again on the save it wrote', description: `During this session the game wrote ${stored.slice(0, 6).map(file => file.path).join(', ')} under user://. Started a second time on that folder (without a window), ${second.error}.${second.log ? ` Its last output: ${second.log.split('\n').slice(-3).join(' | ').slice(0, 400)}` : ''} A fresh start with no save came up at the beginning of this run.` } });
|
|
217
|
+
} else {
|
|
218
|
+
const diff = saveDiff(stored, second.files || []);
|
|
219
|
+
const gone = [...diff.lost, ...diff.emptied.map(name => `${name} (emptied)`)];
|
|
220
|
+
if (second.files && gone.length > 0) {
|
|
221
|
+
const picture = await shot('edge-restart', 'the game as the session left it, before the second start');
|
|
222
|
+
add({ name: 'restart', title, status: 'problem', detail: `after a second start ${gone.length} saved file(s) were gone or empty: ${gone.slice(0, 6).join(', ')}`, screenshot: picture, finding: { severity: 'major', title: 'Saved files are gone after the game starts again', description: `During this session the game wrote ${stored.slice(0, 8).map(file => file.path).join(', ')} under user://. After it was started a second time on that folder, ${gone.slice(0, 8).join(', ')} ${gone.length === 1 ? 'was' : 'were'} gone or empty${diff.kept.length > 0 ? ` and ${diff.kept.slice(0, 6).join(', ')} remained` : ''}. Starting the game removed ${gone.length === 1 ? 'it' : 'them'}.` } });
|
|
223
|
+
} else add({ name: 'restart', title, status: 'ok', detail: `the game wrote ${stored.length} file(s) under user:// (${stored.slice(0, 4).map(file => file.path).join(', ')}${stored.length > 4 ? ', ...' : ''}); started a second time on them, without a window, it came up${second.scene ? ` at ${second.scene}` : ''} and the files were still there${second.errors && second.errors.length > 0 ? `. It logged on that start: ${second.errors[0].slice(0, 160)}` : ''}. Whether it reads them back into the same place was not played` });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
} catch (error) {
|
|
227
|
+
if (stopped()) throw error;
|
|
228
|
+
add({ name: 'restart', title, status: 'not_checked', detail: `the check could not be made (${String(error && error.message).slice(0, 120)})` });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
log(`edge behaviour checks: ${checks.map(check => `${check.name} ${check.status}`).join(', ')}.`);
|
|
232
|
+
return { checks, restored, elapsedMs: Date.now() - started };
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export default { runGodotEdgePass, saveDiff };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
// The tester probes for a Godot game, through the driver addon: the ones a
|
|
2
|
+
// keyboard can make. Scripted, on the runner's own clock, no model call.
|
|
3
|
+
//
|
|
4
|
+
// Probes: one key pressed many times fast, opposite keys held together, the
|
|
5
|
+
// player pushed to the edges of the play area (each arrow held until the
|
|
6
|
+
// screen stops moving), and pause and resume by key. Oracles: a script error
|
|
7
|
+
// the game logs, tied to the probe that raised it; a game that exits; a blank
|
|
8
|
+
// screen; the game's own numbers breaking their rules (read from the scene
|
|
9
|
+
// outline and the game's state hook); and a soft lock (a key that moved the
|
|
10
|
+
// screen twice running moves nothing any more, and nothing else does).
|
|
11
|
+
//
|
|
12
|
+
// A suspected bug is tried again in the session. A Godot run's replay
|
|
13
|
+
// (./replay.js) compares state hashes of the recorded inputs and has no place
|
|
14
|
+
// to run a probe again, so each finding here says how often it came back in
|
|
15
|
+
// the session and that it was not tried from a fresh start. What a keyboard
|
|
16
|
+
// cannot do on this driver (text fields, buttons never named, a menu left and
|
|
17
|
+
// entered again) is listed as not tested.
|
|
18
|
+
import { screenDelta, significant } from './pixels.js';
|
|
19
|
+
import { flatShare, BLANK_SHARE } from './honesty.js';
|
|
20
|
+
import { usedKeysOf } from './edgePass.js';
|
|
21
|
+
import { brokenNow, reproducedWords } from './testerProbes.js';
|
|
22
|
+
|
|
23
|
+
export const GODOT_PROBE_TIMING = Object.freeze({ settleMs: 300, rapidPresses: 15, rapidGapMs: 20, holdMs: 700, edgeHoldMs: 400, edgeMaxMs: 4000, retries: 2 });
|
|
24
|
+
|
|
25
|
+
/** The probes this driver runs, and the ones it cannot, with the words the report uses. */
|
|
26
|
+
export const GODOT_PROBES = Object.freeze([
|
|
27
|
+
['rapid', 'rapid repeated input on one key'],
|
|
28
|
+
['opposite', 'opposite keys held together'],
|
|
29
|
+
['edges', 'the edges of the play area'],
|
|
30
|
+
['pause', 'pause and resume by key']
|
|
31
|
+
]);
|
|
32
|
+
export const GODOT_NOT_PROBED = 'Text fields, buttons play never named, a menu left and entered again, the wrong order and input while loading are not scripted on this driver: not tested by the runner.';
|
|
33
|
+
|
|
34
|
+
const OPPOSITES = [['Left', 'Right'], ['Up', 'Down'], ['A', 'D']];
|
|
35
|
+
const addonKey = key => ({ ' ': 'Space', ArrowLeft: 'Left', ArrowRight: 'Right', ArrowUp: 'Up', ArrowDown: 'Down' }[key] || String(key));
|
|
36
|
+
const q = value => `"${String(value || '').replace(/"/g, "'").slice(0, 60)}"`;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Run the probes on a launched Godot driver. Never throws: a probe that
|
|
40
|
+
* fails is recorded as not checked.
|
|
41
|
+
*
|
|
42
|
+
* @param {Object} args
|
|
43
|
+
* @returns {Promise<{checks: Array<Object>, suspects: Array<Object>, canaries: Array<string>, elapsedMs: number}>}
|
|
44
|
+
*/
|
|
45
|
+
export async function runGodotTesterProbes({ driver, actionRecords = [], screenshots = [], observation = null, signal = null, log = () => {}, timing = GODOT_PROBE_TIMING }) {
|
|
46
|
+
const started = Date.now();
|
|
47
|
+
const checks = [], suspects = [];
|
|
48
|
+
const stopped = () => Boolean(signal && signal.aborted) || Boolean(driver.gameEnded && driver.gameEnded());
|
|
49
|
+
const probe = () => driver._probe().catch(() => null);
|
|
50
|
+
const errors = async () => (await driver.consoleErrors().catch(() => [])).filter(entry => entry && entry.kind === 'error').map(entry => String(entry.text || '').slice(0, 200));
|
|
51
|
+
const text = async () => { try { const seen = await driver.observe(); return String((seen && seen.text) || ''); } catch { return ''; } };
|
|
52
|
+
const moved = async work => { const before = await probe(); await work(); const after = await probe(); return Boolean(before && after && significant(screenDelta(before, after))); };
|
|
53
|
+
const tap = async (key, ms) => { await driver.sendKey(key, true, ms); await driver.sendKey(key, false, 0); await driver.runFor(timing.settleMs); };
|
|
54
|
+
const shot = async (name, reason) => {
|
|
55
|
+
try {
|
|
56
|
+
const saved = await driver.screenshot(name);
|
|
57
|
+
if (saved && saved.relativePath) { screenshots.push({ ...saved, edge: true, reason: `tester probe: ${reason} (saved by the runner)`, ...(Number.isInteger(observation) ? { observation } : {}), at: Date.now(), order: Number.MAX_SAFE_INTEGER - 200 + screenshots.length }); return saved.relativePath; }
|
|
58
|
+
} catch { /* no picture is still a check */ }
|
|
59
|
+
return null;
|
|
60
|
+
};
|
|
61
|
+
const used = usedKeysOf(actionRecords).map(addonKey);
|
|
62
|
+
// Keys that move the screen twice running: what shows later that the game stopped answering.
|
|
63
|
+
const canaries = [];
|
|
64
|
+
|
|
65
|
+
const judge = async (what, { before = '', softLock = true } = {}) => {
|
|
66
|
+
const hits = [];
|
|
67
|
+
if (driver.gameEnded && driver.gameEnded()) { hits.push({ oracle: 'crash', severity: 'blocker', category: 'bug', title: `The game ended after ${what}`, description: `The game process ended after ${what}. It had run through play.` }); return hits; }
|
|
68
|
+
for (const message of await errors()) hits.push({ oracle: 'error', key: message.replace(/\d+/g, '#'), severity: 'major', category: 'bug', title: `A script error was raised when ${what}`, description: `The game logged a script error when ${what}: ${q(message)}.` });
|
|
69
|
+
const share = flatShare(await probe());
|
|
70
|
+
if (share !== null && share >= BLANK_SHARE) hits.push({ oracle: 'blank', severity: 'major', category: 'bug', title: `The screen went blank after ${what}`, description: `After ${what} the whole screen showed one flat colour.` });
|
|
71
|
+
const now = await text();
|
|
72
|
+
for (const b of brokenNow(now)) {
|
|
73
|
+
if (brokenNow(before).some(x => x.kind === b.kind && x.label === b.label && x.to === b.to)) continue;
|
|
74
|
+
const words = { negative: [`"${b.label}" goes below zero`, `The game showed "${b.label}" at ${b.to} after ${what}. A count of this kind cannot be less than nothing.`], above_max: [`"${b.label}" goes above its maximum`, `The game showed "${b.label}" at ${b.to} of ${b.max} after ${what}: past the limit the game itself prints beside it.`], not_a_number: [`"${b.label}" shows "${b.to}" where a number belongs`, `The game printed "${b.label}" as "${b.to}" after ${what}.`] }[b.kind];
|
|
75
|
+
hits.push({ oracle: 'invariant', key: `${b.kind}:${b.label}`, severity: 'major', category: 'bug', title: words[0], description: words[1] });
|
|
76
|
+
}
|
|
77
|
+
if (softLock && canaries.length > 0 && !hits.some(h => h.oracle === 'blank')) {
|
|
78
|
+
const tries = [];
|
|
79
|
+
let answered = false;
|
|
80
|
+
for (const key of [...canaries, ...canaries.map(k => (OPPOSITES.flat().includes(k) ? OPPOSITES.find(p => p.includes(k)).find(x => x !== k) : null)).filter(Boolean), 'Enter', 'Space']) {
|
|
81
|
+
tries.push(key);
|
|
82
|
+
if (await moved(() => tap(key, 200))) { answered = true; break; }
|
|
83
|
+
}
|
|
84
|
+
if (!answered && tries.length >= 2) hits.push({ oracle: 'soft_lock', severity: 'major', category: 'bug', title: `The game stops answering input after ${what}`, description: `After ${what}, none of ${tries.length} keys changed the screen (${tries.join(', ')}), although the game was still running. Before it, ${canaries[0]} changed the screen. A player can no longer do anything: a soft lock.` });
|
|
85
|
+
}
|
|
86
|
+
return hits;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const run = async (id, fn) => {
|
|
90
|
+
const title = GODOT_PROBES.find(p => p[0] === id)[1];
|
|
91
|
+
const add = check => { checks.push({ name: id, title, ...check }); log(`tester probe, ${title}: ${check.status}${check.detail ? ` (${check.detail})` : ''}`); };
|
|
92
|
+
if (stopped()) return add({ status: 'not_checked', detail: 'the game had ended' });
|
|
93
|
+
const stuck = suspects.find(s => ['soft_lock', 'crash', 'blank'].includes(s.oracle));
|
|
94
|
+
if (stuck) return add({ status: 'not_checked', detail: `the game had stopped answering after ${stuck.what}` });
|
|
95
|
+
try {
|
|
96
|
+
const r = await fn();
|
|
97
|
+
if (r && r.skip) return add({ status: 'not_checked', detail: r.skip });
|
|
98
|
+
for (const hit of r.hits) if (!suspects.some(s => s.oracle === hit.oracle && s.key === hit.key && (hit.key !== undefined || s.probe === id))) suspects.push({ ...hit, probe: id, what: r.what, again: r.again, screenshot: await shot(`probe-${id}-${hit.oracle}`, hit.title) });
|
|
99
|
+
add({ status: r.hits.length ? 'problem' : 'ok', detail: r.hits.length ? r.hits.map(h => h.title).join('; ') : 'nothing went wrong in this check' });
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (stopped()) { suspects.push({ oracle: 'crash', probe: id, severity: 'blocker', category: 'bug', title: `The game ended during the probe of ${title}`, description: `The game process ended while the runner probed ${title}. It had run through play.`, what: title, screenshot: null }); return add({ status: 'problem', detail: 'the game ended' }); }
|
|
102
|
+
add({ status: 'not_checked', detail: `the probe itself failed (${String(error && error.message).split('\n')[0].slice(0, 80)})` });
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
await errors();
|
|
107
|
+
if (driver.headless) {
|
|
108
|
+
for (const [id, title] of GODOT_PROBES) checks.push({ name: id, title, status: 'not_checked', detail: 'a headless Godot draws no picture, so the runner cannot tell whether the screen answered' });
|
|
109
|
+
return { checks, suspects, canaries, elapsedMs: Date.now() - started };
|
|
110
|
+
}
|
|
111
|
+
for (const key of used.slice(0, 3)) { if (stopped()) break; if (await moved(() => tap(key, 200)) && await moved(() => tap(key, 200))) canaries.push(key); }
|
|
112
|
+
|
|
113
|
+
await run('rapid', async () => {
|
|
114
|
+
// Each key play used, in turn: the one that moves the player and the one that spends something are not the same key.
|
|
115
|
+
const list = [...new Set([...canaries, ...used])].slice(0, 3);
|
|
116
|
+
if (list.length === 0) return { skip: 'play pressed no key, so there is none to repeat' };
|
|
117
|
+
const what = `${list.join(', then ')} ${list.length === 1 ? 'was' : 'were each'} pressed ${timing.rapidPresses} times as fast as the game ticks`;
|
|
118
|
+
const once = async () => {
|
|
119
|
+
await errors();
|
|
120
|
+
const before = await text();
|
|
121
|
+
for (const key of list) for (let i = 0; i < timing.rapidPresses; i += 1) { await driver.sendKey(key, true, timing.rapidGapMs); await driver.sendKey(key, false, 0); }
|
|
122
|
+
await driver.runFor(timing.settleMs);
|
|
123
|
+
return judge(what, { before });
|
|
124
|
+
};
|
|
125
|
+
return { hits: await once(), what, again: async hit => (await once()).some(h => h.oracle === hit.oracle && h.key === hit.key) };
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
await run('opposite', async () => {
|
|
129
|
+
if (used.length === 0) return { skip: 'play pressed no key, so the game does not seem to be played by keys' };
|
|
130
|
+
const what = `opposite keys were held together (${OPPOSITES.map(p => p.join(' with ')).join(', ')})`;
|
|
131
|
+
const once = async () => { await errors(); const before = await text(); for (const [a, b] of OPPOSITES) { await driver.sendKey(a, true, 0); await driver.sendKey(b, true, timing.holdMs); await driver.sendKey(a, false, 0); await driver.sendKey(b, false, 0); } await driver.runFor(timing.settleMs); return judge(what, { before }); };
|
|
132
|
+
return { hits: await once(), what, again: async hit => (await once()).some(h => h.oracle === hit.oracle && h.key === hit.key) };
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
await run('edges', async () => {
|
|
136
|
+
if (used.length === 0) return { skip: 'play pressed no key, so there is no player to push to an edge' };
|
|
137
|
+
const what = 'the player was pushed to the edges of the play area';
|
|
138
|
+
const once = async () => {
|
|
139
|
+
await errors();
|
|
140
|
+
const before = await text();
|
|
141
|
+
for (const key of ['Left', 'Up', 'Right', 'Down']) {
|
|
142
|
+
if (stopped()) break;
|
|
143
|
+
let held = 0;
|
|
144
|
+
await driver.sendKey(key, true, 0);
|
|
145
|
+
while (held < timing.edgeMaxMs) { const still = !(await moved(() => driver.runFor(timing.edgeHoldMs))); held += timing.edgeHoldMs; if (still) break; }
|
|
146
|
+
await driver.sendKey(key, false, 0);
|
|
147
|
+
}
|
|
148
|
+
await driver.runFor(timing.settleMs);
|
|
149
|
+
return judge(what, { before });
|
|
150
|
+
};
|
|
151
|
+
return { hits: await once(), what, again: async hit => (await once()).some(h => h.oracle === hit.oracle && h.key === hit.key) };
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
await run('pause', async () => {
|
|
155
|
+
const layout = () => driver.rpc.call('edge_layout', {}).catch(() => null);
|
|
156
|
+
const start = await layout();
|
|
157
|
+
if (!start || typeof start.paused !== 'boolean') return { skip: 'the game does not say whether it is paused' };
|
|
158
|
+
let key = null;
|
|
159
|
+
for (const candidate of ['Escape', 'P']) { await tap(candidate, 100); const now = await layout(); if (now && now.paused) { key = candidate; break; } }
|
|
160
|
+
if (!key) return { skip: 'Escape and P did not pause the game, so no pause was found' };
|
|
161
|
+
const what = `the game was paused with ${key} and resumed with ${key}`;
|
|
162
|
+
const once = async first => {
|
|
163
|
+
await errors();
|
|
164
|
+
if (!first) await tap(key, 100);
|
|
165
|
+
await tap(key, 100);
|
|
166
|
+
const after = await layout();
|
|
167
|
+
const hits = await judge(what, { softLock: !(after && after.paused) });
|
|
168
|
+
if (after && after.paused) hits.push({ oracle: 'pause_stuck', severity: 'major', category: 'bug', title: `The game does not come back after a pause with ${key}`, description: `The game paused when ${key} was pressed and was still paused after ${key} was pressed again. If another input resumes it, the game does not say which.` });
|
|
169
|
+
return hits;
|
|
170
|
+
};
|
|
171
|
+
return { hits: await once(true), what, again: async hit => (await once(false)).some(h => h.oracle === hit.oracle && h.key === hit.key) };
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
for (const s of suspects) {
|
|
175
|
+
s.tries = 0; s.hits = 0; s.why = null;
|
|
176
|
+
if (['soft_lock', 'crash', 'blank', 'pause_stuck'].includes(s.oracle)) { s.why = 'the game was left stuck or had ended, so it can only be tried again from a fresh start'; continue; }
|
|
177
|
+
for (let i = 0; i < timing.retries && !stopped() && typeof s.again === 'function'; i += 1) { s.tries += 1; if (await Promise.resolve().then(() => s.again(s)).catch(() => false)) s.hits += 1; }
|
|
178
|
+
}
|
|
179
|
+
return { checks, suspects: suspects.map(({ again: _again, ...rest }) => rest), canaries, elapsedMs: Date.now() - started };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** The probes in words for report.md. */
|
|
183
|
+
export function godotProbesMarkdown(pass) {
|
|
184
|
+
if (!pass || !Array.isArray(pass.checks) || pass.checks.length === 0) return 'No probe ran.';
|
|
185
|
+
const words = { ok: 'tested, nothing went wrong in this check', problem: 'tested, PROBLEM', not_checked: 'not tested' };
|
|
186
|
+
const lines = GODOT_PROBES.map(([id, title]) => { const check = pass.checks.find(c => c.name === id); return check ? `- **${title}**: ${words[check.status] || check.status}. ${String(check.detail || '').replace(/\.?$/, '.')}` : `- **${title}**: not tested. The probes ended before it.`; });
|
|
187
|
+
lines.push(`- ${GODOT_NOT_PROBED}`, '', `A soft lock was ${pass.canaries && pass.canaries.length ? `watched for after each probe, with ${pass.canaries.join(', ')} (a key that moved the screen twice running)` : 'not watched for: no key play pressed moved the screen twice running'}. Each finding says how often it came back in the session; a probe is not run again from a fresh start on this driver. Not tested never means it works.`);
|
|
188
|
+
return lines.join('\n');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export { reproducedWords };
|
|
192
|
+
export default { runGodotTesterProbes, godotProbesMarkdown };
|