mobile-automator 0.37.0 → 0.38.1
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/package.json +2 -2
- package/src/cli.js +77 -16
- package/src/device/action-catalog.js +2 -1
- package/src/device/failure-probe.js +2 -0
- package/src/guide/content/execute.agnostic.md +2 -2
- package/src/guide/content/execute.aware.md +2 -2
- package/src/observe/failure-capture.js +3 -1
- package/src/output/envelope.js +10 -0
- package/src/result/flags.js +61 -1
- package/src/result/store.js +7 -9
- package/src/scenario/replayability.js +2 -2
- package/src/schemas/scenario_schema.json +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobile-automator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.1",
|
|
4
4
|
"description": "Host-agnostic mauto CLI for AI-driven mobile QA automation — analyzes a mobile project and drives devices through mobile-mcp.",
|
|
5
5
|
"homepage": "https://github.com/sh3lan93/mobile-automator#readme",
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"test:all": "jest"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@mobilenext/mobile-mcp": "1.0.
|
|
37
|
+
"@mobilenext/mobile-mcp": "1.0.15",
|
|
38
38
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
39
39
|
"ajv": "^8.20.0",
|
|
40
40
|
"commander": "^12.1.0"
|
package/src/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ const { ScenarioValidator } = require('./scenario/validator');
|
|
|
13
13
|
const { findReplayWarnings, summarize } = require('./scenario/replayability');
|
|
14
14
|
const { evaluate, MECHANICAL_TYPES } = require('./assertion/evaluator');
|
|
15
15
|
const { ResultStore } = require('./result/store');
|
|
16
|
-
const { OBSERVATION_TYPES, parseObservation, parseCapture, parseBool } = require('./result/flags');
|
|
16
|
+
const { OBSERVATION_TYPES, parseObservation, parseCapture, parseBool, parseRunStatus, parseStepStatus } = require('./result/flags');
|
|
17
17
|
const { MemoryStore } = require('./memory/store');
|
|
18
18
|
const { FILES: MEMORY_FILES, AGENT_KINDS } = require('./memory/paths');
|
|
19
19
|
const { validateEntryText, MAX_ENTRY_LEN } = require('./memory/entries');
|
|
@@ -566,8 +566,11 @@ async function handlePress({ deviceBridge }, button) {
|
|
|
566
566
|
}
|
|
567
567
|
|
|
568
568
|
// Build an assertion object from CLI flags, fetch the current element list,
|
|
569
|
-
// and run the pure evaluator. A
|
|
570
|
-
//
|
|
569
|
+
// and run the pure evaluator. A decided failure is a test outcome, not a tool
|
|
570
|
+
// fault: it exits 6 (`test_failed`, #273) so CI sees red without parsing JSON,
|
|
571
|
+
// with the verdict still in `data`. A pass and an undecided Tier-2 verdict
|
|
572
|
+
// (`needs_agent`) stay ok / exit 0. Only an unknown assertion type is a
|
|
573
|
+
// structural (invalid_input) error.
|
|
571
574
|
async function handleAssert({ deviceBridge }, type, flags = {}) {
|
|
572
575
|
if (!KNOWN_ASSERTION_TYPES.has(type)) {
|
|
573
576
|
return {
|
|
@@ -600,19 +603,24 @@ async function handleAssert({ deviceBridge }, type, flags = {}) {
|
|
|
600
603
|
`Record it: mauto result add-assertion --run-id <run_id> --step-id <step_id> ` +
|
|
601
604
|
`--type ${r.type} --pass ${verdict} --message "<why>"`;
|
|
602
605
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
needs_agent: r.needs_agent,
|
|
610
|
-
message: r.message,
|
|
611
|
-
},
|
|
612
|
-
hint
|
|
613
|
-
),
|
|
614
|
-
exitKind: 'ok',
|
|
606
|
+
const verdictData = {
|
|
607
|
+
type: r.type,
|
|
608
|
+
mechanical: r.mechanical,
|
|
609
|
+
pass: r.pass,
|
|
610
|
+
needs_agent: r.needs_agent,
|
|
611
|
+
message: r.message,
|
|
615
612
|
};
|
|
613
|
+
|
|
614
|
+
// Same data, same hint on both paths: an agent that reads `data` and copies
|
|
615
|
+
// the hint keeps working; only the exit code and `ok` change on a failure.
|
|
616
|
+
if (!r.needs_agent && r.pass === false) {
|
|
617
|
+
return {
|
|
618
|
+
envelope: fail('test_failed', `assertion failed: ${r.message}`, hint, verdictData),
|
|
619
|
+
exitKind: 'test_failed',
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
return { envelope: ok(verdictData, hint), exitKind: 'ok' };
|
|
616
624
|
}
|
|
617
625
|
|
|
618
626
|
// Collect a repeatable flag's values into an array (commander's collector).
|
|
@@ -627,6 +635,19 @@ function handleResultAddStep({ resultStoreFactory, projectRoot }, opts) {
|
|
|
627
635
|
};
|
|
628
636
|
}
|
|
629
637
|
|
|
638
|
+
// The status flag is a schema enum, not free text: an unknown value used to
|
|
639
|
+
// be silently recorded as 'error' — a mislabelled step with a green exit —
|
|
640
|
+
// because 'error' was the catch-all of the normalizer rather than an explicit
|
|
641
|
+
// acceptance (#286 review). Same all-or-nothing rule as the composite flags
|
|
642
|
+
// below: reject BEFORE the store is touched, so nothing is half-recorded.
|
|
643
|
+
const parsedStatus = parseStepStatus(status);
|
|
644
|
+
if (parsedStatus.error) {
|
|
645
|
+
return {
|
|
646
|
+
envelope: fail('invalid_input', parsedStatus.error, 'Valid values: pass | fail | skipped | error.'),
|
|
647
|
+
exitKind: 'invalid_input',
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
|
|
630
651
|
// Parse every composite flag BEFORE touching the store: a half-recorded step
|
|
631
652
|
// (screenshot persisted, observation rejected) leaves the agent unable to
|
|
632
653
|
// tell which half landed, so validation is all-or-nothing.
|
|
@@ -657,7 +678,9 @@ function handleResultAddStep({ resultStoreFactory, projectRoot }, opts) {
|
|
|
657
678
|
const store = resultStoreFactory({ runId, scenarioId, projectRoot });
|
|
658
679
|
const step = store.addStep({
|
|
659
680
|
step_id: stepId,
|
|
660
|
-
status,
|
|
681
|
+
// The VALIDATED status: validated AND normalized at the boundary, so the
|
|
682
|
+
// store only ever records schema values.
|
|
683
|
+
status: parsedStatus.value,
|
|
661
684
|
attempts: attempts === undefined ? 1 : Number(attempts),
|
|
662
685
|
screenshot: screenshot === undefined ? null : screenshot,
|
|
663
686
|
error_message: errorMessage === undefined ? null : errorMessage,
|
|
@@ -801,6 +824,26 @@ function handleResultFinalize({ resultStoreFactory, memoryStoreFactory, projectR
|
|
|
801
824
|
};
|
|
802
825
|
}
|
|
803
826
|
|
|
827
|
+
// The status flag is a schema enum, not free text: an unlisted value (a case
|
|
828
|
+
// variant of a documented word, a typo) used to be persisted verbatim — a
|
|
829
|
+
// schema-invalid result file with ok:true and exit 0 — directly under the
|
|
830
|
+
// exit-6 contract keyed on that status (#286 review). Reject before anything
|
|
831
|
+
// is written. A provided-but-empty value is NOT an omitted one: only absence
|
|
832
|
+
// derives the status from the recorded assertions.
|
|
833
|
+
if (status !== undefined) {
|
|
834
|
+
const parsed = parseRunStatus(status);
|
|
835
|
+
if (parsed.error) {
|
|
836
|
+
return {
|
|
837
|
+
envelope: fail(
|
|
838
|
+
'invalid_input',
|
|
839
|
+
parsed.error,
|
|
840
|
+
'Valid values: passed | failed | error, or omit --status to derive it from the recorded assertions.'
|
|
841
|
+
),
|
|
842
|
+
exitKind: 'invalid_input',
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
|
|
804
847
|
// Only provided keys: `defaultMetadata` fills the rest with 'unknown', and
|
|
805
848
|
// the result schema requires all five fields to be strings, so threading
|
|
806
849
|
// `undefined` through would break conformance.
|
|
@@ -854,6 +897,24 @@ function handleResultFinalize({ resultStoreFactory, memoryStoreFactory, projectR
|
|
|
854
897
|
if (memHint) hints.push(memHint);
|
|
855
898
|
}
|
|
856
899
|
|
|
900
|
+
// The exit code is keyed on the FINALIZED status, not the --status flag:
|
|
901
|
+
// with the flag omitted, the store derives 'failed' from a failed assertion,
|
|
902
|
+
// and the exit code must agree with the file either way (#273). 'error' takes
|
|
903
|
+
// the same path — a run that errored is not a pass for CI either; data.status
|
|
904
|
+
// tells the two apart. Everything above (write, retention, harvest) has
|
|
905
|
+
// already run: exit 6 is a verdict about the app, not a reason to lose the
|
|
906
|
+
// record of it.
|
|
907
|
+
if (result.status === 'failed' || result.status === 'error') {
|
|
908
|
+
const hint = hints.length
|
|
909
|
+
? hints.join(' ')
|
|
910
|
+
: 'See data.steps_executed and data.assertion_results for what failed; ' +
|
|
911
|
+
`the result is saved to ${path.relative(projectRoot, store.file)}.`;
|
|
912
|
+
return {
|
|
913
|
+
envelope: fail('test_failed', `run ${runId} ${result.status}`, hint, result),
|
|
914
|
+
exitKind: 'test_failed',
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
|
|
857
918
|
return { envelope: ok(result, hints.length ? hints.join(' ') : null), exitKind: 'ok' };
|
|
858
919
|
}
|
|
859
920
|
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
// 'composed' — no dedicated verb; the agent composes it from existing verbs
|
|
19
19
|
// (e.g. poll `mauto elements`, repeat `mauto swipe`). The
|
|
20
20
|
// execute guide documents the composition.
|
|
21
|
-
// 'unsupported' —
|
|
21
|
+
// 'unsupported' — no `mauto` verb reaches it: the engine has no primitive, or
|
|
22
|
+
// (clear_app_data, since 1.0.15) mauto has not wired it. Not
|
|
22
23
|
// mechanically executable; the guide must NOT promise a verb,
|
|
23
24
|
// and the agent reports it honestly / handles it manually.
|
|
24
25
|
//
|
|
@@ -86,6 +86,8 @@ const PROBE_EXEMPT_VERBS = new Set(['devices', 'crash']);
|
|
|
86
86
|
// Failure kinds that can plausibly mean "the app died". invalid_input is a bad
|
|
87
87
|
// flag, target_not_found/environment/internal never reached (or never
|
|
88
88
|
// involved) the device — none of them are worth a device round trip.
|
|
89
|
+
// test_failed/incomplete are outcomes: the device answered and the app failed;
|
|
90
|
+
// the evidence is the step screenshot, not a crash list.
|
|
89
91
|
const PROBE_KINDS = new Set(['device', 'timeout']);
|
|
90
92
|
|
|
91
93
|
function shouldProbe({ envelope, verb } = {}) {
|
|
@@ -176,7 +176,7 @@ switch the engine mid-run yourself.
|
|
|
176
176
|
|
|
177
177
|
For each assertion, pick the type recorded in the scenario and evaluate it. The 27 types split into two tiers by **who decides pass/fail**:
|
|
178
178
|
|
|
179
|
-
- **Tier 1 — mechanical (the CLI decides).** Deterministic checks over the on-screen element list (plus captured variables / a previous snapshot). Run `mauto elements`, then evaluate with `mauto assert <type> ...`; the CLI returns a JSON verdict (`{ mechanical: true, pass: true|false, message }`). You record that verdict — you do not re-judge it.
|
|
179
|
+
- **Tier 1 — mechanical (the CLI decides).** Deterministic checks over the on-screen element list (plus captured variables / a previous snapshot). Run `mauto elements`, then evaluate with `mauto assert <type> ...`; the CLI returns a JSON verdict (`{ mechanical: true, pass: true|false, message }`). A passing verdict arrives as a normal `ok: true` envelope. A failing one arrives as `ok: false` with `error.kind: "test_failed"` and exit code `6`, and the verdict (`pass: false`) is still in `data`. That is the test result, not a tool error: do not retry the verb or treat the run as broken. You record that verdict — you do not re-judge it.
|
|
180
180
|
- **Tier 2 — visual / semantic (the agent decides).** These require judging pixels. `mauto assert <type> ...` reports them as `needs_agent` (with `pass: null`). For these you take a screenshot with `mauto screenshot <path>`, visually analyze it, and report pass/fail yourself with a clear justification.
|
|
181
181
|
|
|
182
182
|
> One assertion type, `element_state`, names a Tier-1 intent but its per-attribute state inspection is not represented in the element model the CLI reads, so `mauto assert` returns it as `needs_agent` — judge it from the element list / screenshot like a Tier-2 check.
|
|
@@ -210,7 +210,7 @@ For each: take a screenshot, visually analyze it, and report pass/fail with a cl
|
|
|
210
210
|
|
|
211
211
|
### 5. Generate the Result Report
|
|
212
212
|
|
|
213
|
-
Obtain the result schema by running `mauto schema result`, then finalize the run with `mauto result finalize` (writing to `.mobile-automator/results/<run_id>.json`), passing the run metadata you already know (`--device-model`, `--api-level`, `--app-version`, `--environment`) — the timestamp is filled in for you, and omitted fields are recorded as `unknown`. You may supply your own narrative with `--summary <text>`; omitting it keeps the generated default summary line. The finalized result assembles what the earlier `add-step`/`add-assertion` calls already recorded:
|
|
213
|
+
Obtain the result schema by running `mauto schema result`, then finalize the run with `mauto result finalize` (writing to `.mobile-automator/results/<run_id>.json`), passing the run metadata you already know (`--device-model`, `--api-level`, `--app-version`, `--environment`) — the timestamp is filled in for you, and omitted fields are recorded as `unknown`. You may supply your own narrative with `--summary <text>`; omitting it keeps the generated default summary line. A run that finalizes as `failed` or `error` returns `ok: false` with `error.kind: "test_failed"` and exit code `6`. The result file is still written and the full result is in `data`, so present it as usual; the non-zero exit is what lets CI see a red run. The finalized result assembles what the earlier `add-step`/`add-assertion` calls already recorded:
|
|
214
214
|
|
|
215
215
|
- `run_id`, `scenario_id`, `status`, `duration_seconds`.
|
|
216
216
|
- `steps_executed[]`: per-step status, retry_count, screenshot, error_message.
|
|
@@ -226,7 +226,7 @@ setting. Do not switch the engine mid-run yourself.
|
|
|
226
226
|
|
|
227
227
|
For each assertion in the scenario (evaluated after the referenced step), pick the type recorded in the scenario and evaluate it. The 27 types split into two tiers by **who decides pass/fail**:
|
|
228
228
|
|
|
229
|
-
- **Tier 1 — mechanical (the CLI decides).** These are deterministic checks over the on-screen element list (plus captured variables / a previous snapshot). Run `mauto elements` to get the current screen, then evaluate the assertion with `mauto assert <type> ...`; the CLI returns a JSON verdict (`{ mechanical: true, pass: true|false, message }`). You record that verdict — you do not re-judge it.
|
|
229
|
+
- **Tier 1 — mechanical (the CLI decides).** These are deterministic checks over the on-screen element list (plus captured variables / a previous snapshot). Run `mauto elements` to get the current screen, then evaluate the assertion with `mauto assert <type> ...`; the CLI returns a JSON verdict (`{ mechanical: true, pass: true|false, message }`). A passing verdict arrives as a normal `ok: true` envelope. A failing one arrives as `ok: false` with `error.kind: "test_failed"` and exit code `6`, and the verdict (`pass: false`) is still in `data`. That is the test result, not a tool error: do not retry the verb or treat the run as broken. You record that verdict — you do not re-judge it.
|
|
230
230
|
- **Tier 2 — visual / semantic (the agent decides).** These require judging pixels. `mauto assert <type> ...` reports them as `needs_agent` (with `pass: null`) because the CLI cannot decide them. For these you take a screenshot with `mauto screenshot <path>`, visually analyze it, and report pass/fail yourself with a clear justification of what you observed.
|
|
231
231
|
|
|
232
232
|
> One assertion type, `element_state`, names a Tier-1 intent but its per-attribute state inspection is not represented in the element model the CLI reads, so `mauto assert` returns it as `needs_agent` — judge it from the element list / screenshot like a Tier-2 check.
|
|
@@ -276,7 +276,7 @@ For all Tier 2 assertions: take a screenshot, visually analyze it, and report pa
|
|
|
276
276
|
|
|
277
277
|
### 6. Generate the Result Report
|
|
278
278
|
|
|
279
|
-
Obtain the result schema by running `mauto schema result`, then finalize the run with `mauto result finalize` (writing to `.mobile-automator/results/<run_id>.json`), passing the run metadata you already know (`--device-model`, `--api-level`, `--app-version`, `--environment`) — the timestamp is filled in for you, and omitted fields are recorded as `unknown`. You may supply your own narrative with `--summary <text>`; omitting it keeps the generated default summary line. The result carries typed `observations` (`regression`, `flakiness`, `state_context`) gathered by the Observer traits above. `--duration` is now a cross-check rather than the recorded value: when a run trace exists the duration is measured from it, your figure is kept as `measurements.reported_duration_seconds`, and a disagreement beyond the tolerance is recorded as a `state_context` observation. Report the duration you believe is right and let the two be compared; do not reverse-engineer a number to match.
|
|
279
|
+
Obtain the result schema by running `mauto schema result`, then finalize the run with `mauto result finalize` (writing to `.mobile-automator/results/<run_id>.json`), passing the run metadata you already know (`--device-model`, `--api-level`, `--app-version`, `--environment`) — the timestamp is filled in for you, and omitted fields are recorded as `unknown`. You may supply your own narrative with `--summary <text>`; omitting it keeps the generated default summary line. The result carries typed `observations` (`regression`, `flakiness`, `state_context`) gathered by the Observer traits above. `--duration` is now a cross-check rather than the recorded value: when a run trace exists the duration is measured from it, your figure is kept as `measurements.reported_duration_seconds`, and a disagreement beyond the tolerance is recorded as a `state_context` observation. Report the duration you believe is right and let the two be compared; do not reverse-engineer a number to match. A run that finalizes as `failed` or `error` returns `ok: false` with `error.kind: "test_failed"` and exit code `6`. The result file is still written and the full result is in `data`, so present it as usual; the non-zero exit is what lets CI see a red run.
|
|
280
280
|
|
|
281
281
|
### 7. Present the Summary
|
|
282
282
|
|
|
@@ -41,7 +41,9 @@ const { runTracePath } = require('./paths');
|
|
|
41
41
|
// `invalid_input` is excluded: nothing reached the device, so the picture would
|
|
42
42
|
// show the state BEFORE the verb and be evidence of nothing. `internal` is
|
|
43
43
|
// excluded for the same reason, and because a crashed CLI has a stack trace,
|
|
44
|
-
// which is the artifact that actually helps.
|
|
44
|
+
// which is the artifact that actually helps. `test_failed` / `incomplete` are
|
|
45
|
+
// excluded too: the device answered and the app failed, and the evidence is the
|
|
46
|
+
// step's own screenshot — a second capture would only duplicate it.
|
|
45
47
|
const CAPTURED_KINDS = new Set(['device', 'timeout']);
|
|
46
48
|
|
|
47
49
|
function isCapturable(result) {
|
package/src/output/envelope.js
CHANGED
|
@@ -14,6 +14,14 @@ const EXIT = {
|
|
|
14
14
|
// disk) — an environment fault the caller can fix, distinct from exit 1
|
|
15
15
|
// ("the CLI itself broke"). Kept separate so agents/CI can branch on it.
|
|
16
16
|
ENVIRONMENT: 5,
|
|
17
|
+
// Test outcomes, not faults: the device and the tooling worked, and the app
|
|
18
|
+
// under test failed. Distinct from 1-5 so CI can tell "the app is broken"
|
|
19
|
+
// from "the tooling is broken" by exit code alone, without parsing JSON.
|
|
20
|
+
TEST_FAILED: 6,
|
|
21
|
+
// Reserved for replay (`mauto run`, and `result finalize` once it computes
|
|
22
|
+
// it): the run is not decided yet because something still needs agent
|
|
23
|
+
// judgment. Nothing produces it yet.
|
|
24
|
+
INCOMPLETE: 7,
|
|
17
25
|
CANCEL: 130,
|
|
18
26
|
};
|
|
19
27
|
|
|
@@ -29,6 +37,8 @@ const KIND_TO_CODE = {
|
|
|
29
37
|
invalid_input: EXIT.INVALID_INPUT,
|
|
30
38
|
target_not_found: EXIT.TARGET_NOT_FOUND,
|
|
31
39
|
environment: EXIT.ENVIRONMENT,
|
|
40
|
+
test_failed: EXIT.TEST_FAILED,
|
|
41
|
+
incomplete: EXIT.INCOMPLETE,
|
|
32
42
|
cancel: EXIT.CANCEL,
|
|
33
43
|
internal: 1,
|
|
34
44
|
// `init --agent all` partial failure: some hosts wired, some failed. Non-zero
|
package/src/result/flags.js
CHANGED
|
@@ -43,10 +43,70 @@ function parseCapture(spec) {
|
|
|
43
43
|
return { value: { name, value } };
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
// Mirrors the enum at /properties/steps_executed/items/properties/status in
|
|
47
|
+
// src/schemas/result_schema.json; tests/lint/result-coverage.test.js asserts
|
|
48
|
+
// the mapping's outputs never drift from that enum (every accepted spelling
|
|
49
|
+
// lands on a schema value, every schema value is reachable). The CLI accepts
|
|
50
|
+
// the friendly spellings an agent types (pass/fail/skip) alongside the
|
|
51
|
+
// schema's own values; anything else is rejected instead of being silently
|
|
52
|
+
// recorded as 'error' (#286 review).
|
|
53
|
+
const STEP_STATUS_ALIASES = {
|
|
54
|
+
pass: 'passed',
|
|
55
|
+
passed: 'passed',
|
|
56
|
+
fail: 'failed',
|
|
57
|
+
failed: 'failed',
|
|
58
|
+
skipped: 'skipped',
|
|
59
|
+
skip: 'skipped',
|
|
60
|
+
error: 'error',
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// The throwing form, for the store: addStep's input is already validated at
|
|
64
|
+
// the CLI boundary (parseStepStatus), so reaching this with an unknown value
|
|
65
|
+
// means a CLI bug — it escapes as `internal` (exit 1), never as a
|
|
66
|
+
// mislabelled-but-green step.
|
|
67
|
+
function stepStatus(raw) {
|
|
68
|
+
const normalized = STEP_STATUS_ALIASES[raw];
|
|
69
|
+
if (!normalized) throw new Error(`unknown step status "${raw}"`);
|
|
70
|
+
return normalized;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function parseStepStatus(raw) {
|
|
74
|
+
const normalized = STEP_STATUS_ALIASES[raw];
|
|
75
|
+
if (!normalized) {
|
|
76
|
+
return { error: `unknown --status "${raw}" (expected pass | fail | skipped | error)` };
|
|
77
|
+
}
|
|
78
|
+
return { value: normalized };
|
|
79
|
+
}
|
|
80
|
+
|
|
46
81
|
function parseBool(raw, flagName) {
|
|
47
82
|
if (raw === 'true') return { value: true };
|
|
48
83
|
if (raw === 'false') return { value: false };
|
|
49
84
|
return { error: `${flagName} must be "true" or "false" (got "${raw}")` };
|
|
50
85
|
}
|
|
51
86
|
|
|
52
|
-
|
|
87
|
+
// Mirrors the enum at /properties/status in src/schemas/result_schema.json;
|
|
88
|
+
// tests/lint/result-coverage.test.js asserts the two never drift. `result
|
|
89
|
+
// finalize --status` must be one of these or omitted (omission derives the
|
|
90
|
+
// status from the recorded assertions): an unlisted value used to be persisted
|
|
91
|
+
// verbatim — a schema-invalid result file with a green exit — directly under
|
|
92
|
+
// the exit-6 contract keyed on that status (#286 review).
|
|
93
|
+
const RUN_STATUSES = ['passed', 'failed', 'error'];
|
|
94
|
+
|
|
95
|
+
function parseRunStatus(raw) {
|
|
96
|
+
if (!RUN_STATUSES.includes(raw)) {
|
|
97
|
+
return { error: `unknown --status "${raw}" (expected ${RUN_STATUSES.join(' | ')})` };
|
|
98
|
+
}
|
|
99
|
+
return { value: raw };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
module.exports = {
|
|
103
|
+
OBSERVATION_TYPES,
|
|
104
|
+
parseObservation,
|
|
105
|
+
parseCapture,
|
|
106
|
+
parseBool,
|
|
107
|
+
RUN_STATUSES,
|
|
108
|
+
parseRunStatus,
|
|
109
|
+
STEP_STATUS_ALIASES,
|
|
110
|
+
stepStatus,
|
|
111
|
+
parseStepStatus,
|
|
112
|
+
};
|
package/src/result/store.js
CHANGED
|
@@ -5,7 +5,7 @@ const path = require('path');
|
|
|
5
5
|
|
|
6
6
|
const { atomicWrite } = require('../util/atomic');
|
|
7
7
|
const { withLock } = require('../util/lock');
|
|
8
|
-
const { OBSERVATION_TYPES } = require('./flags');
|
|
8
|
+
const { OBSERVATION_TYPES, stepStatus } = require('./flags');
|
|
9
9
|
const { workspaceDir } = require('../workspace/layout');
|
|
10
10
|
|
|
11
11
|
// Incremental result accumulator that persists to
|
|
@@ -33,14 +33,6 @@ function defaultMetadata(overrides = {}) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
// Normalize the caller-friendly status ('pass'/'fail') to the schema enums.
|
|
37
|
-
function stepStatus(status) {
|
|
38
|
-
if (status === 'pass' || status === 'passed') return 'passed';
|
|
39
|
-
if (status === 'fail' || status === 'failed') return 'failed';
|
|
40
|
-
if (status === 'skipped' || status === 'skip') return 'skipped';
|
|
41
|
-
return 'error';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
36
|
function assertionStatus(pass) {
|
|
45
37
|
return pass ? 'passed' : 'failed';
|
|
46
38
|
}
|
|
@@ -70,6 +62,12 @@ class ResultStore {
|
|
|
70
62
|
this._refreshFromDisk();
|
|
71
63
|
}
|
|
72
64
|
|
|
65
|
+
// The result file this store reads and writes. Read-only: the store owns the
|
|
66
|
+
// location, so callers name the file through it rather than rebuilding it.
|
|
67
|
+
get file() {
|
|
68
|
+
return this._file;
|
|
69
|
+
}
|
|
70
|
+
|
|
73
71
|
// Re-load the on-disk accumulator and refresh the in-memory fields. The
|
|
74
72
|
// constructor eager-loads once (read-only paths and back-compat), but every
|
|
75
73
|
// persisting mutator re-runs this UNDER the per-runId lock so it operates on
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// scenario will do on replay; this module reports two kinds of gap:
|
|
5
5
|
//
|
|
6
6
|
// - `unsupported_action` (#166): the schema accepts every action in its enum,
|
|
7
|
-
// but the action catalog marks some `unsupported`.
|
|
8
|
-
//
|
|
7
|
+
// but the action catalog marks some `unsupported`. no `mauto` verb reaches
|
|
8
|
+
// them, whether or not the engine has a primitive, so the step can never
|
|
9
9
|
// replay unattended. Blocking: `mauto validate --strict` fails on it.
|
|
10
10
|
// - `launch_cold_implicit` (#255): a catalog `stepFlags` entry marked
|
|
11
11
|
// `warnWhenUnset`. A step after the first that leaves the marked field to its
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"disable_wifi",
|
|
141
141
|
"set_orientation"
|
|
142
142
|
],
|
|
143
|
-
"description": "The setup action to perform. enable_wifi, disable_wifi and clear_app_data are accepted by the schema but are not mechanically executable (no
|
|
143
|
+
"description": "The setup action to perform. enable_wifi, disable_wifi and clear_app_data are accepted by the schema but are not mechanically executable (no mauto verb runs them), so they cannot replay unattended; mauto validate warns."
|
|
144
144
|
},
|
|
145
145
|
"target_package": {
|
|
146
146
|
"type": "string",
|
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
"grant_permission",
|
|
248
248
|
"deny_permission"
|
|
249
249
|
],
|
|
250
|
-
"description": "The automation action to perform. Supported types: wait_for_element, wait_for_element_gone, wait_for_loading_complete, capture_value, long_press, double_tap, scroll_to_element, press_back, dismiss_keyboard, grant_permission, deny_permission. clear_app_data is accepted by the schema but is not mechanically executable:
|
|
250
|
+
"description": "The automation action to perform. Supported types: wait_for_element, wait_for_element_gone, wait_for_loading_complete, capture_value, long_press, double_tap, scroll_to_element, press_back, dismiss_keyboard, grant_permission, deny_permission. clear_app_data is accepted by the schema but is not mechanically executable: no mauto verb runs it, so it cannot replay unattended (mauto validate warns)."
|
|
251
251
|
},
|
|
252
252
|
"description": {
|
|
253
253
|
"type": "string",
|