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

catch2 v3 compatibility #2

Closed
qsuscs opened this issue Mar 3, 2023 · 2 comments
Closed

catch2 v3 compatibility #2

qsuscs opened this issue Mar 3, 2023 · 2 comments

Comments

@qsuscs
Copy link

qsuscs commented Mar 3, 2023

I applied similar catch2 v3 fixes as with termpaint, but there are still issues (this is with commit 4426a73):

diff --git a/meson.build b/meson.build
index c9c11d5..0f65ec9 100644
--- a/meson.build
+++ b/meson.build
@@ -62,6 +62,10 @@ if not meson.is_subproject()
   catch2_dep = dependency('catch2', required : get_option('system-catch2'))
   if not catch2_dep.found()
     catch2_dep = declare_dependency(compile_args: ['-DBUNDLED_CATCH2'])
+  else
+    if catch2_dep.version().version_compare('>=3.0')
+      catch2_dep = [catch2_dep, declare_dependency(compile_args: ['-DCATCH3'])]
+    endif
   endif
 
   testlib = static_library('testlib', 'tests/catch_main.cpp', dependencies: [catch2_dep])
diff --git a/tests/catch_main.cpp b/tests/catch_main.cpp
index f3be68a..549ac70 100644
--- a/tests/catch_main.cpp
+++ b/tests/catch_main.cpp
@@ -3,7 +3,11 @@
 #define CATCH_CONFIG_RUNNER
 #define CATCH_CONFIG_NO_POSIX_SIGNALS
 #ifndef BUNDLED_CATCH2
+#ifdef CATCH3
+#include "catch2/catch_all.hpp"
+#else
 #include "catch2/catch.hpp"
+#endif
 #else
 #include "catch.hpp"
 #endif
diff --git a/tests/tests.cpp b/tests/tests.cpp
index dde82e5..c38d9df 100644
--- a/tests/tests.cpp
+++ b/tests/tests.cpp
@@ -22,7 +22,11 @@
 #define CATCH_CONFIG_EXTERNAL_INTERFACES
 #define CATCH_CONFIG_NO_POSIX_SIGNALS
 #ifndef BUNDLED_CATCH2
+#ifdef CATCH3
+#include "catch2/catch_all.hpp"
+#else
 #include "catch2/catch.hpp"
+#endif
 #else
 #include "catch.hpp"
 #endif
