read_until:
- 'expected' now accepts a list of values (succeeds on any match).
- new 'regex: true' flag: each pattern is a Python regex (re.search over a
bounded tail, Console.REGEX_WINDOW). Reports which pattern matched.
Serial console robustness & clarity:
- failed open() raises a clear ETUMRuntimeError ("Serial device '…' does not
exist." / permission hint) instead of a raw pyserial traceback.
- a console whose open failed is safely "not open" (init _thd=None +
isOpened guards in readchar/read_nowait/close) — no more cascading
AttributeError: '_thd' on subsequent read steps.
- action handlers: one-liner for expected (ETUMRuntimeError) errors, full
traceback kept for unexpected ones. All console errors use testium
exceptions (ETUMRuntimeError).
Flatpak: grant --device=all so serial adapters (/dev/ttyUSB*, /dev/ttyACM*)
are visible in the sandbox.
Validation: new read_until list/regex (match + no-match) cases in
items/console/test.tum.
Version: 0.3.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
155 lines
4.4 KiB
Plaintext
155 lines
4.4 KiB
Plaintext
|
|
- console:
|
|
name: Console creation
|
|
console_name: term
|
|
doc: Opening the console
|
|
key: $(test)_PASS
|
|
steps:
|
|
- open:
|
|
protocol: terminal
|
|
terminal_path: $(test_directory)
|
|
{% if os == "Linux" %}
|
|
- writeln: echo "endOfOpen"
|
|
{% endif %}
|
|
|
|
- console:
|
|
name: Console read_until with timeout
|
|
console_name: term
|
|
key: $(test)_PASS
|
|
steps:
|
|
{% if os == "Linux" %}
|
|
- read_until: {expected: endOfOpen, timeout: 5}
|
|
{% else %}
|
|
- read_until: {expected: $(terminal_prompt), timeout: 5}
|
|
{% endif %}
|
|
|
|
- console:
|
|
name: Console write
|
|
console_name: term
|
|
key: $(test)_PASS
|
|
steps:
|
|
- writeln: echo 0
|
|
|
|
- sleep:
|
|
name: sleep item
|
|
timeout: 1
|
|
|
|
- console:
|
|
name: Console read_until immediate
|
|
console_name: term
|
|
key: $(test)_PASS
|
|
steps:
|
|
{% if os == "Windows" %}
|
|
- read_until: {expected: "echo 0", timeout: 0}
|
|
{% endif %}
|
|
- read_until: {expected: "0", timeout: 0}
|
|
|
|
- console:
|
|
name: Console write
|
|
console_name: term
|
|
key: $(test)_PASS
|
|
steps:
|
|
- writeln: echo "HelloConsole"
|
|
|
|
- console:
|
|
name: Console read_until fail
|
|
console_name: term
|
|
key: $(test)_FAIL
|
|
steps:
|
|
- read_until: {expected: "Something never prints", timeout: 1}
|
|
|
|
- console:
|
|
name: Console write
|
|
console_name: term
|
|
key: $(test)_PASS
|
|
steps:
|
|
- writeln: echo "HelloConsole"
|
|
|
|
- console:
|
|
name: Console read_until no_fail
|
|
console_name: term
|
|
key: $(test)_PASS
|
|
steps:
|
|
- read_until: {expected: Something never prints, timeout: 1, no_fail: true}
|
|
|
|
- console:
|
|
name: Console read_until muted
|
|
console_name: term
|
|
key: $(test)_PASS
|
|
steps:
|
|
- writeln: echo "HelloConsole"
|
|
{% if os == "Windows" %}
|
|
- read_until: {expected: echo "HelloConsole", timeout: 1, mute: true}
|
|
{% endif %}
|
|
- read_until: {expected: HelloConsole, timeout: 1, mute: true}
|
|
|
|
- console:
|
|
name: Console read_until muted
|
|
console_name: term
|
|
key: $(test)_PASS
|
|
steps:
|
|
- writeln: echo "HelloConsole is PASS" && echo "endOfCmd"
|
|
{% if os == "Windows" %}
|
|
- read_until: {expected: echo "endOfCmd", timeout: 1}
|
|
{% endif %}
|
|
- read_until: {expected: endOfCmd, timeout: 1, process_result: "'Hello' in r'''$(result)''' and 'PASS' in r'''$(result)''' "}
|
|
|
|
{% if os == "Linux" %}
|
|
- console:
|
|
name: Console runs on host (not the Flatpak sandbox)
|
|
doc: Regression guard for the 0.2.1 Flatpak bug (term console spawned inside the sandbox instead of on the host). /.flatpak-info exists only inside the sandbox, so the host-only marker is emitted (and matched by read_until) ONLY when the shell really runs on the host. On a broken Flatpak the marker never appears, read_until times out and the item FAILS. The marker is built at runtime ($M) so it is never present in the command line itself. Passes on every other channel.
|
|
console_name: term
|
|
key: $(test)_PASS
|
|
steps:
|
|
- writeln: 'test -e /.flatpak-info && M=SANDBOX || M=HOST; echo "console_host_check_$M"'
|
|
- read_until: {expected: console_host_check_HOST, timeout: 5}
|
|
{% endif %}
|
|
|
|
# --- read_until matching a list of values (succeeds on any) ---
|
|
- console:
|
|
name: Console read_until list match any
|
|
console_name: term
|
|
key: $(test)_PASS
|
|
steps:
|
|
- writeln: echo "list_marker_B"
|
|
- read_until: {expected: [list_marker_A, list_marker_B, list_marker_C], timeout: 5}
|
|
|
|
- console:
|
|
name: Console read_until list no match
|
|
console_name: term
|
|
key: $(test)_FAIL
|
|
steps:
|
|
- read_until: {expected: [never_marker_A, never_marker_B], timeout: 1}
|
|
|
|
# --- read_until with regular expressions ---
|
|
- console:
|
|
name: Console read_until regex
|
|
console_name: term
|
|
key: $(test)_PASS
|
|
steps:
|
|
- writeln: echo "regex_val_4242_end"
|
|
- read_until: {expected: 'regex_val_\d+_end', regex: true, timeout: 5}
|
|
|
|
- console:
|
|
name: Console read_until regex list any
|
|
console_name: term
|
|
key: $(test)_PASS
|
|
steps:
|
|
- writeln: echo "STATUS=ready"
|
|
- read_until: {expected: ['ERR:.*', 'STATUS=(ready|busy)'], regex: true, timeout: 5}
|
|
|
|
- console:
|
|
name: Console read_until regex no match
|
|
console_name: term
|
|
key: $(test)_FAIL
|
|
steps:
|
|
- read_until: {expected: 'never_\d{4}', regex: true, timeout: 1}
|
|
|
|
- console:
|
|
name: Console closure
|
|
execute_on_stop: true
|
|
console_name: term
|
|
key: $(test)_PASS
|
|
steps:
|
|
- close: term
|