approvals / ApprovalTests.cpp

Native ApprovalTests for C++ on Linux, Mac and Windows
https://approvaltestscpp.readthedocs.io/en/latest/
Apache License 2.0
310 stars 50 forks source link

Support for catch2 v3.x.x #219

Closed Laguna1989 closed 5 months ago

Laguna1989 commented 6 months ago

The catch2 framework was recently upgraded to catch2 v3. The folder structure and files have been changed. There is no header

#include <catch2/catch.hpp>

anymore, but it should be

#include <catch2/catch_test_macros.hpp>

This leads to errors with this line when compiling.

Example output (generated with g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 and cmake version 3.27.7.

FAILED: .../main.cpp.o 
/usr/bin/c++  -I/<project_root>/cmake-build-debug/_deps/rapidcheck-src/extras/catch/include -I/<project_root>/impl/object_lib -I/<project_root>/cmake-build-debug/_deps/rapidcheck-src/include -I/<project_root>/cmake-build-debug/_deps/catch2-src/src/catch2/.. -I/<project_root>/cmake-build-debug/_deps/catch2-build/generated-includes -I/<project_root>/cmake-build-debug/_deps/approvaltests-src/ApprovalTests/.. -I/<project_root>/cmake-build-debug/_deps/approvaltests-src/ApprovalTests -g -fdiagnostics-color=always -MD -MT .../main.cpp.o -MF .../main.cpp.o.d -o .../main.cpp.o -c /<project_root>/test/object_lib_lib_test/main.cpp
In file included from /<project_root>/cmake-build-debug/_deps/approvaltests-src/ApprovalTests/../ApprovalTests/ApprovalTests.hpp:70,
                 from /<project_root>/test/object_lib_lib_test/main.cpp:2:
/<project_root>/cmake-build-debug/_deps/approvaltests-src/ApprovalTests/../ApprovalTests/integrations/catch/Catch2Approvals.h:18:10: fatal error: catch2/catch.hpp: No such file or directory
   18 | #include <catch2/catch.hpp>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
[31/35] Building CXX object _deps/approvaltests-build/ApprovalTests/CMakeFiles/ApprovalTests.dir/reporters/ReporterFactory.cpp.o
ninja: build stopped: subcommand failed.

This is reproducible for the latest tag v.10.12.2 as well as for the current master (d46d1903dc6d8d404da4e4026910e26df5fd3a6e)

claremacrae commented 6 months ago

Thank you, yes this needs to be done.

We have an earlier report in #156 - and need to figure out how to maintain support for both Catch2 v2 and Catch2 v3.

Laguna1989 commented 5 months ago

Fixed with #221