From b7e0bb9930d4c9e7b039ecf19da62ee36d861d0a Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Wed, 26 Jun 2019 12:49:24 +0300 Subject: [PATCH] Add xunit-summary.py (mono/mono#15373) Commit migrated from https://github.com/mono/mono/commit/78b9c66501113469e081066ad6b500595a727b66 --- src/mono/netcore/Makefile | 8 ++++-- src/mono/netcore/xunit-summary.py | 57 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 src/mono/netcore/xunit-summary.py diff --git a/src/mono/netcore/Makefile b/src/mono/netcore/Makefile index 84fc1e5..22d580a 100644 --- a/src/mono/netcore/Makefile +++ b/src/mono/netcore/Makefile @@ -150,7 +150,8 @@ corefx/.stamp-dl-corefx-tests-$(NETCORETESTS_VERSION): run-tests-corefx: update-tests-corefx for testdir in corefx/tests/extracted/*; do \ $(MAKE) run-tests-corefx-$$(basename $${testdir}); \ - done + done; \ + $(MAKE) xunit-summary run-tests-corefx-%: prepare update-tests-corefx echo -n "***************** $* *********************" @@ -173,6 +174,9 @@ build-test-corefx-%: cp $(COREFX_ROOT)/src/$*/tests/tmp/$*.Tests.{dll,pdb} $(CURDIR)/corefx/tests/extracted/$*.Tests/ rm -rf $(COREFX_ROOT)/src/$*/tests/tmp +xunit-summary: + python xunit-summary.py "corefx/tests" + endif -distdir: +distdir: \ No newline at end of file diff --git a/src/mono/netcore/xunit-summary.py b/src/mono/netcore/xunit-summary.py new file mode 100644 index 0000000..86565d7 --- /dev/null +++ b/src/mono/netcore/xunit-summary.py @@ -0,0 +1,57 @@ +import xml.etree.ElementTree as ET +import os +import glob +import ntpath +import sys + +if len(sys.argv) < 1: + print("Usage: xunit-summary.py ") + sys.exit(1) +test_dir = sys.argv [1] + +class TestResults(): + def __init__(self, name, total, passed, failed, skipped, errors, time): + self.name = name + self.total = total + self.passed = passed + self.failed = failed + errors + self.skipped = skipped + self.time = time + +print("") + +tests = [] +for testfile in glob.glob(test_dir + "/*-xunit.xml"): + assemblies = ET.parse(testfile).getroot() + for assembly in assemblies: + test_name = assembly.attrib.get("name") + if test_name is None: + print("WARNING: %s has no tests!" % ntpath.basename(testfile)) + continue + tests.append(TestResults(test_name, + int(assembly.attrib["total"]), + int(assembly.attrib["passed"]), + int(assembly.attrib["failed"]), + int(assembly.attrib["skipped"]), + int(assembly.attrib["errors"]), + float(assembly.attrib["time"]))) + +# sort by name +tests.sort(key=lambda item: item.name) + +print("") +print("=" * 105) +for t in tests: + #if t.failed > 0: # uncomment to list only test suits with failures + print("{0:<60} Total:{1:<6} Failed:{2:<6} Time:{3} sec".format(t.name, t.total, t.failed, round(t.time, 1))) +print("=" * 105) + +print("") +print("Total test suits: %d" % len(tests)) +print("Total tests run: %d" % sum(x.total for x in tests)) +print("Total tests passed: %d" % sum(x.passed for x in tests)) +print("Total tests failed: %d" % sum(x.failed for x in tests)) +print("Total tests skipped: %d" % sum(x.skipped for x in tests)) +print("Total duration: %d min" % (sum(x.time for x in tests) / 60)) +print("") + -- 2.7.4