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

Fixed lcov error #771

Merged
merged 12 commits into from
May 24, 2024
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
5 changes: 4 additions & 1 deletion linux_docker_resources/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ RUN if test ${COMPILE_WITH_CLANG} = true; then apt-get update && apt-get install
# Install coverage build dependencies.
RUN apt-get update && apt-get install --no-install-recommends -y lcov

RUN pip3 install -U lcov_cobertura_fix
# There is a bug in upstream lcov-to-cobertura-xml with newer versions of lcov. There is an
# open PR for it in https://github.com/eriwen/lcov-to-cobertura-xml/pull/55, but until that is
# merged use the fork with the fix.
RUN pip3 install -U git+https://github.com/ahcorde/lcov-to-cobertura-xml@master

# Install the Connext binary from the OSRF repositories.
RUN if test \( ${PLATFORM} = x86 -a ${INSTALL_CONNEXT_DEBS} = true \); then apt-get update && RTI_NC_LICENSE_ACCEPTED=yes apt-get install -y rti-connext-dds-6.0.1; fi
Expand Down
24 changes: 22 additions & 2 deletions ros2_batch_job/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,16 +266,36 @@ def __call__(self, parser, namespace, values, option_string=None):
setattr(args, name, space_directory)
return args

def get_lcov_version():
try:
result = subprocess.run(['lcov', '--version'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True, check=True)
version_output = result.stdout.strip().replace('lcov: LCOV version ', '')
return version_output
except subprocess.CalledProcessError as e:
return ""

def process_coverage(args, job):
print('# BEGIN SUBSECTION: coverage analysis')
# Capture all gdca/gcno files (all them inside buildspace)
coverage_file = os.path.join(args.buildspace, 'coverage.info')

version = get_lcov_version()
lcov_arguments = []
if version.startswith('2'):
lcov_arguments = ['--ignore-errors', 'inconsistent,inconsistent',
'--ignore-errors', 'mismatch,mismatch',
'--ignore-errors', 'negative,negative',
'--ignore-errors', 'unused,unused',
'--ignore-errors', 'empty,empty']
Comment on lines +288 to +292
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not against this, but can you explain more why we need to ignore all of these errors? I think it would be best to have a comment here with that, so future readers know why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was just launching the CI and fixing the errors.


cmd = [
'lcov',
'--capture',
'--directory', args.buildspace,
'--output', str(coverage_file)]
'--output', str(coverage_file)] + lcov_arguments
print(cmd)
subprocess.run(cmd, check=True)
# Filter out system coverage and test code
Expand All @@ -288,7 +308,7 @@ def process_coverage(args, job):
'*/test/*',
'*/tests/*',
'*gtest_vendor*',
'*gmock_vendor*']
'*gmock_vendor*'] + lcov_arguments
print(cmd)
subprocess.run(cmd, check=True)
# Transform results to the cobertura format
Expand Down