tools/mpremote: Make sure stdout and stderr output appear in order.

mpremote error messages now go to stderr, so make sure stdout is flushed
before printing them.

Also update the test runner to capture error messages.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2024-11-06 12:43:04 +11:00
parent 69023622ee
commit 76e6c6345c
2 changed files with 4 additions and 1 deletions

View File

@ -547,7 +547,10 @@ def main():
return 0
except CommandError as e:
# Make sure existing stdout appears before the error message on stderr.
sys.stdout.flush()
print(f"{_PROG}: {e}", file=sys.stderr)
sys.stderr.flush()
return 1
finally:
do_disconnect(state)

View File

@ -16,7 +16,7 @@ for t in $TESTS; do
TMP=$(mktemp -d)
echo -n "${t}: "
# Strip CR and replace the random temp dir with a token.
if env MPREMOTE=${MPREMOTE} TMP="${TMP}" "${t}" | tr -d '\r' | sed "s,${TMP},"'${TMP},g' > "${t}.out"; then
if env MPREMOTE=${MPREMOTE} TMP="${TMP}" "${t}" 2>&1 | tr -d '\r' | sed "s,${TMP},"'${TMP},g' > "${t}.out"; then
if diff "${t}.out" "${t}.exp" > /dev/null; then
echo "OK"
else