Skip to content

Commit 4dff9cb

Browse files
committed
tests/run-tests.py: Change _results.json to have a combined result list.
The `_results.json` output of `run-tests.py` was recently changed in 7a55cb6 to add a list of passed and skipped tests. The way this was done turned out to be not general enough, because we want to add another type of result, namely tests that are skipped because they are too large. Instead of having separate lists in `_results.json` for each kind of result (pass, fail, skip, skip too large, etc), this commit changes the output form of `_results.json` so that it stores a single list of 3-tuples of all tests that were run: [(test_name, result, reason), ...] That's more general and allows adding a reason for skipped and failed tests. At the moment this reason is just an empty string, but can be improved in the future. Signed-off-by: Damien George <damien@micropython.org>
1 parent c0111e6 commit 4dff9cb

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

tests/run-tests.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,7 @@ def run_script_on_remote_target(self, args, test_file, is_special):
605605
def run_tests(pyb, tests, args, result_dir, num_threads=1):
606606
test_count = ThreadSafeCounter()
607607
testcase_count = ThreadSafeCounter()
608-
passed_tests = ThreadSafeCounter([])
609-
failed_tests = ThreadSafeCounter([])
610-
skipped_tests = ThreadSafeCounter([])
608+
test_results = ThreadSafeCounter([])
611609

612610
skip_tests = set()
613611
skip_native = False
@@ -896,7 +894,7 @@ def run_one_test(test_file):
896894

897895
if skip_it:
898896
print("skip ", test_file)
899-
skipped_tests.append((test_name, test_file))
897+
test_results.append((test_name, test_file, "skip", ""))
900898
return
901899

902900
# Run the test on the MicroPython target.
@@ -911,7 +909,7 @@ def run_one_test(test_file):
911909
# start-up code (eg boot.py) when preparing to run the next test.
912910
pyb.read_until(1, b"raw REPL; CTRL-B to exit\r\n")
913911
print("skip ", test_file)
914-
skipped_tests.append((test_name, test_file))
912+
test_results.append((test_name, test_file, "skip", ""))
915913
return
916914

917915
# Look at the output of the test to see if unittest was used.
@@ -994,7 +992,7 @@ def run_one_test(test_file):
994992
# Print test summary, update counters, and save .exp/.out files if needed.
995993
if test_passed:
996994
print("pass ", test_file, extra_info)
997-
passed_tests.append((test_name, test_file))
995+
test_results.append((test_name, test_file, "pass", ""))
998996
rm_f(filename_expected)
999997
rm_f(filename_mupy)
1000998
else:
@@ -1006,7 +1004,7 @@ def run_one_test(test_file):
10061004
rm_f(filename_expected) # in case left over from previous failed run
10071005
with open(filename_mupy, "wb") as f:
10081006
f.write(output_mupy)
1009-
failed_tests.append((test_name, test_file))
1007+
test_results.append((test_name, test_file, "fail", ""))
10101008

10111009
test_count.increment()
10121010

@@ -1035,9 +1033,10 @@ def run_one_test(test_file):
10351033
print(line)
10361034
sys.exit(1)
10371035

1038-
passed_tests = sorted(passed_tests.value)
1039-
skipped_tests = sorted(skipped_tests.value)
1040-
failed_tests = sorted(failed_tests.value)
1036+
test_results = test_results.value
1037+
passed_tests = list(r for r in test_results if r[2] == "pass")
1038+
skipped_tests = list(r for r in test_results if r[2] == "skip")
1039+
failed_tests = list(r for r in test_results if r[2] == "fail")
10411040

10421041
print(
10431042
"{} tests performed ({} individual testcases)".format(
@@ -1069,9 +1068,11 @@ def to_json(obj):
10691068
with open(os.path.join(result_dir, RESULTS_FILE), "w") as f:
10701069
json.dump(
10711070
{
1071+
# The arguments passed on the command-line.
10721072
"args": vars(args),
1073-
"passed_tests": [test[1] for test in passed_tests],
1074-
"skipped_tests": [test[1] for test in skipped_tests],
1073+
# A list of all results of the form [(test, result, reason), ...].
1074+
"results": list(test[1:] for test in test_results),
1075+
# A list of failed tests. This is deprecated, use the "results" above instead.
10751076
"failed_tests": [test[1] for test in failed_tests],
10761077
},
10771078
f,
@@ -1248,7 +1249,7 @@ def main():
12481249
results_file = os.path.join(args.result_dir, RESULTS_FILE)
12491250
if os.path.exists(results_file):
12501251
with open(results_file, "r") as f:
1251-
tests = json.load(f)["failed_tests"]
1252+
tests = list(test[0] for test in json.load(f)["results"] if test[1] == "fail")
12521253
else:
12531254
tests = []
12541255
elif len(args.files) == 0:

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