Skip to content

Commit

Permalink
Add test coverage to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusTomlinson committed Jan 9, 2024
1 parent bbf42bf commit 13f6b16
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ jobs:

steps:
- if: matrix.os == 'windows-2022'
name: Install Cppcheck (Windows)
name: Install Cppcheck, OpenCppCoverage, and wkhtmltopdf (Windows)
run: |
choco install -y --ignore-package-exit-codes cppcheck
choco install -y --ignore-package-exit-codes cppcheck opencppcoverage wkhtmltopdf
echo "C:\Program Files\Cppcheck" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\Program Files\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\Program Files\wkhtmltopdf" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- if: matrix.os == 'windows-2022'
name: Configure MSVC (Windows)
Expand Down Expand Up @@ -57,3 +59,14 @@ jobs:
name: Test - Debug (Windows)
run: |
meson test -vC builddir
meson compile ./codecoverage -C builddir
$files = (Get-ChildItem -R .\builddir\coverage\*.html)
[array]::Reverse($files)
wkhtmltopdf --enable-local-file-access --disable-external-links --header-center [title] $files coverage.pdf
- if: matrix.os == 'windows-2022'
name: Upload Coverage Report (Windows)
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage.pdf
20 changes: 20 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ else
add_project_arguments(['-D_CRT_SECURE_NO_WARNINGS'], language: 'cpp')
endif

# Add code coverage

opencppcoverage = find_program('opencppcoverage', required: false)

opencppcoverage_args = [
'--sources', meson.project_name(),
'--excluded_sources', 'subprojects',
'--excluded_sources', 'tests'
]

if opencppcoverage.found()
run_target('codecoverage',
command: [
opencppcoverage,
'--input_coverage', 'IpcTests.cov',
'--export_type', 'html:coverage'
]
)
endif

# Add formatting

format_first = []
Expand Down
14 changes: 13 additions & 1 deletion tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,16 @@ ipc_tests = executable(
dependencies: [gtest_dep, gmock_dep, ipc_dep]
)

test('IpcTests', ipc_tests)
# Add code coverage

if opencppcoverage.found()
test('IpcTests', opencppcoverage,
args: [
opencppcoverage_args,
'--export_type', 'binary:IpcTests.cov',
ipc_tests
]
)
else
test('IpcTests', ipc_tests)
endif

0 comments on commit 13f6b16

Please sign in to comment.