Skip to content

Commit 76e6c63

Browse files
committed
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 <[email protected]>
1 parent 6902362 commit 76e6c63

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

tools/mpremote/mpremote/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,10 @@ def main():
547547

548548
return 0
549549
except CommandError as e:
550+
# Make sure existing stdout appears before the error message on stderr.
551+
sys.stdout.flush()
550552
print(f"{_PROG}: {e}", file=sys.stderr)
553+
sys.stderr.flush()
551554
return 1
552555
finally:
553556
do_disconnect(state)

tools/mpremote/tests/run-mpremote-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ for t in $TESTS; do
1616
TMP=$(mktemp -d)
1717
echo -n "${t}: "
1818
# Strip CR and replace the random temp dir with a token.
19-
if env MPREMOTE=${MPREMOTE} TMP="${TMP}" "${t}" | tr -d '\r' | sed "s,${TMP},"'${TMP},g' > "${t}.out"; then
19+
if env MPREMOTE=${MPREMOTE} TMP="${TMP}" "${t}" 2>&1 | tr -d '\r' | sed "s,${TMP},"'${TMP},g' > "${t}.out"; then
2020
if diff "${t}.out" "${t}.exp" > /dev/null; then
2121
echo "OK"
2222
else

0 commit comments

Comments
 (0)