scxmlcc icon indicating copy to clipboard operation
scxmlcc copied to clipboard

Thread safe unit tests broken?

Open sstiller opened this issue 6 years ago • 4 comments

Is there really a way to run these tests, or are they broken?

sstiller avatar Oct 26 '18 13:10 sstiller

They should be run automatically - if you have C++17

But I see that the unit test makefile enables only C++11, so they have probably not been run for a while.

I will have a look into this. All the tests should be run by default

jp-embedded avatar Oct 29 '18 10:10 jp-embedded

fixed in commit 857f255d2156a9fefe89c1aadc07fc1b8c234f22

thread safe tests are now run - if you have c++17

jp-embedded avatar Oct 30 '18 22:10 jp-embedded

I think, this issue should be re-opened.

I tried to build the tests with with cmake.

With cmake, the *_t.h files are not generated and C++17 is not used.

C++17 is easy to enable:

diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
index 51d6467..20ae15e 100644
--- a/src/test/CMakeLists.txt
+++ b/src/test/CMakeLists.txt
@@ -7,7 +7,14 @@ add_subdirectory(gtest)
 enable_testing()
 
 set( CMAKE_INCLUDE_CURRENT_DIR ON )
-set( CMAKE_CXX_STANDARD 11 ) 
+
+include(CheckCXXCompilerFlag)
+check_cxx_compiler_flag("-std=c++17" CXX17_SUPPORTED)
+if(CXX17_SUPPORTED)
+  set(CMAKE_CXX_STANDARD 17) 
+else()
+  set(CMAKE_CXX_STANDARD 11)
+endif()
 
 #generate  txml->scxml->headers
 include( scxmlcc_generator )

Generating the *_t.h files should also be no problem, but I have no experience with cmake and I don't want to do something ugly to fix it. Perhaps someone else can do it?

sstiller avatar Nov 02 '18 08:11 sstiller

You are right, I missed that.

jp-embedded avatar Nov 02 '18 09:11 jp-embedded