![]() PASS_REGULAR_EXPRESSION "add: values must be integral" Set_tests_properties(mylib-build-fail PROPERTIES Let’s say we have a trivial C++ library for which we want to do build-failure tests. A copule of days ago I decided that enough is enough and created a reusable solution which allows adding tests for expected build failure easily, very much the way the original StakOverflow question asks. I was never completely satisfied by the proposed solutions, so each time I ended up using tests with static assertions which build successfully. The first time I encountered, back in 2018, as any human being I did a web search and found this StackOverflow issue. I’ve actually ran into this problem several times in the past years. ![]() Unfortunately few build systems have ways of dealing with expected build errors. To avoid these cons, what we need to do is add a bunch of programs with build errors and have tests in our test suite to check that building them produces the expected errors. ![]() Sure, that’s not always bad and not necessarily a deal breaker, but writing tests based on implementation details can lead to bugs being reinforced by the test itself 1. Moreover even if a test with, SFINAE, or concepts is possible, it will often require intricate implementation knowledge of the API being tested.
0 Comments
Leave a Reply. |