Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regenerate ROOT files during CI testing #1287

Merged
merged 15 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/build-spack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,18 @@ jobs:
continue-on-error: ${{matrix.special == 'clang-tidy'}}
run: |
ninja -v -k0
- name: Regenerate ROOT test data
working-directory: build
if: ${{matrix.geant == '11.0'}}
run: |
ninja -v -k0 update-root-test-data
- name: Run tests
working-directory: build
continue-on-error: ${{fromJSON(matrix.geant) < 11}} # TODO: fix failing tests
run: |
if [ "${{matrix.geant}}" == "11.0" ]; then
# TODO: add 11.0.4 and clhep version to tests
#export CELER_TEST_STRICT=1
echo "warning: strict testing is disabled"
# Note this is ignored for geant4, float, clhep
export CELER_TEST_STRICT=1
fi
ctest --parallel $(nproc) --timeout 15 --output-on-failure \
--test-output-size-passed=32768 --test-output-size-failed=1048576
Expand Down
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ function(celeritas_add_device_test base)
endfunction()

if(CELERITAS_USE_Geant4)
# Optional dependence on low-energy EM data
# Optional dependence on low-energy EM data and neutron data
set(CELERITASTEST_G4ENV)
foreach(_ds G4EMLOW G4ENSDFSTATE)
foreach(_ds G4EMLOW G4ENSDFSTATE G4PARTICLEXS)
list(APPEND CELERITASTEST_G4ENV
"${Geant4_DATASET_${_ds}_ENVVAR}=${Geant4_DATASET_${_ds}_PATH}"
)
Expand Down
49 changes: 27 additions & 22 deletions test/celeritas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -377,29 +377,34 @@ celeritas_add_test(user/StepCollector.test.cc
# DATA UPDATE
#-----------------------------------------------------------------------------#

function(celeritas_add_rootupdate_target target filename)
set(_gdml "${PROJECT_SOURCE_DIR}/test/geocel/data/${filename}.gdml")
set(_basename "${CMAKE_CURRENT_SOURCE_DIR}/data/${filename}")
if(CELERITAS_USE_Geant4)
set(_cmake_env
"${CMAKE_COMMAND}" "-E" "env" "${CELERITASTEST_G4ENV}"
set(_root_data)
if(CELERITAS_USE_Geant4 AND CELERITAS_USE_ROOT)
foreach(_filename "four-steel-slabs" "simple-cms")
set(_gdml "${PROJECT_SOURCE_DIR}/test/geocel/data/${_filename}.gdml")
set(_basename "${CMAKE_CURRENT_SOURCE_DIR}/data/${_filename}")
set(_output "${_basename}.root")
add_custom_command(
OUTPUT "${_output}"
DEPENDS
celer-export-geant
"${_gdml}"
"${_basename}.geant.json"
"${PROJECT_SOURCE_DIR}/src/celeritas/ext/RootInterfaceLinkDef.h"
COMMAND
"${CMAKE_COMMAND}" "-E" "env" ${CELERITASTEST_G4ENV}
"$<TARGET_FILE:celer-export-geant>"
"${_gdml}"
"${_basename}.geant.json"
"${_output}"
VERBATIM
)
else()
set(_cmake_env)
endif()
add_custom_target(${target}
COMMAND
${_cmake_env}
"$<TARGET_FILE:celer-export-geant>"
"${_gdml}"
"${_basename}.geant.json"
"${_basename}.root"
VERBATIM
)
add_dependencies(${target} celer-export-geant)
endfunction()
list(APPEND _root_data "${_output}")
endforeach()
endif()

celeritas_add_rootupdate_target(update-four-slabs four-steel-slabs)
celeritas_add_rootupdate_target(update-simple-cms simple-cms)
add_custom_target(update-root-test-data
COMMENT "Regenerate ROOT test data"
DEPENDS ${_root_data}
)

#-----------------------------------------------------------------------------#
4 changes: 2 additions & 2 deletions test/celeritas/data/four-steel-slabs.geant.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"apply_cuts": false,
"lpm": true,
"max_energy": [
1000000.0,
100000000.0,
"MeV"
],
"min_energy": [
0.0001,
"MeV"
],
"msc": "urban",
"msc": "urban_wentzelvi",
"rayleigh_scattering": true
}

18 changes: 14 additions & 4 deletions test/celeritas/phys/ProcessBuilder.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,26 @@ class ProcessBuilderTest : public Test
CELER_ENSURE(particle() && material());
}

static bool has_env(std::string const& var)
{
bool result = !celeritas::getenv("G4LEDATA").empty();
sethrj marked this conversation as resolved.
Show resolved Hide resolved
if (!result && strict_testing())
{
ADD_FAILURE() << "CI testing requires '" << var
<< "' to be defined";
}
return result;
}

static bool has_le_data()
{
static bool const result = !celeritas::getenv("G4LEDATA").empty();
static bool const result = has_env("G4LEDATA");
return result;
}

static bool has_neutron_data()
{
static bool const result
= !celeritas::getenv("G4PARTICLEXSDATA").empty();
static bool const result = has_env("G4PARTICLEXSDATA");
return result;
}
};
Expand Down Expand Up @@ -558,7 +568,7 @@ TEST_F(ProcessBuilderTest, neutron_elastic)
}
}
}

//---------------------------------------------------------------------------//
} // namespace test
} // namespace celeritas
Loading