Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
31 changes: 28 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ========================================================================================
# (C) (or copyright) 2024. Triad National Security, LLC. All rights reserved.
# (C) (or copyright) 2024-2025. Triad National Security, LLC. All rights reserved.
#
# This program was produced under U.S. Government contract 89233218CNA000001 for Los
# Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC
Expand Down Expand Up @@ -47,7 +47,32 @@ jobs:
VERBOSE=1 CFM=clang-format ./style/format.sh
git diff --exit-code --ignore-submodules

cpu:
unit-tests:
if: >
${{ !contains(github.event.pull_request.title, 'Draft:') &&
!contains(github.event.pull_request.title, 'WIP:') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -qq --no-install-recommends tzdata
sudo apt-get install -qq git
sudo apt-get install -qq make cmake g++
sudo apt-get install -qq libopenmpi-dev libhdf5-openmpi-dev
- name: Build and run unit tests
run: |
export MAKE_PROGRAM=make
mkdir -p build
cd build
cmake --preset=cpu-release ../
make -j 4
ctest -L unit --output-on-failure

regression-tests:
if: >
${{ !contains(github.event.pull_request.title, 'Draft:') &&
!contains(github.event.pull_request.title, 'WIP:') }}
Expand All @@ -65,7 +90,7 @@ jobs:
sudo apt-get install -qq libopenmpi-dev libhdf5-openmpi-dev
sudo apt-get install -qq openssh-client
sudo apt-get install -qq python3 python3-numpy python3-h5py python3-matplotlib
- name: Run CPU tests
- name: Run regression tests
run: |
export MAKE_PROGRAM=make
cd tst
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "external/jaybenne"]
path = external/jaybenne
url = https://github.com/lanl/jaybenne.git
[submodule "external/Catch2"]
path = external/Catch2
url = https://github.com/catchorg/Catch2.git
46 changes: 46 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,49 @@ add_subdirectory(external/jaybenne)
# Add artemis
message("\nConfiguring src")
add_subdirectory(src)

# Configure Catch2 for unit testing
if (NOT TARGET Catch2::Catch2WithMain)
message("Configuring Catch2")
set(CATCH_BUILD_TESTING OFF CACHE BOOL "" FORCE)
set(CATCH_INSTALL_DOCS OFF CACHE BOOL "" FORCE)
set(CATCH_INSTALL_EXTRAS OFF CACHE BOOL "" FORCE)
add_subdirectory(external/Catch2 Catch2)
else()
message(STATUS "Catch2 already configured in this build, skipping.")
endif()

# Enable testing
enable_testing()

# Add unit tests
message("\nConfiguring unit tests")
add_subdirectory(tst/unit)

# Add regression tests
message("\nConfiguring regression tests")
find_package(Python3 COMPONENTS Interpreter)
if(Python3_FOUND)
# Determine which test suite to run based on GPU support
if(ARTEMIS_ENABLE_CUDA OR ARTEMIS_ENABLE_HIP)
set(REGRESSION_SUITE "gpu.suite")
else()
set(REGRESSION_SUITE "regression.suite")
endif()

# Add the regression test
add_test(
NAME regression
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tst/run_tests.py
${REGRESSION_SUITE} --cwd
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

# Set label for regression test
set_tests_properties(regression PROPERTIES LABELS "regression")

message(STATUS "Regression test suite: ${REGRESSION_SUITE}")
message(STATUS "Regression test command: ${Python3_EXECUTABLE} run_tests.py ${REGRESSION_SUITE} --cwd")
else()
message(WARNING "Python3 not found. Regression tests will not be available via CTest.")
endif()
1 change: 1 addition & 0 deletions external/Catch2
Submodule Catch2 added at 970916
47 changes: 47 additions & 0 deletions tst/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ========================================================================================
# (C) (or copyright) 2023-2025. Triad National Security, LLC. All rights reserved.
#
# This program was produced under U.S. Government contract 89233218CNA000001 for Los
# Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC
# for the U.S. Department of Energy/National Nuclear Security Administration. All rights
# in the program are reserved by Triad National Security, LLC, and the U.S. Department
# of Energy/National Nuclear Security Administration. The Government is granted for
# itself and others acting on its behalf a nonexclusive, paid-up, irrevocable worldwide
# license in this material to reproduce, prepare derivative works, distribute copies to
# the public, perform publicly and display publicly, and to permit others to do so.
# ========================================================================================

# This file was created in part or in whole by generative AI

# Unit tests using Catch2

# Helper function to add unit tests
function(add_unit_test TEST_NAME TEST_SOURCE)
add_executable(${TEST_NAME} ${TEST_SOURCE})

target_link_libraries(${TEST_NAME}
PRIVATE
Catch2::Catch2WithMain
parthenon
singularity-eos::singularity-eos
Kokkos::kokkos
)

target_include_directories(${TEST_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../../src
${ARTEMIS_SINGULARITY_INCLUDE_PATHS}
)

# Discover and add tests to CTest
catch_discover_tests(${TEST_NAME}
PROPERTIES LABELS "unit")
endfunction()

# Include Catch2's module for test discovery
include(Catch)

# Add individual unit tests here
add_unit_test(test_ideal_gas test_ideal_gas.cpp)
add_unit_test(test_ideal_hhe test_ideal_hhe.cpp)
add_unit_test(test_geometry test_geometry.cpp)
Loading