diff --git a/ros_buildfarm/ci_job.py b/ros_buildfarm/ci_job.py index bbbe5290b..ecd94c6b8 100644 --- a/ros_buildfarm/ci_job.py +++ b/ros_buildfarm/ci_job.py @@ -23,6 +23,7 @@ from ros_buildfarm.common import get_node_label from ros_buildfarm.common \ import get_repositories_and_script_generating_key_files +from ros_buildfarm.common import get_xunit_publisher_types_and_patterns from ros_buildfarm.common import JobValidationError from ros_buildfarm.common import write_groovy_script_and_configs from ros_buildfarm.config import get_ci_build_files @@ -293,6 +294,9 @@ def _get_ci_job_config( 'show_images': build_file.show_images, 'show_plots': build_file.show_plots, + + 'xunit_publisher_types': get_xunit_publisher_types_and_patterns( + ros_version), } job_config = expand_template(template_name, job_data) return job_config diff --git a/ros_buildfarm/common.py b/ros_buildfarm/common.py index df3259c66..efbb41cdd 100644 --- a/ros_buildfarm/common.py +++ b/ros_buildfarm/common.py @@ -589,3 +589,16 @@ def get_package_repo_data(repository_baseurl, targets, cache_dir): repository_baseurl, target, cache_dir) data[target] = index return data + + +def get_xunit_publisher_types_and_patterns(ros_version): + types = [] + if ros_version == 1: + types.append(('GoogleTestType', 'ws/test_results/**/*.xml')) + elif ros_version == 2: + types.append(('GoogleTestType', 'ws/test_results/**/*.gtest.xml')) + types.append(('JUnitType', '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 a97c4b386..1618aaae1 100644 --- a/ros_buildfarm/devel_job.py +++ b/ros_buildfarm/devel_job.py @@ -25,6 +25,7 @@ from ros_buildfarm.common import get_node_label from ros_buildfarm.common \ import get_repositories_and_script_generating_key_files +from ros_buildfarm.common import get_xunit_publisher_types_and_patterns from ros_buildfarm.common import git_github_orgunit from ros_buildfarm.common import JobValidationError from ros_buildfarm.common import write_groovy_script_and_configs @@ -434,6 +435,9 @@ def _get_devel_job_config( 'timeout_minutes': build_file.jenkins_job_timeout, + 'xunit_publisher_types': get_xunit_publisher_types_and_patterns( + ros_version), + 'git_ssh_credential_id': config.git_ssh_credential_id, 'collate_test_stats': build_file.collate_test_stats, diff --git a/ros_buildfarm/templates/ci/ci_job.xml.em b/ros_buildfarm/templates/ci/ci_job.xml.em index e874118b1..f6a9e1f8c 100644 --- a/ros_buildfarm/templates/ci/ci_job.xml.em +++ b/ros_buildfarm/templates/ci/ci_job.xml.em @@ -436,10 +436,12 @@ parameters = [ plots=show_plots, ))@ @[end if]@ +@[if xunit_publisher_types]@ @(SNIPPET( 'publisher_xunit', - pattern='ws/test_results/**/*.xml', + types=xunit_publisher_types, ))@ +@[end if]@ @[if timeout_minutes is not None]@ diff --git a/ros_buildfarm/templates/devel/devel_job.xml.em b/ros_buildfarm/templates/devel/devel_job.xml.em index fea6a222c..07e1f94c5 100644 --- a/ros_buildfarm/templates/devel/devel_job.xml.em +++ b/ros_buildfarm/templates/devel/devel_job.xml.em @@ -264,10 +264,12 @@ if pull_request: 'publisher_warnings', unstable_threshold=0 if notify_compiler_warnings else '', ))@ +@[if xunit_publisher_types]@ @(SNIPPET( 'publisher_xunit', - pattern='ws/test_results/**/*.xml', + types=xunit_publisher_types, ))@ +@[end if]@ @[if (not pull_request) and collate_test_stats]@ @(SNIPPET( 'publisher_groovy-postbuild', diff --git a/ros_buildfarm/templates/snippet/publisher_xunit.xml.em b/ros_buildfarm/templates/snippet/publisher_xunit.xml.em index 08b6856a5..41e2d9363 100644 --- a/ros_buildfarm/templates/snippet/publisher_xunit.xml.em +++ b/ros_buildfarm/templates/snippet/publisher_xunit.xml.em @@ -1,12 +1,24 @@ +@{ +# for backward compatibility only +if 'types' not in vars() and 'pattern' in vars(): + types = [('GoogleTestType', pattern)] +}@ - +@[for type_tag_and_pattern in types]@ +@{ +# 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 +}@ + <@(type_tag)> @ESCAPE(pattern) true true true true - + +@[end for]@