]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
build, tests: introduce compiletest_cxx11_client for C++11 conformity. 25395/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 4 Dec 2018 09:21:26 +0000 (10:21 +0100)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 17 Dec 2018 17:28:47 +0000 (18:28 +0100)
This patch extends the usual pull request workflow with extra stage:
validation of the C++11 compliance of the public headers (currently
`buffers.h` only; I would love to have this broader) on `make check`.
The idea is to let the bots to detect breaking the language part of
our public API early, and thus off-load reviewers and Teuthology.

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/CMakeLists.txt
src/test/CMakeLists.txt
src/test/cxx11_client.cc [new file with mode: 0644]

index d90dc294b8901e43941c1f9f1710692d788eff3b..7ad3af5be4773f4bd2b06ae83990a2239e61c07d 100644 (file)
@@ -111,6 +111,14 @@ if(CMAKE_VERSION VERSION_LESS "3.8")
       "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support.")
   endif()
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
+
+  # for compiletest_cxx11_client
+  CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+  if(NOT COMPILER_SUPPORTS_CXX11)
+    message(FATAL_ERROR
+      "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
+  endif()
+
   include(CheckCCompilerFlag)
   CHECK_C_COMPILER_FLAG("-std=gnu99" COMPILER_SUPPORTS_GNU99)
   if(NOT COMPILER_SUPPORTS_GNU99)
index 1e47535e984074d4d9a66a0933611d0013960b6c..55b60a6ee72f2051f1b6093ea54ad351b0302b70 100644 (file)
@@ -678,6 +678,28 @@ add_executable(unittest_bufferlist
 add_ceph_unittest(unittest_bufferlist)
 target_link_libraries(unittest_bufferlist global)
 
+# compiletest_cxx11_client
+add_executable(compiletest_cxx11_client
+  cxx11_client.cc
+  )
+if(CMAKE_VERSION VERSION_LESS "3.8")
+  # this is ugly as we'll end with -std=c++11 overriding the previous -std=c++17
+  # I would love to have a better way for old Cmakes
+  set_target_properties(compiletest_cxx11_client
+    PROPERTIES COMPILE_FLAGS "-std=c++11 -Werror -pedantic"
+    )
+else()
+  set_target_properties(compiletest_cxx11_client
+    PROPERTIES COMPILE_FLAGS "-Werror -pedantic"
+    CMAKE_CXX_STANDARD 11
+    CXX_STANDARD_REQUIRED ON
+    )
+endif()
+add_ceph_test(compiletest_cxx11_client
+  "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/compiletest_cxx11_client"
+  )
+target_link_libraries(compiletest_cxx11_client global)
+
 # unittest_xlist
 add_executable(unittest_xlist
   test_xlist.cc
diff --git a/src/test/cxx11_client.cc b/src/test/cxx11_client.cc
new file mode 100644 (file)
index 0000000..c30ab5c
--- /dev/null
@@ -0,0 +1,6 @@
+#include "include/buffer.h"
+
+// We might want to include here all our public headers.
+// Not any file residing in src/include has this status.
+
+int main() {}