Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use distinct xunit pattern for ROS 2 #828

Merged
merged 1 commit into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ros_buildfarm/ci_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 14 additions & 2 deletions ros_buildfarm/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not super clear in the pytest documentation or in the deprecation warnings produced, but testing locally I've observed that using pytest version >= 6 does not imply that the junit_family type will be xunit2. In fact, if you don't explicitly set the junit_family (either with a pytest.ini file or a pytest -o option), then we get the legacy behavior. This is what's causing CI to fail for Foxy (ros2/ros2#1016).

I think this only happened to work for Rolling because of all of the backports explicitly setting the junit_family in pytest.ini files (ros2/ros2#951).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #836 for a proposed fix.

'ws/test_results/*/pytest.xml'))
types.append(('JUnitType', 'ws/test_results/**/*.xunit.xml'))
else:
assert False, 'Unsupported ROS version: ' + str(ros_version)
return types


Expand Down
3 changes: 2 additions & 1 deletion ros_buildfarm/devel_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
2 changes: 1 addition & 1 deletion ros_buildfarm/templates/snippet/publisher_xunit.xml.em
Original file line number Diff line number Diff line change
Expand Up @@ -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)>
<pattern>@ESCAPE(pattern)</pattern>
Expand Down