From 0f96032487c5394e64fe1461541ca13162173306 Mon Sep 17 00:00:00 2001 From: Edward d'Auvergne Date: Tue, 13 Mar 2018 20:56:31 +0100 Subject: [PATCH] TestSuite: Shift of the globals unit test helper functions into the test suite. The setting of the SG log levels and developer mode has been removed as this clashes with the output control set by the test suite main() function. --- src/Input/test_hidinput.cxx | 2 +- src/Main/test_autosaveMigration.cxx | 2 +- test_suite/CMakeLists.txt | 3 +++ test_suite/helpers/CMakeLists.txt | 12 ++++++++++++ .../helpers/globals.cxx | 5 +---- .../helpers/globals.hxx | 0 .../unit_tests/Add-ons/test_AddonManagement.cxx | 2 +- test_suite/unit_tests/Main/test_posinit.cxx | 2 +- test_suite/unit_tests/Navaids/CMakeLists.txt | 2 -- test_suite/unit_tests/Navaids/test_flightplan.cxx | 2 +- tests/CMakeLists.txt | 2 +- tests/test_navaids2.cxx | 2 +- 12 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 test_suite/helpers/CMakeLists.txt rename tests/unitTestHelpers.cxx => test_suite/helpers/globals.cxx (95%) rename tests/unitTestHelpers.hxx => test_suite/helpers/globals.hxx (100%) diff --git a/src/Input/test_hidinput.cxx b/src/Input/test_hidinput.cxx index 1f90d4d1a..978157f63 100644 --- a/src/Input/test_hidinput.cxx +++ b/src/Input/test_hidinput.cxx @@ -18,7 +18,7 @@ #include "config.h" -#include "unitTestHelpers.hxx" +#include "test_suite/helpers/globals.hxx" #include diff --git a/src/Main/test_autosaveMigration.cxx b/src/Main/test_autosaveMigration.cxx index edd11663d..b367b16ab 100644 --- a/src/Main/test_autosaveMigration.cxx +++ b/src/Main/test_autosaveMigration.cxx @@ -18,7 +18,7 @@ #include "config.h" -#include "unitTestHelpers.hxx" +#include "test_suite/helpers/globals.hxx" #include #include diff --git a/test_suite/CMakeLists.txt b/test_suite/CMakeLists.txt index 42b2c5613..a64d29fac 100644 --- a/test_suite/CMakeLists.txt +++ b/test_suite/CMakeLists.txt @@ -8,6 +8,9 @@ foreach(test_category add_subdirectory(${test_category}) endforeach(test_category) +# Add the helpers. +add_subdirectory(helpers) + # Add all test suite sources and headers. set(TESTSUITE_SOURCES ${TESTSUITE_SOURCES} diff --git a/test_suite/helpers/CMakeLists.txt b/test_suite/helpers/CMakeLists.txt new file mode 100644 index 000000000..45096948f --- /dev/null +++ b/test_suite/helpers/CMakeLists.txt @@ -0,0 +1,12 @@ +set(TESTSUITE_SOURCES + ${TESTSUITE_SOURCES} + ${CMAKE_CURRENT_SOURCE_DIR}/globals.cxx + PARENT_SCOPE +) + + +set(TESTSUITE_HEADERS + ${TESTSUITE_HEADERS} + ${CMAKE_CURRENT_SOURCE_DIR}/globals.hxx + PARENT_SCOPE +) diff --git a/tests/unitTestHelpers.cxx b/test_suite/helpers/globals.cxx similarity index 95% rename from tests/unitTestHelpers.cxx rename to test_suite/helpers/globals.cxx index c44731e08..70ec72afd 100644 --- a/tests/unitTestHelpers.cxx +++ b/test_suite/helpers/globals.cxx @@ -1,7 +1,7 @@ #include "config.h" -#include "unitTestHelpers.hxx" +#include "globals.hxx" #include
#include
@@ -33,9 +33,6 @@ namespace fgtest void initTestGlobals(const std::string& testName) { - sglog().setLogLevels( SG_ALL, SG_WARN ); - sglog().setDeveloperMode(true); - globals = new FGGlobals; bool foundRoot = false; diff --git a/tests/unitTestHelpers.hxx b/test_suite/helpers/globals.hxx similarity index 100% rename from tests/unitTestHelpers.hxx rename to test_suite/helpers/globals.hxx diff --git a/test_suite/unit_tests/Add-ons/test_AddonManagement.cxx b/test_suite/unit_tests/Add-ons/test_AddonManagement.cxx index b9a4acc30..dce921e99 100644 --- a/test_suite/unit_tests/Add-ons/test_AddonManagement.cxx +++ b/test_suite/unit_tests/Add-ons/test_AddonManagement.cxx @@ -21,7 +21,7 @@ #include "test_AddonManagement.hxx" #include "config.h" -#include "tests/unitTestHelpers.hxx" +#include "test_suite/helpers/globals.hxx" #include #include diff --git a/test_suite/unit_tests/Main/test_posinit.cxx b/test_suite/unit_tests/Main/test_posinit.cxx index ea709d160..4561f1118 100644 --- a/test_suite/unit_tests/Main/test_posinit.cxx +++ b/test_suite/unit_tests/Main/test_posinit.cxx @@ -18,7 +18,7 @@ #include "test_posinit.hxx" -#include "tests/unitTestHelpers.hxx" +#include "test_suite/helpers/globals.hxx" #include diff --git a/test_suite/unit_tests/Navaids/CMakeLists.txt b/test_suite/unit_tests/Navaids/CMakeLists.txt index 880e5d898..9266f8be6 100644 --- a/test_suite/unit_tests/Navaids/CMakeLists.txt +++ b/test_suite/unit_tests/Navaids/CMakeLists.txt @@ -2,13 +2,11 @@ set(TESTSUITE_SOURCES ${TESTSUITE_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/TestSuite.cxx ${CMAKE_CURRENT_SOURCE_DIR}/test_flightplan.cxx - ${PROJECT_SOURCE_DIR}/tests/unitTestHelpers.cxx PARENT_SCOPE ) set(TESTSUITE_HEADERS ${TESTSUITE_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/test_flightplan.hxx - ${PROJECT_SOURCE_DIR}/tests/unitTestHelpers.cxx PARENT_SCOPE ) diff --git a/test_suite/unit_tests/Navaids/test_flightplan.cxx b/test_suite/unit_tests/Navaids/test_flightplan.cxx index 021c6578d..dcb2d2e49 100644 --- a/test_suite/unit_tests/Navaids/test_flightplan.cxx +++ b/test_suite/unit_tests/Navaids/test_flightplan.cxx @@ -1,6 +1,6 @@ #include "test_flightplan.hxx" -#include "tests/unitTestHelpers.hxx" +#include "test_suite/helpers/globals.hxx" #include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b796949d8..9ce27cea8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -88,7 +88,7 @@ set_property(DIRECTORY APPEND PROPERTY fgtestlib_sources "${CMAKE_SOURCE_DIR}/3r get_property(fgtestlib_sources DIRECTORY PROPERTY fgtestlib_sources) add_library(fgtestlib SHARED ${fgtestlib_sources} - unitTestHelpers.cxx + "${CMAKE_SOURCE_DIR}/test_suite/helpers/globals.cxx" testStubs.cxx fake_sgSky.cxx fake_sgPrecipitation.cxx diff --git a/tests/test_navaids2.cxx b/tests/test_navaids2.cxx index 92de78134..fdddde037 100644 --- a/tests/test_navaids2.cxx +++ b/tests/test_navaids2.cxx @@ -1,4 +1,4 @@ -#include "unitTestHelpers.hxx" +#include "test_suite/helpers/globals.hxx" #include