jp-embedded / scxmlcc

The SCXML state machine to C++ compiler
GNU General Public License v3.0
138 stars 34 forks source link

Thread safe unit tests broken? #75

Open sstiller opened 5 years ago

sstiller commented 5 years ago

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

jp-embedded commented 5 years ago

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 commented 5 years ago

fixed in commit 857f255d2156a9fefe89c1aadc07fc1b8c234f22

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

sstiller commented 5 years ago

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?

jp-embedded commented 5 years ago

You are right, I missed that.