Add separate target for unit tests for easier test access. Remove unit tests from ResInsight application. (#11184)

Clean up cmake configuration a bit, and pull down gtest when needed, no longer use a thirdparty subfolder
Add a ResInsight-tests target to run the unit tests
This commit is contained in:
jonjenssen
2024-02-11 20:04:04 +01:00
committed by GitHub
parent 5a3894b804
commit 5391179e16
26 changed files with 268 additions and 27095 deletions

View File

@@ -125,10 +125,6 @@
#include <unistd.h> // for usleep
#endif // WIN32
#ifdef USE_UNIT_TESTS
#include "gtest/gtest.h"
#endif // USE_UNIT_TESTS
// Required to ignore warning of usused variable when defining caf::PdmMarkdownGenerator
#if defined( __clang__ )
#pragma clang diagnostic ignored "-Wunused-variable"
@@ -1395,56 +1391,6 @@ void RiaApplication::waitUntilCommandObjectsHasBeenProcessed()
m_commandQueueLock.unlock();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiaApplication::launchUnitTests()
{
#ifdef USE_UNIT_TESTS
caf::ProgressInfoBlocker progressBlocker;
cvf::Assert::setReportMode( cvf::Assert::CONSOLE );
int argc = QCoreApplication::arguments().size();
QStringList arguments = QCoreApplication::arguments();
std::vector<std::string> argumentsStd;
for ( QString qstring : arguments )
{
argumentsStd.push_back( qstring.toStdString() );
}
std::vector<char*> argVector;
for ( std::string& string : argumentsStd )
{
argVector.push_back( &string.front() );
}
char** argv = argVector.data();
testing::InitGoogleTest( &argc, argv );
//
// Use the gtest filter to execute a subset of tests
QString filterText = RiaPreferencesSystem::current()->gtestFilter();
if ( !filterText.isEmpty() )
{
::testing::GTEST_FLAG( filter ) = filterText.toStdString();
// Example on filter syntax
//::testing::GTEST_FLAG( filter ) = "*RifCaseRealizationParametersReaderTest*";
}
// Use this macro in main() to run all tests. It returns 0 if all
// tests are successful, or 1 otherwise.
//
// RUN_ALL_TESTS() should be invoked after the command line has been
// parsed by InitGoogleTest().
return RUN_ALL_TESTS();
#else
return -1;
#endif
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1562,14 +1508,6 @@ void RiaApplication::initialize()
caf::SelectionManager::instance()->setPdmRootObject( project() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiaApplication::launchUnitTestsWithConsole()
{
return launchUnitTests();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------