Skip to content

Commit

Permalink
Re #5767. Move creation of unit test targets into new CMakeLists
Browse files Browse the repository at this point in the history
...in test directory. This means that any include paths needed for
the unit tests are not also added to the main library build command.

The unit test files are still declared in the same place so that
people only need to edit one file when adding a class.
  • Loading branch information
RussellTaylor committed Aug 16, 2012
1 parent cb2d95b commit 86d69df
Show file tree
Hide file tree
Showing 31 changed files with 1,067 additions and 1,039 deletions.
4 changes: 2 additions & 2 deletions Code/Mantid/Build/cmakelists_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def add_to_cmake(subproject, classname, args, subfolder):
if args.cpp:
lines = redo_cmake_section(lines, "SRC_FILES", "src/" + subfolder + classname + ".cpp")
if args.test:
lines = redo_cmake_section(lines, "TEST_FILES", "test/" + classname + "Test.h")
lines = redo_cmake_section(lines, "TEST_FILES", classname + "Test.h")

f = open(cmake_path, 'w')
text = "\n".join(lines)
Expand All @@ -159,7 +159,7 @@ def remove_from_cmake(subproject, classname, args, subfolder):
if args.cpp:
lines = redo_cmake_section(lines, "SRC_FILES", "", "src/" + subfolder + classname + ".cpp")
if args.test:
lines = redo_cmake_section(lines, "TEST_FILES", "", "test/" + classname + "Test.h")
lines = redo_cmake_section(lines, "TEST_FILES", "", classname + "Test.h")

f = open(cmake_path, 'w')
text = "\n".join(lines)
Expand Down
147 changes: 67 additions & 80 deletions Code/Mantid/Framework/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,74 +240,74 @@ set ( INC_FILES
)

set ( TEST_FILES
test/AlgorithmHasPropertyTest.h
test/AlgorithmHistoryTest.h
test/AlgorithmManagerTest.h
test/AlgorithmPropertyTest.h
test/AlgorithmProxyTest.h
test/AlgorithmTest.h
test/AnalysisDataServiceTest.h
test/AsynchronousTest.h
test/BoxControllerTest.h
test/CompositeFunctionTest.h
test/CoordTransformTest.h
test/CostFunctionFactoryTest.h
test/DataProcessorAlgorithmTest.h
test/EnabledWhenWorkspaceIsTypeTest.h
test/ExperimentInfoTest.h
test/ExpressionTest.h
test/FermiChopperModelTest.h
test/FileFinderTest.h
test/FilePropertyTest.h
test/FrameworkManagerTest.h
test/FunctionDomainTest.h
test/FunctionFactoryTest.h
test/FunctionPropertyTest.h
test/FunctionTest.h
test/FunctionValuesTest.h
test/IEventListTest.h
test/IFunction1DTest.h
test/IFunctionMDTest.h
test/ILiveListenerTest.h
test/IMDWorkspaceTest.h
test/ISpectrumTest.h
test/IkedaCarpenterModeratorTest.h
test/ImmutableCompositeFunctionTest.h
test/ImplicitFunctionParserFactoryTest.h
test/InstrumentDataServiceTest.h
test/LiveListenerFactoryTest.h
test/MDGeometryTest.h
test/MatrixWorkspaceMDIteratorTest.h
test/MemoryManagerTest.h
test/ModeratorModelTest.h
test/MultiDomainFunctionTest.h
test/MultipleExperimentInfosTest.h
test/MultipleFilePropertyTest.h
test/MultiPeriodGroupAlgorithmTest.h
test/NumericAxisTest.h
test/ParamFunctionAttributeHolderTest.h
test/ParameterReferenceTest.h
test/ParameterTieTest.h
test/PropertyManagerDataServiceTest.h
test/PropertyNexusTest.h
test/RunTest.h
test/SampleEnvironmentTest.h
test/SampleTest.h
test/SpectraAxisTest.h
test/SpectraDetectorMapTest.h
test/TextAxisTest.h
test/VectorParameterParserTest.h
test/VectorParameterTest.h
test/WorkspaceFactoryTest.h
test/WorkspaceGroupTest.h
test/WorkspaceHistoryTest.h
test/WorkspacePropertyTest.h
AlgorithmHasPropertyTest.h
AlgorithmHistoryTest.h
AlgorithmManagerTest.h
AlgorithmPropertyTest.h
AlgorithmProxyTest.h
AlgorithmTest.h
AnalysisDataServiceTest.h
AsynchronousTest.h
BoxControllerTest.h
CompositeFunctionTest.h
CoordTransformTest.h
CostFunctionFactoryTest.h
DataProcessorAlgorithmTest.h
EnabledWhenWorkspaceIsTypeTest.h
ExperimentInfoTest.h
ExpressionTest.h
FermiChopperModelTest.h
FileFinderTest.h
FilePropertyTest.h
FrameworkManagerTest.h
FunctionDomainTest.h
FunctionFactoryTest.h
FunctionPropertyTest.h
FunctionTest.h
FunctionValuesTest.h
IEventListTest.h
IFunction1DTest.h
IFunctionMDTest.h
ILiveListenerTest.h
IMDWorkspaceTest.h
ISpectrumTest.h
IkedaCarpenterModeratorTest.h
ImmutableCompositeFunctionTest.h
ImplicitFunctionParserFactoryTest.h
InstrumentDataServiceTest.h
LiveListenerFactoryTest.h
MDGeometryTest.h
MatrixWorkspaceMDIteratorTest.h
MemoryManagerTest.h
ModeratorModelTest.h
MultiDomainFunctionTest.h
MultipleExperimentInfosTest.h
MultipleFilePropertyTest.h
MultiPeriodGroupAlgorithmTest.h
NumericAxisTest.h
ParamFunctionAttributeHolderTest.h
ParameterReferenceTest.h
ParameterTieTest.h
PropertyManagerDataServiceTest.h
PropertyNexusTest.h
RunTest.h
SampleEnvironmentTest.h
SampleTest.h
SpectraAxisTest.h
SpectraDetectorMapTest.h
TextAxisTest.h
VectorParameterParserTest.h
VectorParameterTest.h
WorkspaceFactoryTest.h
WorkspaceGroupTest.h
WorkspaceHistoryTest.h
WorkspacePropertyTest.h
)

