Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Catch2 update #246

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

Open
andreagilardoni wants to merge 4 commits into arduino:master
base: master
Choose a base branch
Loading
from andreagilardoni:cmake-improvements

Conversation

Copy link
Contributor

@andreagilardoni andreagilardoni commented Feb 13, 2025

This PR aims to provide a newer version for catch2 that is directly integrated in CMake with improved functionalities.

This also solves the issue of -Werror=self-move happening on test/src/String/test_move.cpp:45:7 happening on some compilers.

In order to update catch2 the following changes were made:
- CMakeLists.txt: import catch2 with FetchContent_Declare, this will
 make it more flexible and easier to update
- removed main for tests, since it is not mandatory and it doesn't add
 any value of having it
- renaming includes in all the files
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.53%. Comparing base (4a02bfc) to head (6050833).

Additional details and impacted files
@@ Coverage Diff @@
## master #246 +/- ##
=======================================
 Coverage 95.53% 95.53% 
=======================================
 Files 16 16 
 Lines 1075 1076 +1 
=======================================
+ Hits 1027 1028 +1 
 Misses 48 48 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor Author

andreagilardoni commented Feb 13, 2025
edited
Loading

One of the reasons why I suggest introducing this new version of Catch2 is because I noticed that valgrind is unable to detect memory leaks caused by missing virtual destructor.

A practical example is the following. You can test this by running the tests this way valgrind --tool=memcheck --leak-check=yes --error-exitcode=1 bin/test-ArduinoCore-API -s '[printable-delete-01]'

#include <catch.hpp>
#include <api/IPAddress.h>
TEST_CASE("Testing polymorphic IPAddress memory free", "[printable-delete-01]")
{
 arduino::Printable* p = new IPAddress();
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
 delete p;
#pragma GCC diagnostic pop
}

#if defined(GCC_VERSION) && GCC_VERSION >= 13
#pragma GCC diagnostic pop
#endif
String b;
Copy link
Member

Choose a reason for hiding this comment

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

While this surely makes the test pass, I'm quite sure the test is not about self assignment anymore 🙃 If there's an issue with memory leaking from this we should solve it at core level

Copy link
Contributor Author

@andreagilardoni andreagilardoni Feb 17, 2025

Choose a reason for hiding this comment

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

I missed the point of this test case, I'll drop this commit. I'll look if I can improve the preprocessor checks, since I am failing this locally.

facchinm reacted with thumbs up emoji
Copy link
Contributor Author

@andreagilardoni andreagilardoni Feb 17, 2025

Choose a reason for hiding this comment

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

According to Gcc online docs at 3.7.2 GCC_VERSION is not defined in the way we are using it. I think we could check against __GNUC__ only.

I don't understand why on my local machine GCC_VERSION is not defined, but __GNUC__ is.

error: moving ‘a’ of type ‘arduino::String’ to itself [-Werror=self-move]
Which may happen if if GCC_VERSION is not defined, and instead __GNUC__
is defined
since for catch2 '[' is not a valid character in the tag name
@andreagilardoni andreagilardoni force-pushed the cmake-improvements branch 3 times, most recently from 77e6218 to a919d81 Compare July 21, 2025 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@facchinm facchinm Awaiting requested review from facchinm

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /