Skip to content

Commit 1d31bd0

Browse files
committed
tests: Address Copilot review on PR #100.
1 parent ae3ae01 commit 1d31bd0

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

tests/runner/mpremote_bridge.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ def _run(self, code, mount_dir=None):
4949

5050
result = subprocess.run(cmd, capture_output=True, text=True, timeout=30, check=False)
5151
if result.returncode != 0:
52-
detail = result.stderr.strip() or result.stdout.strip()
52+
stderr = result.stderr.strip()
53+
stdout = result.stdout.strip()
54+
parts = [p for p in (stderr, stdout) if p]
55+
detail = "\n".join(parts) or "(no output)"
5356
raise RuntimeError(f"mpremote failed: {detail}")
5457
# mpremote mount adds "Local directory ... is mounted at /remote"
5558
# to stdout; filter it out and keep only the script output
@@ -161,7 +164,13 @@ def run_raw_script(self, script, mount_dir=None):
161164
for line in lines[:-1]:
162165
print(line)
163166
last_line = lines[-1] if lines else ""
164-
return json.loads(last_line)
167+
try:
168+
return json.loads(last_line)
169+
except json.JSONDecodeError:
170+
full = "\n".join(lines)
171+
raise RuntimeError(
172+
f"Script did not produce valid JSON result.\nFull output:\n{full}"
173+
)
165174

166175
def scan_bus(self, i2c_config):
167176
"""Scan I2C bus and return list of addresses."""

tests/scenarios/board_temperature_comparison.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ tests:
5858
pad = ' ' * (12 - len(name))
5959
print(' ' + name + pad + ': ' + str(round(t, 2)) + ' C')
6060
61-
# Check dedicated thermometers in plausible range
62-
dedicated = [temps['HTS221'], temps['WSEN-HIDS'], temps['WSEN-PADS']]
63-
all_ok = all(5.0 <= t <= 50.0 for t in dedicated)
61+
# Check thermometers in plausible range (HTS221, WSEN-HIDS, WSEN-PADS)
62+
thermometers = [temps['HTS221'], temps['WSEN-HIDS'], temps['WSEN-PADS']]
63+
all_ok = all(5.0 <= t <= 50.0 for t in thermometers)
6464
65-
# Check spread between dedicated thermometers
66-
spread = max(dedicated) - min(dedicated)
67-
print(' Spread (dedicated): ' + str(round(spread, 2)) + ' C')
65+
# Check spread between thermometers
66+
spread = max(thermometers) - min(thermometers)
67+
print(' Spread: ' + str(round(spread, 2)) + ' C')
6868
6969
result = all_ok and spread < 8.0
7070
expect_true: true
@@ -102,6 +102,6 @@ tests:
102102

103103
- name: "Temperature values feel correct"
104104
action: manual
105-
prompt: "Les temperatures lues sont-elles coherentes entre elles et avec l'ambiance ?"
105+
prompt: "Les températures lues sont-elles cohérentes entre elles et avec l'ambiance ?"
106106
expect_true: true
107107
mode: [hardware]

0 commit comments

Comments
 (0)