set ( GMOCK_TEST_FILES
test/ImplicitFunctionFactoryTest.h
test/ImplicitFunctionParameterParserFactoryTest.h
test/MatrixWorkspaceTest.h
ImplicitFunctionFactoryTest.h
ImplicitFunctionParameterParserFactoryTest.h
MatrixWorkspaceTest.h
)


Expand All @@ -333,21 +333,8 @@ set_property ( TARGET API PROPERTY FOLDER "MantidFramework" )

target_link_libraries ( API ${MANTIDLIBS} ${WINSOCK} )

if ( CXXTEST_FOUND )
include_directories ( ../TestHelpers/inc )
set ( TESTHELPER_SRCS ../TestHelpers/src/ComponentCreationHelper.cpp )

if ( GMOCK_FOUND AND GTEST_FOUND )
cxxtest_add_test ( APITest ${TEST_FILES} ${GMOCK_TEST_FILES})
target_link_libraries( APITest API ${GMOCK_LIBRARIES} ${GTEST_LIBRARIES} )
else ()
cxxtest_add_test ( APITest ${TEST_FILES} )
target_link_libraries( APITest API )
endif()
add_dependencies ( FrameworkTests APITest )
# Add to the 'FrameworkTests' group in VS
set_property ( TARGET APITest PROPERTY FOLDER "UnitTests" )
endif ()
# Add the unit tests directory
add_subdirectory ( test )

###########################################################################
# Installation settings
Expand Down
17 changes: 17 additions & 0 deletions Code/Mantid/Framework/API/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
if ( CXXTEST_FOUND )
include_directories ( ../../TestHelpers/inc )
# This variable is used within the cxxtest_add_test macro to build these helper classes into the test executable.
# It will go out of scope at the end of this file so doesn't need un-setting
set ( TESTHELPER_SRCS ../../TestHelpers/src/ComponentCreationHelper.cpp )

if ( GMOCK_FOUND AND GTEST_FOUND )
cxxtest_add_test ( APITest ${TEST_FILES} ${GMOCK_TEST_FILES})
target_link_libraries( APITest API ${GMOCK_LIBRARIES} ${GTEST_LIBRARIES} )
else ()
cxxtest_add_test ( APITest ${TEST_FILES} )
target_link_libraries( APITest API )
endif()
add_dependencies ( FrameworkTests APITest )
# Add to the 'FrameworkTests' group in VS
set_property ( TARGET APITest PROPERTY FOLDER "UnitTests" )
endif ()

0 comments on commit 86d69df

Please sign in to comment.