delegate handling of multi-config path to CMake (if version 3.20 or later)
This commit is contained in:
@ -11,8 +11,17 @@ endif()
|
|||||||
|
|
||||||
target_link_libraries(test_simple_commands PRIVATE lammps GTest::GMock)
|
target_link_libraries(test_simple_commands PRIVATE lammps GTest::GMock)
|
||||||
add_test(NAME SimpleCommands COMMAND test_simple_commands)
|
add_test(NAME SimpleCommands COMMAND test_simple_commands)
|
||||||
set_tests_properties(SimpleCommands PROPERTIES
|
if(CMAKE_VERSION VERSION_LESS 3.20)
|
||||||
ENVIRONMENT "LAMMPS_PLUGIN_BIN_DIR=${CMAKE_BINARY_DIR}")
|
set_tests_properties(SimpleCommands PROPERTIES
|
||||||
|
ENVIRONMENT "LAMMPS_PLUGIN_DIR=${CMAKE_BINARY_DIR}")
|
||||||
|
else()
|
||||||
|
cmake_path(SET LAMMPS_PLUGIN_BIN_DIR NORMALIZE ${CMAKE_BINARY_DIR})
|
||||||
|
if(CMAKE_CONFIG_TYPE)
|
||||||
|
cmake_path(APPEND LAMMPS_PLUGIN_BIN_DIR ${CMAKE_CONFIG_TYPE})
|
||||||
|
endif()
|
||||||
|
set_tests_properties(SimpleCommands PROPERTIES
|
||||||
|
ENVIRONMENT "LAMMPS_PLUGIN_DIR=${LAMMPS_PLUGIN_BIN_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(test_lattice_region test_lattice_region.cpp)
|
add_executable(test_lattice_region test_lattice_region.cpp)
|
||||||
target_link_libraries(test_lattice_region PRIVATE lammps GTest::GMock)
|
target_link_libraries(test_lattice_region PRIVATE lammps GTest::GMock)
|
||||||
|
|||||||
@ -411,12 +411,9 @@ TEST_F(SimpleCommandsTest, Units)
|
|||||||
#if defined(LMP_PLUGIN)
|
#if defined(LMP_PLUGIN)
|
||||||
TEST_F(SimpleCommandsTest, Plugin)
|
TEST_F(SimpleCommandsTest, Plugin)
|
||||||
{
|
{
|
||||||
const char *bindir = getenv("LAMMPS_PLUGIN_BIN_DIR");
|
const char *bindir = getenv("LAMMPS_PLUGIN_DIR");
|
||||||
const char *config = getenv("CMAKE_CONFIG_TYPE");
|
if (!bindir) GTEST_SKIP() << "LAMMPS_PLUGIN_DIR not set";
|
||||||
if (!bindir) GTEST_SKIP() << "LAMMPS_PLUGIN_BIN_DIR not set";
|
std::string loadfmt = "plugin load {}plugin.so";
|
||||||
std::string loadfmt = platform::path_join("plugin load ", bindir);
|
|
||||||
if (config) loadfmt = platform::path_join(loadfmt, config);
|
|
||||||
loadfmt = platform::path_join(loadfmt, "{}plugin.so");
|
|
||||||
::testing::internal::CaptureStdout();
|
::testing::internal::CaptureStdout();
|
||||||
lmp->input->one(fmt::format(loadfmt, "hello"));
|
lmp->input->one(fmt::format(loadfmt, "hello"));
|
||||||
auto text = ::testing::internal::GetCapturedStdout();
|
auto text = ::testing::internal::GetCapturedStdout();
|
||||||
@ -438,8 +435,7 @@ TEST_F(SimpleCommandsTest, Plugin)
|
|||||||
lmp->input->one("plugin list");
|
lmp->input->one("plugin list");
|
||||||
text = ::testing::internal::GetCapturedStdout();
|
text = ::testing::internal::GetCapturedStdout();
|
||||||
if (verbose) std::cout << text;
|
if (verbose) std::cout << text;
|
||||||
ASSERT_THAT(text, ContainsRegex(".*1: command style plugin hello"
|
ASSERT_THAT(text, ContainsRegex(".*1: command style plugin hello\n.*2: fix style plugin nve2.*"));
|
||||||
".*2: fix style plugin nve2.*"));
|
|
||||||
|
|
||||||
::testing::internal::CaptureStdout();
|
::testing::internal::CaptureStdout();
|
||||||
lmp->input->one(fmt::format(loadfmt, "hello"));
|
lmp->input->one(fmt::format(loadfmt, "hello"));
|
||||||
|
|||||||
Reference in New Issue
Block a user