From 4689c243385bf79119ca110435fdc855c5ad1afe Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Mon, 23 Oct 2023 10:33:34 +0200 Subject: [PATCH] move to ctest --- .github/workflows/test.yml | 3 +- CMakeLists.txt | 22 ++++++++++++++ test/.gitignore | 21 +++++++++++++ test/CMakeLists.txt | 45 +++++++++++++++++++++++++++ test/test_CLDConfig.py | 62 -------------------------------------- 5 files changed, 90 insertions(+), 63 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 test/.gitignore create mode 100644 test/CMakeLists.txt delete mode 100644 test/test_CLDConfig.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 035cc39..5604cf7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,5 +27,6 @@ jobs: run: | docker exec CLDConfig_CI /bin/bash -c 'source ${{ matrix.SETUP }}; cd CLDConfig; - pytest; + cmake .; + ctest --output-on-failure; ' diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..183887a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,22 @@ +#[[ +Copyright (c) 2014-2023 Key4hep-Project. + +This file is part of Key4hep. +See https://key4hep.github.io/key4hep-doc/ for further info. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +]] +project(CLDConfig) + +add_subdirectory(test) +enable_testing() diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..db5ab16 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1,21 @@ +### CMake ### +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +### CMake Patch ### +# External projects +*-prefix/ + +### other ### +*.root +*.slcio +build/* diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..3bd9e04 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,45 @@ +#[[ +Copyright (c) 2014-2023 Key4hep-Project. + +This file is part of Key4hep. +See https://key4hep.github.io/key4hep-doc/ for further info. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +]] +include(CTest) + +set(DETECTOR $ENV{K4GEO}/FCCee/CLD/compact/FCCee_o1_v04/FCCee_o1_v04.xml) +set(CLDConfig_DIR ${CMAKE_CURRENT_LIST_DIR}/../CLDConfig) + +add_test(NAME ddsim_lcio + WORKING_DIRECTORY ${CLDConfig_DIR} + COMMAND ddsim -S cld_steer.py -N 3 --inputFile ../test/yyxyev_000.stdhep --outputFile test.slcio --compactFile ${DETECTOR} +) + +# FIXME: need to call k4run from CLDConfig dir where the pandora config lives +add_test(NAME lcio_input + WORKING_DIRECTORY ${CLDConfig_DIR} + COMMAND k4run --inputFiles=test.slcio --outputBasename=rec_test_lcio CLDReconstruction.py --GeoSvc.detectors=${DETECTOR} +) +set_property(TEST lcio_input APPEND PROPERTY DEPENDS ddsim_lcio) + +add_test(NAME ddsim_edm4hep + WORKING_DIRECTORY ${CLDConfig_DIR} + COMMAND ddsim -S cld_steer.py -N 3 --inputFile ../test/yyxyev_000.stdhep --outputFile test.edm4hep.root --compactFile ${DETECTOR} +) + +add_test(NAME edm4hep_input + WORKING_DIRECTORY ${CLDConfig_DIR} + COMMAND k4run --inputFiles=test.edm4hep.root --outputBasename=rec_test_edm4hep CLDReconstruction.py --GeoSvc.detectors=${DETECTOR} +) +set_property(TEST edm4hep_input APPEND PROPERTY DEPENDS ddsim_edm4hep) diff --git a/test/test_CLDConfig.py b/test/test_CLDConfig.py deleted file mode 100644 index aaa709c..0000000 --- a/test/test_CLDConfig.py +++ /dev/null @@ -1,62 +0,0 @@ -# -# Copyright (c) 2014-2023 Key4hep-Project. -# -# This file is part of Key4hep. -# See https://key4hep.github.io/key4hep-doc/ for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import os -import subprocess -from decorator import decorator -import pytest - -@decorator -def _CLDConfig(test_fun): - os.chdir("CLDConfig") - test_fun() - os.chdir("..") - -detectorModel = os.path.join(os.environ["K4GEO"], "FCCee/CLD/compact/FCCee_o1_v04/FCCee_o1_v04.xml") - -@_CLDConfig -@pytest.mark.dependency() -def test_ddsim_lcio(): - command = "ddsim -S cld_steer.py -N 3 --inputFile ../test/yyxyev_000.stdhep --outputFile test.slcio".split() - command.extend(["--compactFile", detectorModel]) - res = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) - assert res.returncode == 0, res.stdout - -@_CLDConfig -@pytest.mark.dependency() -def test_ddsim_edm4hep(): - command = "ddsim -S cld_steer.py -N 3 --inputFile ../test/yyxyev_000.stdhep --outputFile test.edm4hep.root".split() - command.extend(["--compactFile", detectorModel]) - res = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) - assert res.returncode == 0, res.stdout - -@_CLDConfig -@pytest.mark.dependency(depends=["test_ddsim_lcio"]) -def test_lcio_input(): - command = "k4run --inputFiles=test.slcio --outputBasename=rec_test_lcio CLDReconstruction.py".split() - command.extend(["--GeoSvc.detectors", detectorModel]) - res = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) - assert res.returncode == 0, res.stdout - -@_CLDConfig -@pytest.mark.dependency(depends=["test_ddsim_edm4hep"]) -def test_edm4hep_input(): - command = "k4run --inputFiles=test.edm4hep.root --outputBasename=rec_test_edm4hep CLDReconstruction.py".split() - command.extend(["--GeoSvc.detectors", detectorModel]) - res = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) - assert res.returncode == 0, res.stdout