From 4507460c797abca635deb7d35e849f2591ad7a07 Mon Sep 17 00:00:00 2001 From: David Rowland Date: Mon, 20 May 2024 15:39:20 +0100 Subject: [PATCH] Added support for passing/failing tests --- tests/CMakeLists.txt | 7 +++++-- ...{test_file_size.cpp => fail_file_size.cpp} | 0 tests/{test_free.cpp => fail_free.cpp} | 0 ...e_function.cpp => fail_large_function.cpp} | 0 tests/{test_malloc.cpp => fail_malloc.cpp} | 0 ...{test_read_file.cpp => fail_read_file.cpp} | 0 tests/{test_vector.cpp => fail_vector.cpp} | 0 tests/pass_small_function.cpp | 16 ++++++++++++++ tests/test_small_function.cpp | 21 ------------------- 9 files changed, 21 insertions(+), 23 deletions(-) rename tests/{test_file_size.cpp => fail_file_size.cpp} (100%) rename tests/{test_free.cpp => fail_free.cpp} (100%) rename tests/{test_large_function.cpp => fail_large_function.cpp} (100%) rename tests/{test_malloc.cpp => fail_malloc.cpp} (100%) rename tests/{test_read_file.cpp => fail_read_file.cpp} (100%) rename tests/{test_vector.cpp => fail_vector.cpp} (100%) create mode 100644 tests/pass_small_function.cpp delete mode 100644 tests/test_small_function.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 98fb409..82873d1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) #====================================== message(CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}) -file(GLOB test_files LIST_DIRECTORIES false "${CMAKE_CURRENT_SOURCE_DIR}" test_*.cpp) +file(GLOB test_files LIST_DIRECTORIES false "${CMAKE_CURRENT_SOURCE_DIR}" pass_*.cpp fail_*.cpp) message(test_files: ${test_files}) #====================================== @@ -28,7 +28,10 @@ foreach(file ${test_files}) ) add_test (NAME ${test_name} COMMAND ${test_name}) - set_property(TEST ${test_name} PROPERTY WILL_FAIL TRUE) + + if(${test_name} MATCHES "fail") + set_property(TEST ${test_name} PROPERTY WILL_FAIL TRUE) + endif() endforeach() diff --git a/tests/test_file_size.cpp b/tests/fail_file_size.cpp similarity index 100% rename from tests/test_file_size.cpp rename to tests/fail_file_size.cpp diff --git a/tests/test_free.cpp b/tests/fail_free.cpp similarity index 100% rename from tests/test_free.cpp rename to tests/fail_free.cpp diff --git a/tests/test_large_function.cpp b/tests/fail_large_function.cpp similarity index 100% rename from tests/test_large_function.cpp rename to tests/fail_large_function.cpp diff --git a/tests/test_malloc.cpp b/tests/fail_malloc.cpp similarity index 100% rename from tests/test_malloc.cpp rename to tests/fail_malloc.cpp diff --git a/tests/test_read_file.cpp b/tests/fail_read_file.cpp similarity index 100% rename from tests/test_read_file.cpp rename to tests/fail_read_file.cpp diff --git a/tests/test_vector.cpp b/tests/fail_vector.cpp similarity index 100% rename from tests/test_vector.cpp rename to tests/fail_vector.cpp diff --git a/tests/pass_small_function.cpp b/tests/pass_small_function.cpp new file mode 100644 index 0000000..30ff1f1 --- /dev/null +++ b/tests/pass_small_function.cpp @@ -0,0 +1,16 @@ +#include +#include + +struct doubles +{ + double d[2]; +}; + +int main() +{ + realtime_context rc; + doubles d; + std::function fn = [d] { }; + + return 0; +} diff --git a/tests/test_small_function.cpp b/tests/test_small_function.cpp deleted file mode 100644 index 893be1a..0000000 --- a/tests/test_small_function.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -struct doubles -{ - double d[2]; -}; - -int main() -{ - std::function fn; - - { - realtime_context rc; - doubles d; - std::function fn = [d] { }; - - } - - return 0; -}