chore: Unify build & test, add ctest to coverage#6013
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #6013 +/- ##
=========================================
+ Coverage 78.3% 78.6% +0.3%
=========================================
Files 816 817 +1
Lines 68887 69005 +118
Branches 8304 8233 -71
=========================================
+ Hits 53942 54244 +302
+ Misses 14945 14761 -184 🚀 New features to boost your workflow:
|
ximinez
left a comment
There was a problem hiding this comment.
If the ctesttests are being counted in the coverage, why did the coverage not go up?
| ctest \ | ||
| --output-on-failure \ | ||
| -C "${BUILD_TYPE}" |
There was a problem hiding this comment.
ctest can run the jobs in parallel with -j $count. This is not important now, while the tests only take 1/4 second to run, but as we convert more beast-style tests, it could.
There's one caveat, which is that Windows (/sigh It's always Windows) locks some of the build files while running tests, and parallel jobs can collide. I have an inelegant workaround, which is to use --repeat until-pass:$num_tests. More details.
There was a problem hiding this comment.
it would be simpler not to use -j on Windows, IMO. EDIT: or simply use -j 1
There was a problem hiding this comment.
With the self-hosted Windows runners we set up, Windows is now one of the fastest to finish, so setting -j 1 would be more than ok for a while.
It did go up - see https://app.codecov.io/github/XRPLF/rippled/pull/6013/indirect-changes We simply do not have much under |
There was a problem hiding this comment.
A few small changes.
There is one problem in cmake files with this approach:
https://github.com/XRPLF/rippled/actions/runs/19173584738/job/54812410544?pr=6013#step:16:15
1/8 Test #2: xrpl.test.basics.build ........... Passed 0.03 sec
It thinks .build targets are part of testing (which shouldn't be true), and that's why it also doubles number of tests (binaries) it shows as passed (it shows 8 instead of 4)
17f5fcb to
f8a7aa0
Compare
That's because It as if the build targets for the unit tests were not defined as a normal binary targets on purpose. Any idea why ?
|
Was introduced by @vvysokikh1 here: https://github.com/XRPLF/rippled/pull/5383/files#diff-8f9256a178a57a974e7c72cd0e428ea351a5bfedc852982d9e7aae592c0daaa9 I don't know why it has been done this way |
I've tried removing these dummy .build targets in dbb38c6 and we will see what happens. It appears to work just fine. |
I'm not exactly sure about the change as of now (I don't remember tbh). I initially thought it was done to allow |
| # Network unit tests are currently not supported on Windows | ||
| if(NOT WIN32) | ||
| xrpl_add_test(net) | ||
| target_link_libraries(xrpl.test.net PRIVATE xrpl.imports.test) | ||
| endif() |
There was a problem hiding this comment.
what exactly is wrong with them on win?
There was a problem hiding this comment.
There was a problem hiding this comment.
Example failing test https://github.com/XRPLF/rippled/actions/runs/18801210581/job/53689528229?pr=5932
There was a problem hiding this comment.
As a result of this find, xrpl.test.net were disabled on Windows in #5932 , although this test never worked on Windows.
Questions were addressed by the author.
Oh! Fantastic! |
This change unifies the build and test jobs into a single job, and adds `ctest` to coverage reporting. The mechanics of coverage reporting is slightly complex and most of it is encapsulated in the `coverage` target. The status quo way of preparing coverage reports involves running a single target `cmake --build . --target coverage`, which does three things: * Build the `rippled` binary (via target dependency) * Prepare coverage reports: * Run `./rippled -u` unit tests. * Gather test output and build reports. This makes it awkward to add an additional `ctest` step between build and coverage reporting steps. The better solution is to split `coverage` target into separate build, followed by `ctest`, followed by test generation. Luckily, the `coverage` target has been designed specifically to support such case; it does not need to build `rippled`, it's just a dependency. Similarly it allows additional tests to be run before gathering test outputs; in principle we could even strip it from running tests and run them separately instead. This means we can keep build, `ctest` and generation of coverage reports as separate steps, as long as the state of build directory is fully (including file timestamps, additional coverage files etc.) preserved between the steps. This means that in order to run `ctest` for coverage reporting we need to integrate build and test into a single job, which this change does.
High Level Overview of Change
This PR unifies build and test jobs into a single job, and adds
ctestto coverage reporting.Context of Change
The mechanics of coverage reporting is slightly complex and most of it is encapsulated in the
coveragetarget. The status quo way of preparing coverage reports involves running a single targetcmake --build . --target coveragewhich does three things:rippledbinary (via target dependency)./rippled -uunit testsThis makes it awkward to add an additional
cteststep between build and coverage reporting steps. The better solution is to splitcoveragetarget into separate build, followed byctest, followed by test generation. Luckily, thecoveragetarget has been designed specifically to support such case; it does not need to buildrippled, it's just a dependency. Similarly it allows additional tests to be run before gathering test outputs; in principle we could even strip it from running tests and run them separately instead (a possible future PR ?)This means we can keep build,
ctestand generation of coverage reports as separate steps, as long as the state of build directory is fully (including file timestamps, additional coverage files etc) preserved between the steps.This means that in order to run
ctestfor coverage reporting we need to integrate build and test into a single job.This has the added benefit of halving the number of jobs which need to be scheduled and significantly reduces the number of files copied between the jobs. The
on-triggerworkflow is literary running hundreds of jobs (matrix of build types, unity and non-unity, two different CPU architectures, different distributions and distribution versions, different compilers) and even though we will cut this number down at some point, having the number of jobs doubled just to keep tests separate from build makes for very unpleasant experience troubleshooting test / build errors.Type of Change
.gitignore, formatting, dropping support for older tooling)