Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[all] Refactor SofaTest to cut dependencies #471

Merged
merged 30 commits into from
Nov 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
81e12e0
[SofaKernel] Add a base class for framework_test.
damienmarchal Oct 11, 2017
fcbb885
[SofaKernel] Add BaseTest & NumericTest in helper.
damienmarchal Oct 12, 2017
ae6c9be
[SofaKernel] Add in SofaSimulationGraph the base class for testing fu…
damienmarchal Oct 12, 2017
640aabc
[SofaKernel] Update all the files in framework_test to use BaseTest o…
damienmarchal Oct 12, 2017
cbefd55
[SofaKernel] Move tests thats needs a simulation into frameworkextra_…
damienmarchal Oct 12, 2017
244ab05
[SofaTest] Update so it now rely on helper/BaseTest & add deprecation…
damienmarchal Oct 12, 2017
029be0f
[modules] add frameworkextra_test into CMakeLists.
damienmarchal Oct 12, 2017
b3a2ae4
[SofaGTestMain] Remove the dependency to SofaTest.
damienmarchal Oct 12, 2017
54a2cb2
[SceneCreator] force loading of exernal component libraries (initComp…
damienmarchal Oct 12, 2017
6b2d29b
[SofaKernel] Add SOFA_SIMULATION_GRAPH_API to BaseSimulationTest to a…
damienmarchal Oct 12, 2017
e9f0ab8
[packages] Add a packages for exposing all common components in a plu…
damienmarchal Oct 12, 2017
2ca2be1
[SofaKernel] Add SimpleApi to create scene graph in a python like way.
damienmarchal Oct 12, 2017
ace7a3b
[BaseSimulation] Add a new way to create SceneInstance.
damienmarchal Oct 12, 2017
ba082bd
[SofaKernel] Updates the tests in simulation_test to remove the depen…
damienmarchal Oct 12, 2017
1400e0f
[SceneCreator] Remove SimpleApi, it is now in SofaSimulationGraph
damienmarchal Oct 12, 2017
22f77ea
[SceneCreator] Remove the dependency to SofaComponent* use the SofaAl…
damienmarchal Oct 12, 2017
7d5b4c4
[SofaTest] Use the package SofaAllCommonComponents instead of using s…
damienmarchal Oct 12, 2017
8e8d7a9
Merge remote-tracking branch 'upstream/master' into moveTestToSofaKer…
damienmarchal Oct 12, 2017
e588c70
[SofaTest] Add missing SOFA_TestPlugin_API
damienmarchal Oct 12, 2017
f7e1194
[SofaTest] Unify the SOFA_SOFATEST_API to be consistent with the rest…
damienmarchal Oct 12, 2017
f88a33c
[SofaKernel] Fix compilation problem because of linking issue.
damienmarchal Oct 13, 2017
e332328
[SofaMiscFem] Fix compilation problem because of linking issue.
damienmarchal Oct 13, 2017
ea80eea
Merge remote-tracking branch 'upstream/master' into moveTestToSofaKer…
damienmarchal Oct 23, 2017
7d14652
[SofaKernel] remove framework_test/io/ImagePNG_test.cpp that poped-up…
damienmarchal Oct 23, 2017
21a9456
[SofaTest] Repalce SOFA_TestPlugin_API to SOFA_SOFATEST_API to make i…
damienmarchal Oct 23, 2017
7c3ae9d
[SofaTest] Remove the TestMessageHandler.cpp that is now useless.
damienmarchal Oct 23, 2017
9bb2da5
Merge remote-tracking branch 'upstream/master' into moveTestToSofaKer…
damienmarchal Nov 8, 2017
6904881
[CI] ADD: stop testing if unexpected crash occurs
guparan Nov 9, 2017
116320c
[SofaTest] remove the link with gtest that cause the tests to crash.
damienmarchal Nov 10, 2017
49b5071
[SofaFramework] Fix PluginManager_test & MeshVTKLoader_test that was …
damienmarchal Nov 10, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ list(APPEND CMAKE_MODULE_PATH "${SOFA_KERNEL_SOURCE_DIR}/SofaFramework")
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/extlibs)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/applications/plugins)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/applications/packages)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/applications/projects)

