Skip to content

Commit

Permalink
Merge pull request highperformancecoder#208 from ChinouneMehdi/build_…
Browse files Browse the repository at this point in the history
…tests

Rename cmake option for tests
  • Loading branch information
highperformancecoder authored Feb 8, 2021
2 parents 4f373fa + 42c6bcd commit 19f4d8c
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 86 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ jobs:
- name: Configuring
run: |
mkdir build && cd build
cmake .. -DSEARCH_FOR_UPDATES=OFF -DDOWNLOAD_LINKS=OFF -DORIGIN_IMPORT=ON -DSCRIPTING_PYTHON=ON
cmake .. -DSEARCH_FOR_UPDATES=OFF -DDOWNLOAD_LINKS=OFF -DORIGIN_IMPORT=ON -DSCRIPTING_PYTHON=ON \
-DBUILD_TESTS=ON
- name: Building
run: |
Expand Down Expand Up @@ -113,7 +114,7 @@ jobs:
run: |
mkdir build; cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}\scripts\buildsystems\vcpkg.cmake `
-DORIGIN_IMPORT=ON -DSCRIPTING_PYTHON=${{ matrix.python }}
-DORIGIN_IMPORT=ON -DSCRIPTING_PYTHON=${{ matrix.python }} -DBUILD_TESTS=ON
- name: Building
run: |
Expand Down Expand Up @@ -160,7 +161,7 @@ jobs:
- name: Configuring
run: |
mkdir build && cd build
cmake .. -G"MSYS Makefiles" -DORIGIN_IMPORT=ON -DSCRIPTING_PYTHON=ON
cmake .. -G"MSYS Makefiles" -DORIGIN_IMPORT=ON -DSCRIPTING_PYTHON=ON -DBUILD_TESTS=ON
- name: Building
run: |
Expand Down Expand Up @@ -203,7 +204,8 @@ jobs:
- name: Configuring
run: |
mkdir build && cd build
cmake .. -DORIGIN_IMPORT=ON -DSCRIPTING_PYTHON=ON -DPython3_ROOT_DIR=$pythonLocation
cmake .. -DORIGIN_IMPORT=ON -DSCRIPTING_PYTHON=ON -DPython3_ROOT_DIR=$pythonLocation \
-DBUILD_TESTS=ON
- name: Building
run: |
Expand Down
11 changes: 5 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ option( SCRIPTING_MUPARSER "Enable muParser Scripting" ON )

option( SCRIPTING_PYTHON "Enable Python Scripting" OFF )

option( ENABLE_Testing "Enable testing" ON )
option( BUILD_TESTS "Build tests" OFF )

if( SCRIPTING_PYTHON )
if( MINGW )
Expand All @@ -103,10 +103,6 @@ if( SCRIPTING_PYTHON )
find_package( PyQt REQUIRED )
endif()

if( ENABLE_Testing )
enable_testing()
endif()

option( ORIGIN_IMPORT "Enable importing OriginLab project files" OFF )

# GSL
Expand Down Expand Up @@ -137,7 +133,10 @@ add_subdirectory( scidavis )

add_subdirectory( fitPlugins )

add_subdirectory( test )
if( BUILD_TESTS )
enable_testing()
add_subdirectory( test )
endif()

# Documentation
set( DOC_FILES
Expand Down
143 changes: 67 additions & 76 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,97 +1,88 @@
if( ENABLE_Testing )

message( STATUS "Testing enabled" )

set( CMAKE_AUTOMOC OFF )
set( CMAKE_AUTOUIC OFF )
set( CMAKE_AUTORCC OFF )

set( SRCS
"main.cpp"
"applicationWindow.cpp"
"readWriteProject.cpp"
"fft.cpp"
"menus.cpp"
"arrowMarker.cpp"
set( CMAKE_AUTOMOC OFF )
set( CMAKE_AUTOUIC OFF )
set( CMAKE_AUTORCC OFF )

set( SRCS
"main.cpp"
"applicationWindow.cpp"
"readWriteProject.cpp"
"fft.cpp"
"menus.cpp"
"arrowMarker.cpp"
)
if( NOT WIN32 )
list( APPEND SRCS
"testPaintDevice.cpp"
"3dplot.cpp"
)
if( NOT WIN32 )
list( APPEND SRCS
"testPaintDevice.cpp"
"3dplot.cpp"
)
endif()
endif()

add_executable( unittest ${SRCS} )
add_executable( unittest ${SRCS} )

find_package( GTest REQUIRED )

target_link_libraries( unittest libscidavis GTest::GTest )

if( NOT WIN32 )
target_link_libraries( unittest pthread )
endif()
find_package( GTest REQUIRED )

if( ORIGIN_IMPORT )
target_compile_definitions( unittest PRIVATE ORIGIN_IMPORT )
endif()
target_link_libraries( unittest libscidavis GTest::GTest )

if( MULTI_CONFIG )
target_include_directories( unittest PRIVATE
"${CMAKE_BINARY_DIR}/libscidavis/libscidavis_autogen/include_$<CONFIG>"
)
else()
target_include_directories( unittest PRIVATE
"${CMAKE_BINARY_DIR}/libscidavis/libscidavis_autogen/include"
)
endif()
if( NOT WIN32 )
target_link_libraries( unittest pthread )
endif()

include(GoogleTest)
gtest_discover_tests( unittest )
if( ORIGIN_IMPORT )
target_compile_definitions( unittest PRIVATE ORIGIN_IMPORT )
endif()

set( TestDataFiles
"3dplot.sciprj"
"3dplotTable.sciprj"
"testProject.sciprj"
"Histo.opj"
"USstates.opj"
if( MULTI_CONFIG )
target_include_directories( unittest PRIVATE
"${CMAKE_BINARY_DIR}/libscidavis/libscidavis_autogen/include_$<CONFIG>"
)
else()
target_include_directories( unittest PRIVATE
"${CMAKE_BINARY_DIR}/libscidavis/libscidavis_autogen/include"
)
file( COPY ${TestDataFiles} DESTINATION . )
endif()

if( NOT (SEARCH_FOR_UPDATES OR DOWNLOAD_LINKS) )
include(GoogleTest)
gtest_discover_tests( unittest DISCOVERY_MODE PRE_TEST )

set( menu_files defaultMenus_en.menudat appWithGraphen.menudat )
set( TestDataFiles
"3dplot.sciprj"
"3dplotTable.sciprj"
"testProject.sciprj"
"Histo.opj"
"USstates.opj"
)
file( COPY ${TestDataFiles} DESTINATION . )

foreach( menu ${menu_files} )
get_filename_component( test_name ${menu} NAME_WLE )
add_test( NAME menuData_${test_name} COMMAND diff -q ${menu} ${CMAKE_CURRENT_SOURCE_DIR}/menuData/${menu} )
set_tests_properties( menuData_${test_name} PROPERTIES DEPENDS unittest )
endforeach()
if( NOT (SEARCH_FOR_UPDATES OR DOWNLOAD_LINKS) )

endif()
set( menu_files defaultMenus_en.menudat appWithGraphen.menudat )

if( SCRIPTING_PYTHON )
foreach( menu ${menu_files} )
get_filename_component( test_name ${menu} NAME_WLE )
add_test( NAME menuData_${test_name} COMMAND diff -q ${menu} ${CMAKE_CURRENT_SOURCE_DIR}/menuData/${menu} )
set_tests_properties( menuData_${test_name} PROPERTIES DEPENDS unittest )
endforeach()

file( COPY pythonTests/ DESTINATION ./tmp )
file( COPY ../scidavis-logo.png DESTINATION ./tmp )
endif()

file( GLOB pythonTests pythonTests/*.py )
# qwtPlotCurve segfault with sip5 or macos
if( SIP_VERSION VERSION_GREATER_EQUAL 5 OR APPLE )
list( REMOVE_ITEM pythonTests ${CMAKE_CURRENT_SOURCE_DIR}/pythonTests/qwtPlotCurve.py )
endif()
if( SCRIPTING_PYTHON )

foreach( pythonTest ${pythonTests} )
get_filename_component( test_name ${pythonTest} NAME_WLE )
add_test( NAME python_${test_name}
COMMAND scidavis -l=en -x ${pythonTest}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tmp
)
endforeach()
file( COPY pythonTests/ DESTINATION ./tmp )
file( COPY ../scidavis-logo.png DESTINATION ./tmp )

file( GLOB pythonTests pythonTests/*.py )
# qwtPlotCurve segfault with sip5 or macos
if( SIP_VERSION VERSION_GREATER_EQUAL 5 OR APPLE )
list( REMOVE_ITEM pythonTests ${CMAKE_CURRENT_SOURCE_DIR}/pythonTests/qwtPlotCurve.py )
endif()

else( ENABLE_Testing )

message( STATUS "Testing not enabled" )
foreach( pythonTest ${pythonTests} )
get_filename_component( test_name ${pythonTest} NAME_WLE )
add_test( NAME python_${test_name}
COMMAND scidavis -l=en -x ${pythonTest}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tmp
)
endforeach()

endif( ENABLE_Testing )
endif()

0 comments on commit 19f4d8c

Please sign in to comment.