From 1e23c89f8eb40f161cf3197682567edd5a7457bf Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Mon, 24 Nov 2025 14:54:41 -0500 Subject: [PATCH] feat(CLI11): Added command line parsing library Added a library for command line option parsing, CLI11. --- .gitignore | 1 + build-config/CLI11/meson.build | 2 + build-config/meson.build | 2 +- subprojects/cli11.wrap | 10 ++++ tests/network/approx8Test.cpp | 91 ---------------------------------- tests/network/meson.build | 23 --------- 6 files changed, 14 insertions(+), 115 deletions(-) create mode 100644 build-config/CLI11/meson.build create mode 100644 subprojects/cli11.wrap delete mode 100644 tests/network/approx8Test.cpp delete mode 100644 tests/network/meson.build diff --git a/.gitignore b/.gitignore index 5ec114b2..1c6a11cf 100644 --- a/.gitignore +++ b/.gitignore @@ -80,6 +80,7 @@ subprojects/libplugin/ subprojects/minizip-ng-4.0.10/ subprojects/cvode-*/ subprojects/kinsol-*/ +subprojects/CLI11-*/ *.fbundle *.wraplock diff --git a/build-config/CLI11/meson.build b/build-config/CLI11/meson.build new file mode 100644 index 00000000..a8549f32 --- /dev/null +++ b/build-config/CLI11/meson.build @@ -0,0 +1,2 @@ +cli11_proj = subproject('cli11') +cli11_dep = cli11_proj.get_variable('CLI11_dep') \ No newline at end of file diff --git a/build-config/meson.build b/build-config/meson.build index 0951b252..864988aa 100644 --- a/build-config/meson.build +++ b/build-config/meson.build @@ -14,4 +14,4 @@ subdir('json') subdir('pybind') - +subdir('CLI11') diff --git a/subprojects/cli11.wrap b/subprojects/cli11.wrap new file mode 100644 index 00000000..00725907 --- /dev/null +++ b/subprojects/cli11.wrap @@ -0,0 +1,10 @@ +[wrap-file] +directory = CLI11-2.6.1 +source_url = https://github.com/CLIUtils/CLI11/archive/refs/tags/v2.6.1.tar.gz +source_filename = CLI11-2.6.1.tar.gz +source_hash = 377691f3fac2b340f12a2f79f523c780564578ba3d6eaf5238e9f35895d5ba95 +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/cli11_2.6.1-1/CLI11-2.6.1.tar.gz +wrapdb_version = 2.6.1-1 + +[provide] +dependency_names = CLI11 \ No newline at end of file diff --git a/tests/network/approx8Test.cpp b/tests/network/approx8Test.cpp deleted file mode 100644 index 72b7fc47..00000000 --- a/tests/network/approx8Test.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include -#include - -#include "fourdst/composition/composition.h" -#include "fourdst/config/config.h" -#include "gridfire/engine/engine_approx8.h" -#include "gridfire/engine/engine_graph.h" -#include "gridfire/network.h" - -#include - - -std::string TEST_CONFIG = std::string(getenv("MESON_SOURCE_ROOT")) + "/tests/testsConfig.yaml"; -class approx8Test : public ::testing::Test {}; - -/** - * @brief Test the constructor of the Config class. - */ -TEST_F(approx8Test, constructor) { - fourdst::config::Config& config = fourdst::config::Config::getInstance(); - config.loadConfig(TEST_CONFIG); - EXPECT_NO_THROW(gridfire::approx8::Approx8Network()); -} - -TEST_F(approx8Test, setStiff) { - gridfire::approx8::Approx8Network network; - EXPECT_NO_THROW(network.setStiff(true)); - EXPECT_TRUE(network.isStiff()); - EXPECT_NO_THROW(network.setStiff(false)); - EXPECT_FALSE(network.isStiff()); -} - -TEST_F(approx8Test, evaluate) { - gridfire::approx8::Approx8Network network; - gridfire::NetIn netIn; - - std::vector comp = {0.708, 2.94e-5, 0.276, 0.003, 0.0011, 9.62e-3, 1.62e-3, 5.16e-4}; - std::vector symbols = {"H-1", "He-3", "He-4", "C-12", "N-14", "O-16", "Ne-20", "Mg-24"}; - - fourdst::composition::Composition composition; - composition.registerSymbol(symbols, true); - composition.setMassFraction(symbols, comp); - bool isFinalized = composition.finalize(true); - EXPECT_TRUE(isFinalized); - - netIn.composition = composition; - netIn.temperature = 1e7; - netIn.density = 1e2; - netIn.energy = 0.0; - - netIn.tMax = 3.15e17; - netIn.dt0 = 1e12; - - gridfire::NetOut netOut; - EXPECT_NO_THROW(netOut = network.evaluate(netIn)); - - double energyFraction = netOut.energy / 1.6433051127589775E+18; - double H1MassFraction = netOut.composition.getMassFraction("H-1")/ 0.50166262445895604; - double He4MassFraction = netOut.composition.getMassFraction("He-4") / 0.48172273720971226; - - double relError = 1e-6; - EXPECT_NEAR(H1MassFraction, 1.0, relError); - EXPECT_NEAR(He4MassFraction, 1.0, relError); - EXPECT_NEAR(energyFraction, 1.0, relError); -} - -TEST_F(approx8Test, reaclib) { - using namespace gridfire; - const std::vector comp = {0.708, 0.0, 2.94e-5, 0.276, 0.003, 0.0011, 9.62e-3, 1.62e-3, 5.16e-4}; - const std::vector symbols = {"H-1", "H-2", "He-3", "He-4", "C-12", "N-14", "O-16", "Ne-20", "Mg-24"}; - - fourdst::composition::Composition composition; - composition.registerSymbol(symbols, true); - composition.setMassFraction(symbols, comp); - [[maybe_unused]] bool didFinalize = composition.finalize(true); - - - NetIn netIn; - netIn.composition = composition; - netIn.temperature = 1e7; - netIn.density = 1e2; - netIn.energy = 0.0; - - netIn.tMax = 3.15e17; - netIn.dt0 = 1e12; - - GraphEngine network(composition); - // NetOut netOut; - // netOut = network.evaluate(netIn); - // std::cout << netOut << std::endl; -} diff --git a/tests/network/meson.build b/tests/network/meson.build deleted file mode 100644 index aa09943d..00000000 --- a/tests/network/meson.build +++ /dev/null @@ -1,23 +0,0 @@ -# Test files for network -test_sources = [ - 'approx8Test.cpp', -] - -foreach test_file : test_sources - exe_name = test_file.split('.')[0] - message('Building test: ' + exe_name) - - # Create an executable target for each test - test_exe = executable( - exe_name, - test_file, - dependencies: [gtest_dep, gtest_main, gridfire_dep, composition_dep], - install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly - ) - - # Add the executable as a test - test( - exe_name, - test_exe, - env: ['MESON_SOURCE_ROOT=' + meson.project_source_root(), 'MESON_BUILD_ROOT=' + meson.project_build_root()]) -endforeach