Fix tests to work with out of source builds.#1926
Conversation
# Conflicts: # .github/workflows/build_and_test.yml # Tests/Packet++Test/main.cpp
|
@Dimi1010 should we close this PR? |
|
Sure, we can do it for now. |
# Conflicts: # .github/workflows/build_and_test.yml
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1926 +/- ##
========================================
Coverage 83.81% 83.81%
========================================
Files 313 313
Lines 55676 55669 -7
Branches 11606 11821 +215
========================================
- Hits 46665 46660 -5
+ Misses 7810 7807 -3
- Partials 1201 1202 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Ditto: are the changes related to this PR?
|
@Dimi1010 the reason the coverage tests are failing is a new gcovr version that was released recently. I'm not entirely sure how to fix it, but for now we can pin to the latest version supported by all platforms as I did here |
seladb
left a comment
There was a problem hiding this comment.
Please see one comment, overall LGTM
Summary
This PR refactors the project to output the PCPP Test executables inside the default output directory and updates the CI
build_and_testworkflow to use the new location.Rationale
The previous implementation used built the test executables within the source directories. The rationale for that was to allow usage of
PcapExamplesfolder inside the test folder for samples. The approach however created several issues with modern build patterns such as multi-config generators like Visual Studio and Ninja Multi-Config. Those solutions rely partially on out of source builds, by having the output artifacts that are config specific be generated in config sub-folders (e.g. Debug, Release, etc).The hardcoded output location of the executable broke functionalities such as the ability to have multiple configuration executables cached. For example switching to a Release config and building would overwrite a previously built Debug target.
The refactor updates the project to output all of its artifacts inside the build directory, keeping the source stable allowing more predictable behaviour when utilizing modern generators.
Changes
Test executable output location change
The test executable output location has been moved to the default location (e.g.
$(buildDir)/Tests/Packet++Test/<Config>/Packet++Test.exe).To keep compatibility the contents of
PcapExamplesare copied next to the executable. A possible future fix is to provide the ability for executable to load test resources from a custom location instead of relying on samples being inside the working directory.Refactor of
run_testsscriptsThe CI run tests python scripts have been refactored to allow for variable locations for build directory and test executables.
The change also introduces a new
Runnerclass that separates most of the logic into smaller functions instead of having a monolith main function, improving readability. Additional logging has also been added to help with runtime debugging.Github Actions workflow update
The
build_and_testworkflow has been updated to utilize the refactoredrun_testsby passing the build directory of the project, and in some cases override on the default relative paths to the test executables.The workflow has also been updated to utilize the
working-directoryparameter on action steps instead of using acd ...command inside shell command of therunparameter.