From d09139189912adada695ca95092ba703e3e40069 Mon Sep 17 00:00:00 2001 From: Gregory A Lundberg Date: Wed, 1 Nov 2017 21:26:37 -0500 Subject: [PATCH 1/3] Renamed the target and binary for the Boost unit tests from `test` to `boost_unit_tests` This quells warnings from CMake about reserved target names, and reduces confusion about which `test` is intended: the wesnoth executable or the standard shell command. --- .gitignore | 1 + SConstruct | 12 ++++++------ changelog | 5 +++++ source_lists/{test => boost_unit_tests} | 0 src/CMakeLists.txt | 10 +++++----- src/SConscript | 8 ++++---- 6 files changed, 21 insertions(+), 15 deletions(-) rename source_lists/{test => boost_unit_tests} (100%) diff --git a/.gitignore b/.gitignore index 981984cb8d66..f6df19bf6fea 100644 --- a/.gitignore +++ b/.gitignore @@ -133,6 +133,7 @@ userdata # testing /test* +/boost_unit_tests* !/test_wrapper.sh src/test error*.log diff --git a/SConstruct b/SConstruct index 00baab94d171..e081fc6c95bf 100755 --- a/SConstruct +++ b/SConstruct @@ -46,7 +46,7 @@ def OptionalPath(key, val, env): opts.AddVariables( ListVariable('default_targets', 'Targets that will be built if no target is specified in command line.', - "wesnoth,wesnothd", Split("wesnoth wesnothd campaignd test")), + "wesnoth,wesnothd", Split("wesnoth wesnothd campaignd boost_unit_tests")), EnumVariable('build', 'Build variant: release, debug, or profile', "release", ["release", "debug", "profile"]), PathVariable('build_dir', 'Build all intermediate files(objects, test programs, etc) under this dir', "build", PathVariable.PathAccept), ('extra_flags_config', "Extra compiler and linker flags to use for configuration and all builds. Whether they're compiler or linker is determined by env.ParseFlags. Unknown flags are compile flags by default. This applies to all extra_flags_* variables", ""), @@ -201,11 +201,11 @@ Important switches include: With no arguments, the recipe builds wesnoth and wesnothd. Available build targets include the individual binaries: - wesnoth wesnothd campaignd test + wesnoth wesnothd campaignd boost_unit_tests You can make the following special build targets: - all = wesnoth wesnothd campaignd test (*). + all = wesnoth wesnothd campaignd boost_unit_tests (*). TAGS = build tags for Emacs (*). wesnoth-deps.png = project dependency graph install = install all executables that currently exist, and any data needed @@ -431,8 +431,8 @@ if env["prereqs"]: have_test_prereqs = have_client_prereqs and conf.CheckBoost('unit_test_framework') \ or Warning("Unit tests are disabled because their prerequisites are not met") test_env = conf.Finish() - if not have_test_prereqs and "test" in env["default_targets"]: - env["default_targets"].remove("test") + if not have_test_prereqs and "boost_unit_tests" in env["default_targets"]: + env["default_targets"].remove("boost_unit_tests") print(" " + env.subst("If any config checks fail, look in $build_dir/config.log for details")) print(" If a check fails spuriously due to caching, use --config=force to force its rerun") @@ -595,7 +595,7 @@ except: Export(Split("env client_env test_env have_client_prereqs have_server_prereqs have_test_prereqs")) SConscript(dirs = Split("po doc packaging/windows packaging/systemd")) -binaries = Split("wesnoth wesnothd campaignd test") +binaries = Split("wesnoth wesnothd campaignd boost_unit_tests") builds = { "release" : dict(CCFLAGS = Split(rel_comp_flags) , LINKFLAGS = Split(rel_link_flags)), "debug" : dict(CCFLAGS = Split(debug_flags) , CPPDEFINES = Split(glibcxx_debug_flags)), diff --git a/changelog b/changelog index 5a4f65125f9f..63f6319b6c73 100644 --- a/changelog +++ b/changelog @@ -4,6 +4,11 @@ Version 1.13.10+dev: have linger=no in [end_level]. * A Tale of Two Brothers: * Added a full set of hints on easy difficulty. + * Contiuous Integration (CI) and Unit testing + * Renamed the target and binary for the Boost unit tests from `test` to + `boost_unit_tests`. This quells warnings from CMake about reserved target + names, and reduces confusion about which `test` is intended: the wesnoth + executable or the standard shell command. * Language and i18n: * Updated translations: Chinese (Simplified) * Lua API: diff --git a/source_lists/test b/source_lists/boost_unit_tests similarity index 100% rename from source_lists/test rename to source_lists/boost_unit_tests diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 72adedf002b2..44a2b166c7a0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -485,7 +485,7 @@ if(ENABLE_TESTS) add_definitions(-DBOOST_TEST_DYN_LINK) - GetSources("test" test_SRC) + GetSources("boost_unit_tests" test_SRC) if(ENABLE_GAME) set(test_LIB @@ -514,16 +514,16 @@ if(ENABLE_TESTS) "${CXX_FLAG_NO_USELESS_CAST}" ) - add_executable(test + add_executable(boost_unit_tests ${test_SRC} ) - target_link_libraries(test + target_link_libraries(boost_unit_tests ${test_LIB} ${game-external-libs} boost_unit_test_framework ) - set_target_properties(test - PROPERTIES OUTPUT_NAME ${BINARY_PREFIX}test${BINARY_SUFFIX} + set_target_properties(boost_unit_tests + PROPERTIES OUTPUT_NAME ${BINARY_PREFIX}boost_unit_tests${BINARY_SUFFIX} ) endif(ENABLE_TESTS) diff --git a/src/SConscript b/src/SConscript index 5ca73a310a0e..a506cd5ae4b9 100644 --- a/src/SConscript +++ b/src/SConscript @@ -80,7 +80,7 @@ if env["png"]: libwesnoth_sdl = client_env.Library("wesnoth_sdl", libwesnoth_sdl_sources) #---wesnoth--- -# Used by both 'wesnoth' and 'test' targets +# Used by both 'wesnoth' and 'boost_unit_tests' targets wesnoth_sources = GetSources("wesnoth") @@ -161,9 +161,9 @@ env.WesnothProgram("wesnothd", wesnothd_sources + [libwesnoth_core, env["wesnoth campaignd_sources = GetSources("campaignd") env.WesnothProgram("campaignd", campaignd_sources + [libwesnoth_core], have_server_prereqs, OBJPREFIX = "campaignd_") -#---test--- -test_sources = GetSources("test") -test = test_env.WesnothProgram("test", test_sources + [libwesnoth_extras, libwesnoth_core, libwesnoth, libwesnoth_sdl, libwesnoth_extras], have_test_prereqs) +#---boost_unit_tests--- +test_sources = GetSources("boost_unit_tests") +boost_unit_tests = test_env.WesnothProgram("boost_unit_tests", test_sources + [libwesnoth_extras, libwesnoth_core, libwesnoth, libwesnoth_sdl, libwesnoth_extras], have_test_prereqs) #---end of getting sources--- sources = [] From ad01dbd404e092e258fece5d1ad473fea1717d12 Mon Sep 17 00:00:00 2001 From: Gregory A Lundberg Date: Fri, 3 Nov 2017 15:30:47 -0500 Subject: [PATCH 2/3] Quell CMake Warning CMP005 Deprecated --- CMakeLists.txt | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c96d10d84fb5..64c43cae49dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,10 +11,6 @@ cmake_minimum_required(VERSION 2.6.0) include(CheckCXXCompilerFlag) -if(COMMAND cmake_policy) - cmake_policy(SET CMP0005 OLD) -endif(COMMAND cmake_policy) - set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) # use our own version of FindBoost.cmake and other Find* scripts @@ -485,14 +481,14 @@ endif(UNIX AND NOT CMAKE_COMPILER_IS_GNUCXX) set(DATADIR ${DATAROOTDIR}/${DATADIRNAME}) if(NOT WIN32) - add_definitions(-DWESNOTH_PATH=\\\"${DATADIR}\\\") + add_definitions(-DWESNOTH_PATH="${DATADIR}") endif(NOT WIN32) if(X11_FOUND) add_definitions(-D_X11) endif(X11_FOUND) -add_definitions(-DLOCALEDIR=\\\"${LOCALEDIR}\\\") +add_definitions(-DLOCALEDIR="${LOCALEDIR}") # -NDEBUG is automatically added to all release build types, so manually remove # this define from the related variables @@ -677,15 +673,15 @@ else(LOCALEDIR MATCHES "^/") set(LOCALE_INSTALL ${DATADIR}/${LOCALEDIR}) endif(LOCALEDIR MATCHES "^/") -add_definitions(-DFIFODIR=\\\"${FIFO_DIR}\\\") +add_definitions(-DFIFODIR="${FIFO_DIR}") if(PREFERENCES_DIR) - add_definitions(-DPREFERENCES_DIR=\\\"${PREFERENCES_DIR}\\\") + add_definitions(-DPREFERENCES_DIR="${PREFERENCES_DIR"}) endif(PREFERENCES_DIR) if(DEFAULT_PREFS_FILE) - add_definitions(-DDEFAULT_PREFS_PATH=\\\"${DEFAULT_PREFS_FILE}\\\") + add_definitions(-DDEFAULT_PREFS_PATH="${DEFAULT_PREFS_FILE"}) if(NOT DEFAULT_PREFS_FILE MATCHES "^/") add_definitions(-DHAS_RELATIVE_DEFPREF) From bf8758afde020c1edfacf320c5ab3058acbb41fd Mon Sep 17 00:00:00 2001 From: Gregory A Lundberg Date: Mon, 6 Nov 2017 13:43:18 -0600 Subject: [PATCH 3/3] Tell Travis about Boost unit test name change --- .travis.yml | 2 +- utils/travis/test_executor.sh | 2 +- utils/travis/test_wrapper.sh | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 496d1bc2d098..fa3e8e3892a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ matrix: env: opt=-O0 CXXSTD=11 NLS=false before_install: - - export TARGETS="wesnoth wesnothd campaignd test" + - export TARGETS="wesnoth wesnothd campaignd boost_unit_tests" - export STRICT_COMPILATION=false - export EXTRA_FLAGS_RELEASE="" - export WML_TESTS=true CPP_TESTS=false PLAY_TEST=true MP_TEST=true diff --git a/utils/travis/test_executor.sh b/utils/travis/test_executor.sh index 2144eb76a196..0abe1d2f0695 100755 --- a/utils/travis/test_executor.sh +++ b/utils/travis/test_executor.sh @@ -1,3 +1,3 @@ #!/bin/bash set -e -gdb -q -batch -return-child-result -ex "run" -ex "thread apply all bt" -ex "quit" --args ./test +gdb -q -batch -return-child-result -ex "run" -ex "thread apply all bt" -ex "quit" --args ./boost_unit_tests diff --git a/utils/travis/test_wrapper.sh b/utils/travis/test_wrapper.sh index 6451ee1d0912..b045cf6780ba 100755 --- a/utils/travis/test_wrapper.sh +++ b/utils/travis/test_wrapper.sh @@ -1,15 +1,15 @@ #!/bin/bash COUNTER=10 -./test +./boost_unit_tests ERRORCODE=$? while [ $COUNTER -gt 0 -a $ERRORCODE -eq 200 ]; do - echo "test gave error code 200 (segfault).. trying again." + echo "boost_unit_tests gave error code 200 (segfault).. trying again." COUNTER=$((COUNTER-1)) - ./test + ./boost_unit_tests ERRORCODE=$? done if [ $ERRORCODE -eq 200 ]; then - echo "test gave error code 200 ten times. suppressing this error...\n" + echo "boost_unit_tests gave error code 200 ten times. suppressing this error...\n" ERRORCODE=0 fi export TEST_ERROR_CODE="$ERRORCODE"