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

Fix Sonarcloud sonar-project.properties #127

Merged
merged 11 commits into from
Aug 26, 2022
Merged

Conversation

krisukox
Copy link
Contributor

@krisukox krisukox commented Aug 4, 2022

The purpose of this PR is to generate code coverage from the headers which are included only in the test cases.
This PR:

  • adds test source files to the sonar.inclusions property
  • excludes test source files from the final code coverage by adding sonar.coverage.exclusions property

jungleraptor and others added 11 commits August 2, 2022 18:27
Fixes the emitted sonar.properties file so that header and test files
are picked up by Sonarcloud analysis.

According to the docs `sonar.tests` is ignored for C/C++ code, so
test paths should be treated the same as source paths.

Also switches `sonar.inclusions` with `sonar.sources` to fix the include
paths being filtered out.
Fixes code coverage builds by switching to using the sonar.inclusions
property.

Some of our build targets set their source directories in the include paths.
Those paths are then emitted in the sonar-project.properties file here. The
issue is that this can lead to files being indexed twice which the sonar-scanner
treats as an error.

Using the `sonar.inclusions` property and adding pattern strings avoids this
issue.
Add executables
Distiguish executable and tests using SWIFT_TYPES + test/test_library and LINK_LIBRARIES + gtest
@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 4, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@krisukox krisukox requested a review from jungleraptor August 18, 2022 12:25
@krisukox krisukox marked this pull request as ready for review August 18, 2022 12:25
@krisukox krisukox requested a review from woodfell August 18, 2022 12:25
Copy link
Contributor

@jungleraptor jungleraptor left a comment

Choose a reason for hiding this comment

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

It looks good but I would like to see some tests that activate the coverage.

list(JOIN test_files ",${_sonarcloud_newline}" sonar_tests)
string(APPEND sonarcloud_project_properties_content "sonar.tests.inclusions=${_sonarcloud_newline}${sonar_tests}\n")
foreach(source_file ${source_source_files})
list(REMOVE_ITEM test_files ${source_file})
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the purpose of this? There's intersection between these sets of files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, e.g.: swiftlets-core library and unit-test-swiftlets-harness test target have threaded_swiftlet.cc source file.

Copy link
Contributor

@jungleraptor jungleraptor left a comment

Choose a reason for hiding this comment

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

LGTM let's give it a go.

@krisukox krisukox merged commit 2d81b27 into master Aug 26, 2022
@krisukox krisukox deleted the krisukox/sonarcloud branch August 26, 2022 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants