Skip to content

Commit aaea140

Browse files
committed
mpremote/tests: Rewrite test runner.
This rewrite fixes quoting issues preventing the script from running under windows bash, and modifies its behavior to produce output more in line with the test runner used for the main micropython test suite. Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
1 parent f89c863 commit aaea140

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ docs/genrst/
1515
tests/results/*
1616
tests/ports/unix/ffi_lib.so
1717

18+
# Test failure outputs for mpremote
19+
tools/mpremote/tests/results/*
20+
1821
# Python cache files
1922
__pycache__/
2023

tools/mpremote/tests/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,45 @@
11
#!/bin/bash
22
set -e
33

4-
TEST_DIR="${TEST_DIR:-$(dirname $0)}"
5-
MPREMOTE="${MPREMOTE:-${TEST_DIR}/../mpremote.py}"
4+
TESTS_DIR="${TESTS_DIR:-$(dirname $0)}"
5+
RESULT_DIR="${RESULT_DIR:-${TESTS_DIR}/results}"
6+
MPREMOTE="${MPREMOTE:-${TESTS_DIR}/../mpremote.py}"
7+
DIFF="diff --unified --strip-trailing-cr"
68

79
if [ -z "$1" ]; then
810
# Find tests matching test_*.sh
9-
TESTS=${TEST_DIR}/test_*.sh
11+
declare -a TESTS=("${TESTS_DIR}"/test_*.sh)
1012
else
11-
# Specific test path from the command line.
12-
TESTS="$1"
13+
# Specific test paths from the command line.
14+
declare -a TESTS=("$@")
1315
fi
1416

15-
for t in $TESTS; do
17+
mkdir --parents "${RESULT_DIR}"
18+
19+
for test in "${TESTS[@]}"; do
1620
TMP=$(mktemp -d)
17-
echo -n "${t}: "
18-
# Strip CR and replace the random temp dir with a token.
19-
if env MPREMOTE="${MPREMOTE}" TMP="${TMP}" "${t}" 2>&1 | tr -d '\r' | sed "s,${TMP},"'${TMP},g' > "${t}.out"; then
20-
if diff "${t}.out" "${t}.exp" > /dev/null; then
21+
result="${RESULT_DIR}/$(basename "${test}")"
22+
23+
echo -n "${test}: "
24+
25+
env TMP="${TMP}" envsubst <"${test}.exp" >"${result}.exp"
26+
if env MPREMOTE="${MPREMOTE}" TMP="${TMP}" "${test}" >"${result}.out" 2>&1; then
27+
if $DIFF "${result}.out" "${result}.exp" > /dev/null; then
2128
echo "OK"
29+
rm "${result}.out" "${result}.exp"
2230
else
2331
echo "FAIL"
24-
diff "${t}.out" "${t}.exp" || true
2532
fi
2633
else
2734
echo "CRASH"
2835
fi
2936
rm -r "${TMP}"
3037
done
38+
39+
for test in "${TESTS[@]}"; do
40+
result="${RESULT_DIR}/$(basename "${test}")"
41+
if [ -e "${result}.out" ]; then
42+
echo "FAILURE ${test}"
43+
$DIFF "${result}.out" "${result}.exp"
44+
fi
45+
done

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy