diff --git a/ros_buildfarm/ci_job.py b/ros_buildfarm/ci_job.py index d9cee87be..9f5cb1aec 100644 --- a/ros_buildfarm/ci_job.py +++ b/ros_buildfarm/ci_job.py @@ -303,7 +303,8 @@ def _get_ci_job_config( # only Ubuntu Focal has a new enough pytest version which generates # JUnit compliant result files - 'xunit_publisher_types': get_xunit_publisher_types_and_patterns(), + 'xunit_publisher_types': get_xunit_publisher_types_and_patterns( + ros_version, os_name == 'ubuntu' and os_code_name != 'bionic'), } job_config = expand_template(template_name, job_data) return job_config diff --git a/ros_buildfarm/common.py b/ros_buildfarm/common.py index fb875f6bc..eb914bfc6 100644 --- a/ros_buildfarm/common.py +++ b/ros_buildfarm/common.py @@ -600,9 +600,21 @@ def get_packages_in_workspaces(workspace_roots, condition_context=None): return pkgs -def get_xunit_publisher_types_and_patterns(): +def get_xunit_publisher_types_and_patterns( + ros_version, pytest_junit_compliant +): types = [] - types.append(('GoogleTestType', 'ws/test_results/**/*.xml')) + if ros_version == 1: + types.append(('GoogleTestType', 'ws/test_results/**/*.xml')) + elif ros_version == 2: + types.append(('CTestType', 'ws/test_results/*/Testing/*/Test.xml')) + types.append(('GoogleTestType', 'ws/test_results/**/*.gtest.xml')) + types.append(( + 'JUnitType' if pytest_junit_compliant else 'GoogleTestType', + 'ws/test_results/*/pytest.xml')) + types.append(('JUnitType', 'ws/test_results/**/*.xunit.xml')) + else: + assert False, 'Unsupported ROS version: ' + str(ros_version) return types diff --git a/ros_buildfarm/devel_job.py b/ros_buildfarm/devel_job.py index 4597401b6..88455ab93 100644 --- a/ros_buildfarm/devel_job.py +++ b/ros_buildfarm/devel_job.py @@ -439,7 +439,8 @@ def _get_devel_job_config( # only Ubuntu Focal has a new enough pytest version which generates # JUnit compliant result files - 'xunit_publisher_types': get_xunit_publisher_types_and_patterns(), + 'xunit_publisher_types': get_xunit_publisher_types_and_patterns( + ros_version, os_name == 'ubuntu' and os_code_name != 'bionic'), 'git_ssh_credential_id': config.git_ssh_credential_id, diff --git a/ros_buildfarm/templates/snippet/publisher_xunit.xml.em b/ros_buildfarm/templates/snippet/publisher_xunit.xml.em index 2a7d869f0..99418e7ba 100644 --- a/ros_buildfarm/templates/snippet/publisher_xunit.xml.em +++ b/ros_buildfarm/templates/snippet/publisher_xunit.xml.em @@ -9,7 +9,7 @@ if 'types' not in vars() and 'pattern' in vars(): @{ # expanding these within the for statement leads to a TypeError in empy version 3.3.4 and older type_tag, pattern = type_tag_and_pattern -assert type_tag in ('GoogleTestType', 'JUnitType'), 'Unsupported test type tag: ' + type_tag +assert type_tag in ('CTestType', 'GoogleTestType', 'JUnitType'), 'Unsupported test type tag: ' + type_tag }@ <@(type_tag)> @ESCAPE(pattern)