← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1830868-skip-tests into lp:widelands

 

Notabilis has proposed merging lp:~widelands-dev/widelands/bug-1830868-skip-tests into lp:widelands.

Commit message:
Adding compile.sh switch -s to skip building the tests.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1830868 in widelands: "Add switch to compile.sh for skipping boost unit tests"
  https://bugs.launchpad.net/widelands/+bug/1830868

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1830868-skip-tests/+merge/368858
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1830868-skip-tests into lp:widelands.
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2019-05-09 06:43:00 +0000
+++ CMakeLists.txt	2019-06-15 09:39:05 +0000
@@ -48,6 +48,7 @@
 option(OPTION_GLEW_STATIC "Use static GLEW Library" OFF)
 option(OPTION_BUILD_WEBSITE_TOOLS "Build website-related tools" ON)
 option(OPTION_BUILD_TRANSLATIONS "Build translations" ON)
+option(OPTION_BUILD_TESTS "Build tests" ON)
 
 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
   message(FATAL_ERROR "Build directory and source directory must not be the same.")
@@ -298,17 +299,19 @@
 endif (NOT DEFINED WL_VERSION)
 
 # Enable testing.
-include(CTest)
-enable_testing()
+if (OPTION_BUILD_TESTS)
+  include(CTest)
+  enable_testing()
 
-# Run a test after a normal compile. This magic is needed as 'make test' will
-# not rebuild tests:
-# http://stackoverflow.com/questions/733475/cmake-ctest-make-test-doesnt-build-tests
-add_custom_target(_run_all_tests ALL
-  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
-  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
-  DEPENDS wl_tests
-)
+  # Run a test after a normal compile. This magic is needed as 'make test' will
+  # not rebuild tests:
+  # http://stackoverflow.com/questions/733475/cmake-ctest-make-test-doesnt-build-tests
+  add_custom_target(_run_all_tests ALL
+    COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
+    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+    DEPENDS wl_tests
+  )
+endif (OPTION_BUILD_TESTS)
 
 install (
   FILES ${CMAKE_CURRENT_BINARY_DIR}/VERSION

=== modified file 'cmake/WlFunctions.cmake'
--- cmake/WlFunctions.cmake	2019-04-18 12:46:07 +0000
+++ cmake/WlFunctions.cmake	2019-06-15 09:39:05 +0000
@@ -178,6 +178,12 @@
 
 # Common test target definition.
 function(wl_test NAME)
+
+  if (NOT OPTION_BUILD_TESTS)
+    return()
+  endif()
+
+
   _parse_common_args("${ARGN}")
 
   add_executable(${NAME} ${ARG_SRCS})

=== modified file 'compile.sh'
--- compile.sh	2018-12-06 21:59:09 +0000
+++ compile.sh	2019-06-15 09:39:05 +0000
@@ -38,6 +38,9 @@
     echo "-t or --no-translations"
     echo "                      Omit building translations."
     echo " "
+    echo "-s or --skip-tests"
+    echo "                      Skip linking and executing the tests."
+    echo " "
     echo "-a or --no-asan       If in debug mode, switch off the AddressSanitizer."
     echo "                      Release builds are created without AddressSanitizer"
     echo "                      by default."
@@ -81,6 +84,7 @@
 ## Options to control the build.
 BUILD_WEBSITE="ON"
 BUILD_TRANSLATIONS="ON"
+BUILD_TESTS="ON"
 BUILD_TYPE="Debug"
 USE_ASAN="ON"
 COMPILER="default"
@@ -128,6 +132,10 @@
       BUILD_TRANSLATIONS="OFF"
     shift
     ;;
+    -s|--skip-tests)
+      BUILD_TESTS="OFF"
+    shift
+    ;;
     -w|--no-website)
       BUILD_WEBSITE="OFF"
     shift
@@ -169,7 +177,14 @@
   echo "Translations will be built."
   echo "You can use -t or --no-translations to omit building them."
 else
-echo "Translations will not be built."
+	echo "Translations will not be built."
+fi
+echo " "
+if [ $BUILD_TESTS = "ON" ]; then
+  echo "Tests will be built."
+  echo "You can use -s or --skip-tests to omit building them."
+else
+	echo "Tests will not be built."
 fi
 echo " "
 echo "###########################################################"
@@ -245,9 +260,9 @@
   # Compile Widelands
   compile_widelands () {
     if [ $buildtool = "ninja" ] || [ $buildtool = "ninja-build" ] ; then
-      cmake -G Ninja .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOPTION_BUILD_WEBSITE_TOOLS=$BUILD_WEBSITE -DOPTION_BUILD_TRANSLATIONS=$BUILD_TRANSLATIONS -DOPTION_ASAN=$USE_ASAN
+      cmake -G Ninja .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOPTION_BUILD_WEBSITE_TOOLS=$BUILD_WEBSITE -DOPTION_BUILD_TRANSLATIONS=$BUILD_TRANSLATIONS -DOPTION_BUILD_TESTS=$BUILD_TESTS -DOPTION_ASAN=$USE_ASAN
     else
-      cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOPTION_BUILD_WEBSITE_TOOLS=$BUILD_WEBSITE -DOPTION_BUILD_TRANSLATIONS=$BUILD_TRANSLATIONS -DOPTION_ASAN=$USE_ASAN
+      cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOPTION_BUILD_WEBSITE_TOOLS=$BUILD_WEBSITE -DOPTION_BUILD_TRANSLATIONS=$BUILD_TRANSLATIONS -DOPTION_BUILD_TESTS=$BUILD_TESTS -DOPTION_ASAN=$USE_ASAN
     fi
 
     $buildtool -j $CORES
@@ -339,6 +354,11 @@
 else
   echo "# - No translations                                       #"
 fi
+if [ $BUILD_TESTS = "ON" ]; then
+  echo "# - Tests                                                 #"
+else
+  echo "# - No tests                                              #"
+fi
 
 if [ $BUILD_WEBSITE = "ON" ]; then
   echo "# - Website-related executables                           #"


Follow ups