[1/2] sccache c++ -Itests.p -I. -I.. -I/usr/include/qt5/QtCore -I/usr/include/qt5 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++14 -O0 -g -DCATCH3 -DQT_CORE_LIB -fPIC -MD -MQ tests.p/tests_tests.cpp.o -MF tests.p/tests_tests.cpp.o.d -o tests.p/tests_tests.cpp.o -c ../tests/tests.cpp
FAILED: tests.p/tests_tests.cpp.o 
sccache c++ -Itests.p -I. -I.. -I/usr/include/qt5/QtCore -I/usr/include/qt5 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++14 -O0 -g -DCATCH3 -DQT_CORE_LIB -fPIC -MD -MQ tests.p/tests_tests.cpp.o -MF tests.p/tests_tests.cpp.o.d -o tests.p/tests_tests.cpp.o -c ../tests/tests.cpp
../tests/tests.cpp:41:57: error: expected class-name before ‘{’ token
   41 | struct SaneStateListener : Catch::TestEventListenerBase {
      |                                                         ^
../tests/tests.cpp:46:11: error: ‘TestEventListenerBase’ has not been declared
   46 |     using TestEventListenerBase::TestEventListenerBase; // inherit constructor
      |           ^~~~~~~~~~~~~~~~~~~~~
../tests/tests.cpp:48:18: error: ‘virtual void SaneStateListener::testCaseStarting(const Catch::TestCaseInfo&)’ marked ‘override’, but does not override
   48 |     virtual void testCaseStarting(Catch::TestCaseInfo const& testInfo) override {
      |                  ^~~~~~~~~~~~~~~~
../tests/tests.cpp:60:18: error: ‘virtual void SaneStateListener::testCaseEnded(const Catch::TestCaseStats&)’ marked ‘override’, but does not override
   60 |     virtual void testCaseEnded(Catch::TestCaseStats const& testCaseStats) override {
      |                  ^~~~~~~~~~~~~
../tests/tests.cpp: In constructor ‘SaneStateListener::SaneStateListener(const Catch::ReporterConfig&)’:
../tests/tests.cpp:42:91: error: expected class-name before ‘(’ token
   42 |     SaneStateListener(Catch::ReporterConfig const& _config) : Catch::TestEventListenerBase(_config) {
      |                                                                                           ^
../tests/tests.cpp:42:91: error: expected ‘{’ before ‘(’ token
../tests/tests.cpp: In member function ‘virtual void SaneStateListener::testCaseEnded(const Catch::TestCaseStats&)’:
../tests/tests.cpp:63:41: error: request for member ‘name’ in ‘testCaseStats.Catch::TestCaseStats::testInfo’, which is of pointer type ‘const Catch::TestCaseInfo* const’ (maybe you meant to use ‘->’ ?)
   63 |             puts(testCaseStats.testInfo.name.c_str());
      |                                         ^~~~
../tests/tests.cpp:68:41: error: request for member ‘name’ in ‘testCaseStats.Catch::TestCaseStats::testInfo’, which is of pointer type ‘const Catch::TestCaseInfo* const’ (maybe you meant to use ‘->’ ?)
   68 |             puts(testCaseStats.testInfo.name.c_str());
      |                                         ^~~~
In file included from /usr/include/catch2/reporters/catch_reporters_all.hpp:33,
                 from /usr/include/catch2/catch_all.hpp:119,
                 from ../tests/tests.cpp:26:
/usr/include/catch2/reporters/catch_reporter_registrars.hpp: In instantiation of ‘Catch::IEventListenerPtr Catch::ListenerRegistrar<T>::TypedListenerFactory::create(const Catch::IConfig*) const [with T = SaneStateListener; Catch::IEventListenerPtr = Catch::Detail::unique_ptr<Catch::IEventListener>]’:
/usr/include/catch2/reporters/catch_reporter_registrars.hpp:85:31:   required from here
/usr/include/catch2/reporters/catch_reporter_registrars.hpp:86:55: error: could not convert ‘Catch::Detail::make_unique(Args&& ...) [with T = SaneStateListener; Args = {const Catch::IConfig*&}]()’ from ‘unique_ptr<SaneStateListener>’ to ‘unique_ptr<Catch::IEventListener>’
   86 |                 return Detail::make_unique<T>( config );
      |                                                       ^
      |                                                       |
      |                                                       unique_ptr<SaneStateListener>
In file included from /usr/include/catch2/interfaces/catch_interfaces_reporter.hpp:16,
                 from /usr/include/catch2/benchmark/catch_benchmark.hpp:16,
                 from /usr/include/catch2/benchmark/catch_benchmark_all.hpp:24,
                 from /usr/include/catch2/catch_all.hpp:25:
/usr/include/catch2/internal/catch_unique_ptr.hpp: In instantiation of ‘Catch::Detail::unique_ptr<T> Catch::Detail::make_unique(Args&& ...) [with T = SaneStateListener; Args = {const Catch::IConfig*&}]’:
/usr/include/catch2/reporters/catch_reporter_registrars.hpp:86:46:   required from ‘Catch::IEventListenerPtr Catch::ListenerRegistrar<T>::TypedListenerFactory::create(const Catch::IConfig*) const [with T = SaneStateListener; Catch::IEventListenerPtr = Catch::Detail::unique_ptr<Catch::IEventListener>]’
/usr/include/catch2/reporters/catch_reporter_registrars.hpp:85:31:   required from here
/usr/include/catch2/internal/catch_unique_ptr.hpp:111:30: error: no matching function for call to ‘SaneStateListener::SaneStateListener(const Catch::IConfig*&)’
  111 |         return unique_ptr<T>(new T(CATCH_FORWARD(args)...));
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../tests/tests.cpp:42:5: note: candidate: ‘SaneStateListener::SaneStateListener(const Catch::ReporterConfig&)’
   42 |     SaneStateListener(Catch::ReporterConfig const& _config) : Catch::TestEventListenerBase(_config) {
      |     ^~~~~~~~~~~~~~~~~
../tests/tests.cpp:42:52: note:   no known conversion for argument 1 from ‘const Catch::IConfig*’ to ‘const Catch::ReporterConfig&’
   42 |     SaneStateListener(Catch::ReporterConfig const& _config) : Catch::TestEventListenerBase(_config) {
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
../tests/tests.cpp:41:8: note: candidate: ‘constexpr SaneStateListener::SaneStateListener(const SaneStateListener&)’
   41 | struct SaneStateListener : Catch::TestEventListenerBase {
      |        ^~~~~~~~~~~~~~~~~
../tests/tests.cpp:41:8: note:   no known conversion for argument 1 from ‘const Catch::IConfig*’ to ‘const SaneStateListener&’
../tests/tests.cpp:41:8: note: candidate: ‘constexpr SaneStateListener::SaneStateListener(SaneStateListener&&)’
../tests/tests.cpp:41:8: note:   no known conversion for argument 1 from ‘const Catch::IConfig*’ to ‘SaneStateListener&&’
ninja: build stopped: subcommand failed.
@textshell
Copy link
Owner

Can you try if #3 fixes the problem?

@textshell
Copy link
Owner

Tested on debian, which now also has catch2 3.x

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

No branches or pull requests

2 participants