From e365a5d78759a053d932cc34f1401440a2fdd310 Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Tue, 9 Jun 2020 15:41:54 +0200 Subject: [PATCH] Revert "Rework of https://github.com/ros2/ci/pull/415 (#469)" This reverts commit d3de5ef07cac0aefae80c5abbcd7f5559619f610. --- ros2_batch_job/__main__.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/ros2_batch_job/__main__.py b/ros2_batch_job/__main__.py index 497e876fa..ea5b370e6 100644 --- a/ros2_batch_job/__main__.py +++ b/ros2_batch_job/__main__.py @@ -14,7 +14,6 @@ import argparse import configparser -from distutils.version import StrictVersion import os from pathlib import Path import platform @@ -385,23 +384,18 @@ def build_and_test(args, job): # xunit2 format is needed to make Jenkins xunit plugin 2.x happy with open('pytest.ini', 'w') as ini_file: ini_file.write('[pytest]\njunit_family=xunit2') - # check if packages have a pytest.ini file that doesn't choose junit_family=xunit2 - # and patch configuration if needed to force the xunit2 value - # Import pytest here instead of the top of the file, see https://github.com/ros2/ci/issues/467 - import pytest - xunit_6_or_greater = StrictVersion(pytest.__version__) >= StrictVersion('6.0.0') + # check if packages have a pytest.ini file and add the xunit2 + # format if it is not present for path in Path('.').rglob('pytest.ini'): config = configparser.ConfigParser() config.read(str(path)) - if xunit_6_or_greater: - # only need to correct explicit legacy option if exists - if not check_xunit2_junit_family_value(config, 'legacy'): + try: + # only if xunit2 is set continue the loop with the file unpatched + if config.get('pytest', 'junit_family') == 'xunit2': continue - else: - # in xunit < 6 need to enforce xunit2 if not set - if check_xunit2_junit_family_value(config, 'xunit2'): - continue - print("Patch '%s' to override 'pytest.junit_family=xunit2'" % path) + except configparser.NoOptionError: + pass + print('xunit2 patch applied to ' + str(path)) config.set('pytest', 'junit_family', 'xunit2') with open(path, 'w+') as configfile: config.write(configfile) @@ -449,10 +443,6 @@ def build_and_test(args, job): return 0 -def check_xunit2_junit_family_value(config, value): - return config.get('pytest', 'junit_family', fallback='') == value - - def run(args, build_function, blacklisted_package_names=None): if blacklisted_package_names is None: blacklisted_package_names = []