approvals / ApprovalTests.cpp

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

Create wrapper ApprovalTests.hpp for projects that use this via add_subdirectory (or similar) to use #89

Closed claremacrae closed 4 years ago

claremacrae commented 4 years ago

For the background to this, see https://github.com/approvals/ApprovalTests.cpp.StarterProject/issues/9

It turns out that this will be really useful when documenting the CMake Integrations - see #69.

claremacrae commented 4 years ago

Unfortunately adding a single header for ApprovalTests has broken the Xcode CI builds that use unity.

https://github.com/approvals/ApprovalTests.cpp/runs/393170720 https://github.com/approvals/ApprovalTests.cpp/runs/393170749

Commenting out this one test fixes the build:

// begin-snippet: YouCanVerifyCombinationsOf2
TEST_CASE("YouCanVerifyCombinationsOf2")
{
    std::vector<std::string> v{"hello", "world"};
    std::vector<int> numbers{1, 2, 3};
    CombinationApprovals::verifyAllCombinations(
        [](std::string s, int i) { return std::make_pair(s, i); }, v, numbers);
}
// end-snippet

This is probably related to https://github.com/catchorg/Catch2/pull/1405 "Fixes disagreement between operator<< available for SFINAE and actually usable"

claremacrae commented 4 years ago

The fix in a877b874f434468e48bc53a4902004b9baa076dd didn't entirely work. The code built, but tests in CombinationTests.cpp failed to find the source code location when in Ninja Unity builds - the file was compiled on its own, so must not have had whatever magic Ninja and Unity uses to get the path right when multiple files are compiled.

The next change - 8a94fa88c1abbd9409a39e25629b0a052924e501 - built fine and the tests passed.

claremacrae commented 4 years ago

I've logged the need for a workaround to the build failure in #90 - so am closing this issue now.