diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f96afb305c1f84eb94055bb3bf7f5b8b7922f1c1..3374def33af870a1e2a60e58b875183130c1984c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,3 @@ -# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration - # List of the CI build stages. stages: - step-A @@ -27,7 +25,7 @@ workflow: # TEMPLATES FOR BUILDING ON DIFFERENT PLATFORMS -# Base template for all macOS jobs +# general macOS job template .macos-template-job: &macos-job tags: - macos @@ -43,7 +41,10 @@ workflow: - export CPPFLAGS="-I/usr/local/opt/expat/include" - export PATH="/usr/local/opt/qt5/bin:$PATH" # to make Qt5 discoverable by CMake -# Base template for all Ubuntu jobs +# NOTE +# The Ubuntu package 'nlohmann-json-dev' is version 2.x, too old for us. +# Thus, for GeoModelVisualization (GMEX), we now build nlohmann_json as part +# of the build, by using the 'standalone' job only .ubuntu-template-job-default: &ubuntu-job image: gitlab-registry.cern.ch/geomodeldev/ubuntu-geant4-image:main-base rules: diff --git a/CI/DockerfileFull b/CI/DockerfileFull index bf50b397d014269c6b899fa75a27143a703c6d5d..79cb16a899b034e392d829f6e9a38e3d2c05fc04 100755 --- a/CI/DockerfileFull +++ b/CI/DockerfileFull @@ -2,12 +2,8 @@ ARG BASEIMAGE=gitlab-registry.cern.ch/geomodeldev/ubuntu-geant4-image:main-base FROM ${BASEIMAGE} -# Install GoogleTest -# FIXME: we want to move this to the main image later -RUN apt-get update && apt-get install -y libgtest-dev - ### Compile then geo model -COPY . /workdir/GeoModel_src/ +COPY . /workdir/GeoModel_src/ RUN mkdir -p /workdir/build_geomodel/ && \ cd /workdir/build_geomodel/ && \ . ~/.bashrc && \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 11529c9b3f55021f8192adc7290fed422b8e5940..e747085ca71b79d5a625767de7e31a2eccd5dc6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration # === Preamble === cmake_minimum_required(VERSION 3.16...3.26) @@ -34,9 +34,6 @@ endif() include( SetupEigen3 ) include( SetupXercesC ) include( SetupJSON ) -# Add the GoogleTest framework, for tests -find_package(GTest REQUIRED) -include_directories(${GTEST_INCLUDE_DIRS}) # Find the dependencies that the project always picks up from its environment. find_package( SQLite3 3.7.17 ) diff --git a/GeoModelIO/GeoModelDBManager/CMakeLists.txt b/GeoModelIO/GeoModelDBManager/CMakeLists.txt index 37dabe13b3c1153fa62724784d4a6e1765236e19..513943cf47bcc58dc6f8647fbe8b233c7244f0c6 100644 --- a/GeoModelIO/GeoModelDBManager/CMakeLists.txt +++ b/GeoModelIO/GeoModelDBManager/CMakeLists.txt @@ -1,12 +1,11 @@ -# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration ################################################################################ # Package: GeoModelDBManager # author: Riccardo Maria BIANCHI @ CERN - 2017 # major updates: # - R.M.Bianchi, 2018 -# - R.M.Bianchi, Nov 2020 -# - R.M.Bianchi, Apr 2024 -- Add CTest tests -# - R.M.Bianchi, Feb 2025 -- Add GoogleTest support +# - R.M.Bianvhi, Nov 2020 +# - R.M.Bianvhi, Apr 2024 ################################################################################ # Find the header and source files. @@ -40,32 +39,7 @@ install( FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/GeoModelDBManager COMPONENT Development ) - -### --- Add Tests --- - -#++ Create a 'simple' unit test add_executable(test_create_db_file tests/test_create_db_file.cpp) target_link_libraries( test_create_db_file GeoModelIO::GeoModelDBManager) add_test(NAME testCreateDBFile COMMAND test_create_db_file) - -#++ Create a GoogleTest test, -# and let CTest run all the sub-tests defined in it separately. -# NOTE: You can still use the standard CMake `add_test` function -# to declare the test; however, in that case, CTest will -# run it as a whole and you will only get one line of output -# for all the tests in it togetehr. -# While with the GTest method here below, you will get -# one line of output for each actual test defined in the -# 'container' test program. -# Therefore, for GTest tests it is advisable to use the -# approach below. -# -# Create test executable -add_executable(test_db_functions tests/test_db_functions.cpp) -target_link_libraries(test_db_functions GeoModelDBManager GTest::GTest GTest::Main) -# Register the test and let CTest discover -# all tests contained in it and run them separately -include(GoogleTest) -gtest_discover_tests(test_db_functions) - diff --git a/GeoModelIO/GeoModelDBManager/tests/test_create_db_file.cpp b/GeoModelIO/GeoModelDBManager/tests/test_create_db_file.cpp index 6fb9c5fa5388f0550e7d03dfb894181b164094e3..970e18de7a8f9a009549d12bfb04cd3b692517be 100644 --- a/GeoModelIO/GeoModelDBManager/tests/test_create_db_file.cpp +++ b/GeoModelIO/GeoModelDBManager/tests/test_create_db_file.cpp @@ -22,7 +22,7 @@ int main(int argc, char *argv[]) //------------------------------------------------------------------------------------// // Open a geometry file //------------------------------------------------------------------------------------// - std::string path = "test_geometry.db"; + std::string path = "geometry.db"; // check if DB file exists. If not, return. // FIXME: TODO: this check should go in the 'GMDBManager' constructor. diff --git a/GeoModelIO/GeoModelDBManager/tests/test_db_functions.cpp b/GeoModelIO/GeoModelDBManager/tests/test_db_functions.cpp deleted file mode 100644 index 6bba7f476203b34e6f0deb7e09630d5ef19fdd04..0000000000000000000000000000000000000000 --- a/GeoModelIO/GeoModelDBManager/tests/test_db_functions.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// GeoModel includes -#include "GeoModelDBManager/GMDBManager.h" - -#include <gtest/gtest.h> -#include <filesystem> - -class DatabaseTest : public ::testing::Test { -protected: - std::string dbFile = "test_database.db"; - std::unique_ptr<GMDBManager> dbManager{}; - - void SetUp() override { - // Remove any existing test database - if (std::filesystem::exists(dbFile)) { - std::filesystem::remove(dbFile); - } - - // open the DB connection - dbManager = std::make_unique<GMDBManager>(dbFile); - - // check the DB connection - if (dbManager->checkIsDBOpen()) - { - std::cout << "OK! Database is open!" << std::endl; - } - else - { - std::cout << "Database ERROR!! Exiting..." << std::endl; - exit(EXIT_FAILURE); - } - } - - void TearDown() override { - if (std::filesystem::exists(dbFile)) { - std::filesystem::remove(dbFile); - } - } -}; - -TEST_F(DatabaseTest, CreateDatabaseTest) { - // EXPECT_TRUE(dbManager->createDatabase()); - EXPECT_TRUE(std::filesystem::exists(dbFile)); -} - -TEST_F(DatabaseTest, PopulateDatabaseTest) { - // ASSERT_TRUE(dbManager->createDatabase()); - EXPECT_TRUE(dbManager->initDB()); -} - -// TEST_F(DatabaseTest, InsertDataTest) { -// ASSERT_TRUE(dbManager->createDatabase()); -// ASSERT_TRUE(dbManager->initDB()); - -// EXPECT_TRUE(dbManager->insertData("key1", "value1")); -// } - -// TEST_F(DatabaseTest, ReadDataTest) { -// ASSERT_TRUE(dbManager->createDatabase()); -// ASSERT_TRUE(dbManager->populateDatabase()); - -// dbManager->insertData("key1", "value1"); -// EXPECT_EQ(dbManager->readData("key1"), "value1"); -// } -