# Create etc/sofa.ini: it contains the paths to share/ and examples/. In the
Expand Down Expand Up @@ -354,6 +355,9 @@ endif()
## Plugins
add_subdirectory(applications/plugins)

## Packages
add_subdirectory(applications/packages)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damienmarchal could you explain why this folder has been created ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that for the unit tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Hugo,

Sure,

The goal of the PR is to cut the dependency between tests & core+modules. My problem was that modules are not plugins which was annoying to loose the dependency graph. So I decided to make plugin containing only the modules initialization so when you load the plugin the underlying modules get initialized properly. This is what packages/SofaAllCommonComponent is doing.

I created the folder packages to put this SofaAllCommonComponent to differentiate this from other real plugins that actually contains code.

Now, putting that in perspective I think this should and will be remove while we are moving toward the full pluginization and sofaNG re-organization.


## Applications
add_subdirectory(applications/projects)

Expand Down
6 changes: 2 additions & 4 deletions SofaKernel/framework/framework_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ set(SOURCE_FILES
core/objectmodel/BaseObjectDescription_test.cpp
core/objectmodel/DataFileName_test.cpp
core/DataEngine_test.cpp
core/TrackedData_test.cpp
defaulttype/MapMapSparseMatrixEigenUtils_test.cpp
defaulttype/MatTypes_test.cpp
defaulttype/VecTypes_test.cpp
helper/types/Color_test.cpp
helper/types/Material_test.cpp
helper/AdvancedTimer_test.cpp
helper/KdTree_test.cpp
helper/Utils_test.cpp
helper/Quater_test.cpp
Expand All @@ -30,7 +28,7 @@ set(SOURCE_FILES
helper/system/PluginManager_test.cpp
helper/system/atomic_test.cpp
helper/logging/logging_test.cpp
simulation/DefaultAnimationLoop_test.cpp
testing/TestMessageHandler_test.cpp
main.cpp
)

Expand All @@ -43,7 +41,7 @@ include_directories(${gtest_SOURCE_DIR}/include)
add_definitions("-DFRAMEWORK_TEST_RESOURCES_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/resources\"")

add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} gtest_main SofaHelper SofaCore SofaDefaultType SofaTest)
target_link_libraries(${PROJECT_NAME} gtest_main SofaHelper SofaCore SofaDefaultType)
#add_dependencies(${PROJECT_NAME} PluginA PluginB PluginC PluginD PluginE PluginF)

add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})
Expand Down
6 changes: 4 additions & 2 deletions SofaKernel/framework/framework_test/core/DataEngine_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
******************************************************************************/
#include <sofa/core/DataEngine.h>

#include <gtest/gtest.h>
#include <sofa/helper/testing/BaseTest.h>
using sofa::helper::testing::BaseTest ;


namespace sofa {

Expand Down Expand Up @@ -78,7 +80,7 @@ class TestEngine : public core::DataEngine
};


