From b17f27416d7619a82242495aeb8a654b5be64afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 5 Aug 2021 17:15:19 +0200 Subject: [PATCH] ci: Switch to meson's generated Junit report ... instead of generating it ourselves from the regular meson logs. Part-of: --- .gitlab-ci.yml | 2 +- .gitlab-ci/meson-junit-report.py | 109 ------------------------------- .gitlab-ci/run-tests.sh | 6 -- 3 files changed, 1 insertion(+), 116 deletions(-) delete mode 100755 .gitlab-ci/meson-junit-report.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 436835ceb..507444d90 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -213,7 +213,7 @@ build-without-native-backend-and-wayland@x86_64: artifacts: expire_in: 1 day reports: - junit: "build/${CI_JOB_NAME}-report.xml" + junit: "build/meson-logs/testlog-catchsegv.junit.xml" name: "mutter-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}" when: always paths: diff --git a/.gitlab-ci/meson-junit-report.py b/.gitlab-ci/meson-junit-report.py deleted file mode 100755 index 6370ffa35..000000000 --- a/.gitlab-ci/meson-junit-report.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env python3 - -# Turns a Meson testlog.json file into a JUnit XML report -# -# Copyright 2019 GNOME Foundation -# -# SPDX-License-Identifier: LGPL-2.1-or-later -# -# Original author: Emmanuele Bassi - -import argparse -import datetime -import json -import os -import sys -import xml.etree.ElementTree as ET - -aparser = argparse.ArgumentParser(description='Turns a Meson test log into a JUnit report') -aparser.add_argument('--project-name', metavar='NAME', - help='The project name', - default='unknown') -aparser.add_argument('--job-id', metavar='ID', - help='The job ID for the report', - default='Unknown') -aparser.add_argument('--branch', metavar='NAME', - help='Branch of the project being tested', - default='main') -aparser.add_argument('--output', metavar='FILE', - help='The output file, stdout by default', - type=argparse.FileType('w', encoding='UTF-8'), - default=sys.stdout) -aparser.add_argument('infile', metavar='FILE', - help='The input testlog.json, stdin by default', - type=argparse.FileType('r', encoding='UTF-8'), - default=sys.stdin) - -args = aparser.parse_args() - -outfile = args.output - -testsuites = ET.Element('testsuites') -testsuites.set('id', '{}/{}'.format(args.job_id, args.branch)) -testsuites.set('package', args.project_name) -testsuites.set('timestamp', datetime.datetime.utcnow().isoformat(timespec='minutes')) - -suites = {} -for line in args.infile: - data = json.loads(line) - (full_suite, unit_name) = data['name'].split(' / ') - (project_name, suite_name) = full_suite.split(':') - - duration = data['duration'] - return_code = data['returncode'] - log = data['stdout'] - - unit = { - 'suite': suite_name, - 'name': unit_name, - 'duration': duration, - 'returncode': return_code, - 'stdout': log, - } - - units = suites.setdefault(suite_name, []) - units.append(unit) - -for name, units in suites.items(): - print('Processing suite {} (units: {})'.format(name, len(units))) - - def if_failed(unit): - if unit['returncode'] != 0: - return True - return False - - def if_succeded(unit): - if unit['returncode'] == 0: - return True - return False - - successes = list(filter(if_succeded, units)) - failures = list(filter(if_failed, units)) - print(' - {}: {} pass, {} fail'.format(name, len(successes), len(failures))) - - testsuite = ET.SubElement(testsuites, 'testsuite') - testsuite.set('name', '{}/{}'.format(args.project_name, name)) - testsuite.set('tests', str(len(units))) - testsuite.set('errors', str(len(failures))) - testsuite.set('failures', str(len(failures))) - - for unit in successes: - testcase = ET.SubElement(testsuite, 'testcase') - testcase.set('classname', '{}/{}'.format(args.project_name, unit['suite'])) - testcase.set('name', unit['name']) - testcase.set('time', str(unit['duration'])) - - for unit in failures: - testcase = ET.SubElement(testsuite, 'testcase') - testcase.set('classname', '{}/{}'.format(args.project_name, unit['suite'])) - testcase.set('name', unit['name']) - testcase.set('time', str(unit['duration'])) - - failure = ET.SubElement(testcase, 'failure') - failure.set('classname', '{}/{}'.format(args.project_name, unit['suite'])) - failure.set('name', unit['name']) - failure.set('type', 'error') - failure.text = unit['stdout'] - -output = ET.tostring(testsuites, encoding='unicode') -outfile.write(output) diff --git a/.gitlab-ci/run-tests.sh b/.gitlab-ci/run-tests.sh index f2e8519d5..0c3139383 100755 --- a/.gitlab-ci/run-tests.sh +++ b/.gitlab-ci/run-tests.sh @@ -20,10 +20,4 @@ xvfb-run -s '+iglx -noreset' \ exit_code=$? -python3 .gitlab-ci/meson-junit-report.py \ - --project-name=mutter \ - --job-id "${CI_JOB_NAME}" \ - --output "build/${CI_JOB_NAME}-report.xml" \ - build/meson-logs/testlog-catchsegv.json - exit $exit_code