summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2020-09-14 18:11:19 +1000
committerJim Mussared <jim.mussared@gmail.com>2020-09-18 12:51:21 +1000
commit06dda48144be94ff6bef92b5bbf3fa87dea32cfa (patch)
treeaa1cfbe911cb8aba225ded4bf0caca6799332089
parent857e2c8fd54bc1d5ec3d3c0a38e4ac989e91413a (diff)
tests/run-multitests.py: Show test/truth diff.
-rwxr-xr-xtests/run-multitests.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/run-multitests.py b/tests/run-multitests.py
index 7ab4e85c5..ad032df38 100755
--- a/tests/run-multitests.py
+++ b/tests/run-multitests.py
@@ -7,6 +7,7 @@
import sys, os, time, re, select
import argparse
import subprocess
+import tempfile
sys.path.append("../tools")
import pyboard
@@ -18,6 +19,9 @@ else:
CPYTHON3 = os.getenv("MICROPY_CPYTHON3", "python3")
MICROPYTHON = os.getenv("MICROPY_MICROPYTHON", "../ports/unix/micropython")
+# For diff'ing test output
+DIFF = os.getenv("MICROPY_DIFF", "diff -u")
+
PYTHON_TRUTH = CPYTHON3
INSTANCE_READ_TIMEOUT_S = 10
@@ -323,6 +327,18 @@ def run_test_on_instances(test_file, num_instances, instances):
return error, skip, output_str
+def print_diff(a, b):
+ a_fd, a_path = tempfile.mkstemp(text=True)
+ b_fd, b_path = tempfile.mkstemp(text=True)
+ os.write(a_fd, a.encode())
+ os.write(b_fd, b.encode())
+ os.close(a_fd)
+ os.close(b_fd)
+ subprocess.run(DIFF.split(" ") + [a_path, b_path])
+ os.unlink(a_path)
+ os.unlink(b_path)
+
+
def run_tests(test_files, instances_truth, instances_test):
skipped_tests = []
passed_tests = []
@@ -372,6 +388,8 @@ def run_tests(test_files, instances_truth, instances_test):
print(output_test, end="")
print("### TRUTH ###")
print(output_truth, end="")
+ print("### DIFF ###")
+ print_diff(output_test, output_truth)
if cmd_args.show_output:
print()