struct DataEngine_test: public ::testing::Test
struct DataEngine_test: public BaseTest
{
TestEngine engine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
******************************************************************************/
#include <sofa/core/loader/MeshLoader.h>

#include <gtest/gtest.h>
#include <sofa/helper/testing/BaseTest.h>
using sofa::helper::testing::BaseTest ;

namespace sofa {

Expand All @@ -47,7 +48,7 @@ class MeshTestLoader : public MeshLoader
*
* @author Thomas Lemaire @date 2014
*/
class MeshLoader_test : public ::testing::Test
class MeshLoader_test : public BaseTest
{
protected:
MeshLoader_test() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,25 @@
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#include <SofaSimulationCommon/init.h>
/*
* #include <SofaSimulationCommon/init.h>
using sofa::simulation::common::init ;

#include <SofaSimulationGraph/init.h>
using sofa::simulation::graph::init ;

#include <SofaComponentBase/initComponentBase.h>
using sofa::component::initComponentBase ;

#include <SofaTest/Sofa_test.h>
using sofa::Sofa_test ;
*/

#include <sofa/core/objectmodel/BaseObjectDescription.h>
using sofa::core::objectmodel::BaseObjectDescription ;

#include <SofaTest/TestMessageHandler.h>
using sofa::helper::logging::Message ;

#include <sofa/helper/testing/BaseTest.h>
using sofa::helper::testing::BaseTest ;


struct BaseObjectDescription_test: public Sofa_test<>
struct BaseObjectDescription_test: public BaseTest
{
void SetUp()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#include <SofaTest/Sofa_test.h>
using sofa::Sofa_test ;

#include <SofaTest/TestMessageHandler.h>
using sofa::helper::logging::Message ;
using sofa::helper::logging::ExpectMessage ;

#include <sofa/core/objectmodel/BaseObjectDescription.h>
using sofa::core::objectmodel::BaseObjectDescription ;

Expand All @@ -39,9 +32,12 @@ using sofa::helper::system::DataRepository ;
#include <sofa/helper/system/SetDirectory.h>
using sofa::helper::system::SetDirectory ;

#include <sofa/helper/testing/BaseTest.h>
using sofa::helper::testing::BaseTest ;

#define filename "UtilsTest.ini"

class DataFileName_test: public Sofa_test<>
class DataFileName_test: public BaseTest
{
DataFileName d_filename;
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
#include <sofa/helper/vectorData.h>
#include <sofa/core/objectmodel/DataFileName.h>

#include <gtest/gtest.h>
#include <sofa/helper/testing/BaseTest.h>
using sofa::helper::testing::BaseTest ;


namespace sofa {

Expand All @@ -33,7 +35,7 @@ using namespace core::objectmodel;
Create two datas and a link between them.
Set the value of data1 and check if the boolean is dirty of data2 is true and that the value of data2 is right.
*/
struct DataLink_test: public ::testing::Test
struct DataLink_test: public BaseTest
{
Data<int> data1;
Data<int> data2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@

#include <sofa/defaulttype/Quat.h>

/// Beuaark
#include "../../../applications/plugins/SofaTest/Sofa_test.h"
#include <sofa/helper/testing/NumericTest.h>
using namespace sofa::helper::testing ;

#include <gtest/gtest.h>

using namespace sofa;
using namespace sofa::helper;
Expand Down
7 changes: 4 additions & 3 deletions SofaKernel/framework/framework_test/helper/KdTree_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#include <limits>
#include <sofa/helper/kdTree.h>

#include <sofa/defaulttype/VecTypes.h>
#include <sofa/helper/random.h>

#include <gtest/gtest.h>
#include <sofa/helper/testing/BaseTest.h>
using sofa::helper::testing::BaseTest ;

#include <limits>

namespace sofa {

Expand All @@ -36,7 +37,7 @@ namespace sofa {
* @date 2014
*/

struct KdTreeTest: public ::testing::Test
struct KdTreeTest: public BaseTest
{
typedef SReal Real;
typedef defaulttype::Vec<3,Real> Coord;
Expand Down
1 change: 0 additions & 1 deletion SofaKernel/framework/framework_test/helper/Utils_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <gtest/gtest.h>

#include <sofa/helper/system/FileSystem.h>
#include <SofaTest/TestMessageHandler.h>

using sofa::helper::Utils;
using sofa::helper::system::FileSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@
#include <sofa/helper/io/MeshOBJ.h>
#include <sofa/helper/system/FileRepository.h>

#include <gtest/gtest.h>

#include <SofaTest/TestMessageHandler.h>
using sofa::helper::logging::Message;
#include <sofa/helper/testing/BaseTest.h>
using sofa::helper::testing::BaseTest ;

namespace sofa {

using namespace core::loader;

class MeshOBJ_test : public ::testing::Test
class MeshOBJ_test : public BaseTest
{
protected:
void SetUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
#include <sofa/helper/system/FileRepository.h>
#include <sofa/helper/io/MeshSTL.h>

#include <gtest/gtest.h>
#include <sofa/helper/testing/BaseTest.h>
using sofa::helper::testing::BaseTest ;

#include <SofaTest/TestMessageHandler.h>
using sofa::helper::logging::Message;

namespace sofa {

class MeshSTL_test : public ::testing::Test
class MeshSTL_test : public BaseTest
{
protected:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
#include <gtest/gtest.h>
#include <exception>
#include <algorithm>
#include <SofaTest/TestMessageHandler.h>
using sofa::helper::logging::Message;
#include <sofa/helper/testing/BaseTest.h>
using sofa::helper::testing::BaseTest ;



using sofa::helper::system::FileSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
#include <sofa/helper/system/FileRepository.h>
#include <sofa/helper/system/FileSystem.h>
#include <sofa/helper/Utils.h>
#include <gtest/gtest.h>
#include <SofaTest/TestMessageHandler.h>

#include <sofa/helper/testing/BaseTest.h>
using sofa::helper::testing::BaseTest ;

#include <fstream>

Expand All @@ -51,7 +52,7 @@ const std::string separator = "/";
const std::string prefix = "lib";
#endif // WIN32

struct PluginManager_test: public ::testing::Test
struct PluginManager_test: public BaseTest
{
std::string pluginDir;

Expand Down Expand Up @@ -86,27 +87,52 @@ TEST_F(PluginManager_test, loadTestPluginByPath)
std::string pluginPath = pluginDir + separator + prefix + pluginFileName + dotExt;
std::string nonpluginPath = pluginDir + separator + prefix + nonpluginName + dotExt;

std::cout << pm.getPluginMap().size() << std::endl;
ASSERT_TRUE(pm.loadPluginByPath(pluginPath));
std::cout << pm.getPluginMap().size() << std::endl;
ASSERT_FALSE(pm.loadPluginByPath(nonpluginPath));
std::cout << pm.getPluginMap().size() << std::endl;
/// Check that existing plugins are correctly handled and returns no
/// error/warning message.
{
EXPECT_MSG_NOEMIT(Warning, Error) ;

std::cout << pm.getPluginMap().size() << std::endl;
ASSERT_TRUE(pm.loadPluginByPath(pluginPath));
ASSERT_GT(pm.findPlugin(pluginName).size(), 0u);
}

ASSERT_GT(pm.findPlugin(pluginName).size(), 0u);
ASSERT_EQ(pm.findPlugin(nonpluginName).size(), 0u);
/// Check that non existing plugin are currectly handled and returns an
/// error message.
{
EXPECT_MSG_NOEMIT(Warning) ;
EXPECT_MSG_EMIT(Error) ;

std::cout << pm.getPluginMap().size() << std::endl;
ASSERT_FALSE(pm.loadPluginByPath(nonpluginPath));
ASSERT_EQ(pm.findPlugin(nonpluginName).size(), 0u);
std::cout << pm.getPluginMap().size() << std::endl;
}
}

TEST_F(PluginManager_test, loadTestPluginByName )
{
PluginManager&pm = PluginManager::getInstance();

ASSERT_TRUE(pm.loadPluginByName(pluginName) );
ASSERT_FALSE(pm.loadPluginByName(nonpluginName));
/// Check that existing plugins are correctly handled and returns no
/// error/warning message.
{
EXPECT_MSG_NOEMIT(Warning, Error) ;

ASSERT_TRUE(pm.loadPluginByName(pluginName) );
std::string pluginPath = pm.findPlugin(pluginName);
ASSERT_GT(pluginPath.size(), 0u);
}

std::string pluginPath = pm.findPlugin(pluginName);
ASSERT_GT(pluginPath.size(), 0u);
ASSERT_EQ(pm.findPlugin(nonpluginName).size(), 0u);
/// Check that non existing plugin are currectly handled and returns an
/// error message.
{
EXPECT_MSG_NOEMIT(Warning) ;
EXPECT_MSG_EMIT(Error) ;
ASSERT_FALSE(pm.loadPluginByName(nonpluginName));

ASSERT_EQ(pm.findPlugin(nonpluginName).size(), 0u);
}
}

TEST_F(PluginManager_test, pluginEntries)
Expand Down
Loading