approvals / ApprovalTests.cpp

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

ReporterFactoryTests.cpp fails to build with doctest 2.4.2 #168

Closed claremacrae closed 3 years ago

claremacrae commented 3 years ago

We bundle doctest 2.4.1, which works fine.

However a change in doctest 2.4.2 results in this error message:

[ 85%] Building CXX object approvaltests.cpp_build/tests/DocTest_Tests/CMakeFiles/DocTest_Tests.dir/reporters/ReporterFactoryTests.cpp.o
In file included from /Users/clare/Documents/develop/ApprovalTests/ApprovalTests.cpp.CMakeSamples/ApprovalTests.cpp/tests/DocTest_Tests/reporters/ReporterFactoryTests.cpp:8:
/Users/clare/Documents/develop/ApprovalTests/ApprovalTests.cpp.CMakeSamples/ApprovalTests.cpp/tests/DocTest_Tests/reporters/ReporterFactoryTests.cpp: In lambda function:
/Users/clare/Documents/develop/ApprovalTests/ApprovalTests.cpp.CMakeSamples/ApprovalTests.cpp/tests/DocTest_Tests/reporters/ReporterFactoryTests.cpp:38:46: error: no match for 'operator+' (operand types are 'doctest::detail::MessageBuilder' and 'const char* const')
   38 |         INFO(std::string("Reporter name = ") + reporterName);
      |                                              ^ ~~~~~~~~~~~~
      |                                                |
      |                                                const char* const
/Users/clare/Documents/develop/ApprovalTests/ApprovalTests.cpp.CMakeSamples/doctest/doctest/doctest.h:1989:19: note: in definition of macro 'DOCTEST_INFO_IMPL'
 1989 |         mb_name * __VA_ARGS__;                                                                     \
      |                   ^~~~~~~~~~~
/Users/clare/Documents/develop/ApprovalTests/ApprovalTests.cpp.CMakeSamples/doctest/doctest/doctest.h:2499:14: note: in expansion of macro 'DOCTEST_INFO'
 2499 | #define INFO DOCTEST_INFO
      |              ^~~~~~~~~~~~
/Users/clare/Documents/develop/ApprovalTests/ApprovalTests.cpp.CMakeSamples/ApprovalTests.cpp/tests/DocTest_Tests/reporters/ReporterFactoryTests.cpp:38:9: note: in expansion of macro 'INFO'
   38 |         INFO(std::string("Reporter name = ") + reporterName);
      |         ^~~~
make[2]: *** [approvaltests.cpp_build/tests/DocTest_Tests/CMakeFiles/DocTest_Tests.dir/reporters/ReporterFactoryTests.cpp.o] Error 1
make[1]: *** [approvaltests.cpp_build/tests/DocTest_Tests/CMakeFiles/DocTest_Tests.dir/all] Error 2
make: *** [all] Error 2
claremacrae commented 3 years ago

It turns out that values can be combined in INFO statements using , - so the + is not needed.

See the docs

claremacrae commented 3 years ago

However, changing the test to separate values with a , causes the build to fail with doctest 2.4.1:

[ 59%] Building CXX object tests/DocTest_Tests/CMakeFiles/DocTest_Tests.dir/reporters/ReporterFactoryTests.cpp.o
/Users/clare/Documents/develop/ApprovalTests/ApprovalTests.cpp/tests/DocTest_Tests/reporters/ReporterFactoryTests.cpp:38:47: error: too many arguments provided to function-like macro invocation
        INFO(std::string("Reporter name = "), reporterName);
                                              ^
/Users/clare/Documents/develop/ApprovalTests/ApprovalTests.cpp/third_party/doctest/include/doctest/doctest.2.3.7.h:1935:9: note: macro 'DOCTEST_INFO' defined here
#define DOCTEST_INFO(expression)                                                                   \
        ^
/Users/clare/Documents/develop/ApprovalTests/ApprovalTests.cpp/tests/DocTest_Tests/reporters/ReporterFactoryTests.cpp:38:9: error: use of undeclared identifier 'DOCTEST_INFO'
        INFO(std::string("Reporter name = "), reporterName);
        ^
/Users/clare/Documents/develop/ApprovalTests/ApprovalTests.cpp/third_party/doctest/include/doctest/doctest.2.3.7.h:2454:14: note: expanded from macro 'INFO'
#define INFO DOCTEST_INFO
             ^
2 errors generated.
make[3]: *** [tests/DocTest_Tests/CMakeFiles/DocTest_Tests.dir/reporters/ReporterFactoryTests.cpp.o] Error 1