Files
CMake/Tests/RunCMake/GoogleTest/configuration_gtest.cpp
Ryan Thornton 3b4838b57f GoogleTest: Add tests for MultiConfig discovery in PRE_TEST mode
PRE_TEST makes it possible to properly distinguish between test cases
that exist only in certain configurations.

In the new test scenario, debug tests are disabled in release builds,
and release tests are disabled in debug builds
when a multi config generator is used.

Note, this is a bit of a hack and *only* works for PRE_TEST mode.

POST_BUILD makes no attempt to get this right. It preserves the status quo
and you obtain the tests that were last discovered.

See further discussion in !4078

Ideally, the POST_BUILD behavior could be fixed
by using generator expressions in OUTPUT and BYPRODUCT expressions.

Then you could do something like:

    set(ctest_include_file "${ctest_file_base}_include-$<CONFIG>.cmake")
    set(ctest_tests_file "${ctest_file_base}_tests-$<CONFIG>.cmake")

Once #12877 lands, maybe this can be revisited.

Co-authored-by: Ryan Thornton <ThorntonRyan@JohnDeere.com>
Co-authored-by: Kevin Puetz <PuetzKevinA@JohnDeere.com>
2020-03-27 09:40:40 -05:00

24 lines
742 B
C++

#include <iostream>
#include <string>
int main(int argc, char** argv)
{
// Note: GoogleTest.cmake doesn't actually depend on Google Test as such;
// it only requires that we produces output in the expected format when
// invoked with --gtest_list_tests. Thus, we fake that here. This allows us
// to test the module without actually needing Google Test.
if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") {
std::cout << "configuration." << std::endl;
#ifdef DEBUG
std::cout << " DISABLED_case_release" << std::endl;
std::cout << " case_debug" << std::endl;
#else
std::cout << " case_release" << std::endl;
std::cout << " DISABLED_case_debug" << std::endl;
#endif
return 0;
}
return 1;
}