Skip to content

Commit

Permalink
Upgrade to a newer version of Catch using FetchContent
Browse files Browse the repository at this point in the history
  • Loading branch information
TrentHouliston committed Jul 14, 2024
1 parent 964efc8 commit ae944aa
Show file tree
Hide file tree
Showing 52 changed files with 122 additions and 262 deletions.
29 changes: 0 additions & 29 deletions cmake/Modules/FindCATCH.cmake

This file was deleted.

93 changes: 0 additions & 93 deletions cmake/Modules/HeaderLibrary.cmake

This file was deleted.

8 changes: 4 additions & 4 deletions src/dsl/store/TypeCallbackStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ namespace dsl {
namespace store {

/**
* @biref The main callback store for reactions that are executed when a paticular type is emitted.
* @brief The main callback store for reactions that are executed when a particular type is emitted.
*
* @details This store is the main location that callbacks that are executed on type are stored.
* This method of storing is how the system realises compile time message dispatch. By storing each
* differnt type of message user in its own location the system knows exactly which reactions to
* execuing without having to do an expensive lookup. This reduces the latency and computational
* power invovled in spawning a new reaction when a type is emitted.
* different type of message user in its own location the system knows exactly which reactions to
* executing without having to do an expensive lookup. This reduces the latency and computational
* power involved in spawning a new reaction when a type is emitted.
*
* @tparam TriggeringType the type that when emitted will start this function
*/
Expand Down
120 changes: 62 additions & 58 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,61 +20,65 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER I
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
]]

find_package(CATCH)

if(CATCH_FOUND)
# Supported options:
option(BUILD_TESTS "Builds all of the NUClear unit tests." TRUE)

if(BUILD_TESTS)
enable_testing()

add_compile_definitions(CATCH_CONFIG_CONSOLE_WIDTH=120)

file(
GLOB
test_src
test.cpp
"api/*.cpp"
"dsl/*.cpp"
"dsl/emit/*.cpp"
"log/*.cpp"
"util/*.cpp"
"util/network/*.cpp"
"util/serialise/*.cpp"
)

file(GLOB test_util_src "test_util/*.cpp")
add_library(test_util STATIC ${test_util_src})
target_link_libraries(test_util PUBLIC NUClear::nuclear)
target_include_directories(
test_util SYSTEM PUBLIC ${CATCH_INCLUDE_DIRS} ${PROJECT_BINARY_DIR}/include "${PROJECT_SOURCE_DIR}/src"
)

# Some tests must be executed as individual binaries
file(GLOB individual_tests "${CMAKE_CURRENT_SOURCE_DIR}/individual/*.cpp")

foreach(test_src ${individual_tests})
get_filename_component(test_name ${test_src} NAME_WE)

add_executable(${test_name} ${test_src})
target_link_libraries(${test_name} NUClear::nuclear test_util)
set_target_properties(${test_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/individual")
target_include_directories(${test_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
# Enable warnings, and all warnings are errors

add_test(${test_name} test_nuclear)

endforeach(test_src)

add_executable(test_nuclear ${test_src})
target_include_directories(test_nuclear PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(test_nuclear NUClear::nuclear test_util)
add_test(test_nuclear test_nuclear)

add_executable(test_network networktest.cpp)
target_link_libraries(test_network NUClear::nuclear test_util)
target_include_directories(test_network PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

endif(BUILD_TESTS)
endif(CATCH_FOUND)
option(BUILD_TESTS "Builds all of the NUClear unit tests." TRUE)

if(BUILD_TESTS)
# Get catch2 using FetchContent
include(FetchContent)
FetchContent_Declare(
Catch2
GIT_SHALLOW TRUE
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.6.0
)
FetchContent_MakeAvailable(Catch2)

enable_testing()

file(
GLOB
test_src
test.cpp
"api/*.cpp"
"dsl/*.cpp"
"dsl/emit/*.cpp"
"log/*.cpp"
"util/*.cpp"
"util/network/*.cpp"
"util/serialise/*.cpp"
)

# Create a test_util library that is used by all tests
file(GLOB test_util_src "test_util/*.cpp")
add_library(test_util STATIC ${test_util_src})
target_link_libraries(test_util PUBLIC NUClear::nuclear)
target_include_directories(
test_util SYSTEM PUBLIC ${CATCH_INCLUDE_DIRS} ${PROJECT_BINARY_DIR}/include "${PROJECT_SOURCE_DIR}/src"
)

# Some tests must be executed as individual binaries
file(GLOB individual_tests "${CMAKE_CURRENT_SOURCE_DIR}/individual/*.cpp")

foreach(test_src ${individual_tests})
get_filename_component(test_name ${test_src} NAME_WE)

add_executable(${test_name} ${test_src})
target_link_libraries(${test_name} PRIVATE test_util)
target_link_libraries(${test_name} PRIVATE Catch2::Catch2WithMain)
set_target_properties(${test_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/individual")
target_include_directories(${test_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_test(${test_name} test_nuclear)
endforeach(test_src)

add_executable(test_nuclear ${test_src})
target_include_directories(test_nuclear PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(test_nuclear test_util)
target_link_libraries(test_nuclear Catch2::Catch2WithMain)
add_test(test_nuclear test_nuclear)

# Special test binary for testing NUClearNet
add_executable(test_network networktest.cpp)
target_link_libraries(test_network test_util)
target_include_directories(test_network PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

endif(BUILD_TESTS)
2 changes: 1 addition & 1 deletion tests/api/ReactionHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <nuclear>

#include "test_util/TestBase.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/api/ReactionStatistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <nuclear>

#include "test_util/TestBase.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/api/ReactorArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <nuclear>

// Anonymous namespace to keep everything file local
Expand Down
2 changes: 1 addition & 1 deletion tests/dsl/Always.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <nuclear>

#include "test_util/TestBase.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/dsl/ArgumentFission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <nuclear>
#include <utility>

Expand Down
2 changes: 1 addition & 1 deletion tests/dsl/BlockNoData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <nuclear>

#include "test_util/TestBase.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/dsl/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <nuclear>

#include "test_util/TestBase.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/dsl/CommandLineArguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <nuclear>
#include <sstream>

Expand Down
2 changes: 1 addition & 1 deletion tests/dsl/CustomGet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <nuclear>

#include "test_util/TestBase.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/dsl/DSLOrdering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <nuclear>

#include "test_util/TestBase.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/dsl/DSLProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <nuclear>

#include "test_util/TestBase.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/dsl/Every.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <nuclear>
#include <numeric>

Expand Down
2 changes: 1 addition & 1 deletion tests/dsl/FlagMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <nuclear>

#include "test_util/TestBase.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/dsl/FusionInOrder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <nuclear>

namespace {
Expand Down
Loading

0 comments on commit ae944aa

Please sign in to comment.