diff --git a/unittest/commands/CMakeLists.txt b/unittest/commands/CMakeLists.txt index f6a73b56b3..1a9984a20e 100644 --- a/unittest/commands/CMakeLists.txt +++ b/unittest/commands/CMakeLists.txt @@ -11,8 +11,17 @@ endif() target_link_libraries(test_simple_commands PRIVATE lammps GTest::GMock) add_test(NAME SimpleCommands COMMAND test_simple_commands) -set_tests_properties(SimpleCommands PROPERTIES - ENVIRONMENT "LAMMPS_PLUGIN_BIN_DIR=${CMAKE_BINARY_DIR}") +if(CMAKE_VERSION VERSION_LESS 3.20) + 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) target_link_libraries(test_lattice_region PRIVATE lammps GTest::GMock) diff --git a/unittest/commands/test_simple_commands.cpp b/unittest/commands/test_simple_commands.cpp index 7e52d24eca..9460a723ee 100644 --- a/unittest/commands/test_simple_commands.cpp +++ b/unittest/commands/test_simple_commands.cpp @@ -411,12 +411,9 @@ TEST_F(SimpleCommandsTest, Units) #if defined(LMP_PLUGIN) TEST_F(SimpleCommandsTest, Plugin) { - const char *bindir = getenv("LAMMPS_PLUGIN_BIN_DIR"); - const char *config = getenv("CMAKE_CONFIG_TYPE"); - if (!bindir) GTEST_SKIP() << "LAMMPS_PLUGIN_BIN_DIR not set"; - std::string loadfmt = platform::path_join("plugin load ", bindir); - if (config) loadfmt = platform::path_join(loadfmt, config); - loadfmt = platform::path_join(loadfmt, "{}plugin.so"); + const char *bindir = getenv("LAMMPS_PLUGIN_DIR"); + if (!bindir) GTEST_SKIP() << "LAMMPS_PLUGIN_DIR not set"; + std::string loadfmt = "plugin load {}plugin.so"; ::testing::internal::CaptureStdout(); lmp->input->one(fmt::format(loadfmt, "hello")); auto text = ::testing::internal::GetCapturedStdout(); @@ -438,8 +435,7 @@ TEST_F(SimpleCommandsTest, Plugin) lmp->input->one("plugin list"); text = ::testing::internal::GetCapturedStdout(); if (verbose) std::cout << text; - ASSERT_THAT(text, ContainsRegex(".*1: command style plugin hello" - ".*2: fix style plugin nve2.*")); + ASSERT_THAT(text, ContainsRegex(".*1: command style plugin hello\n.*2: fix style plugin nve2.*")); ::testing::internal::CaptureStdout(); lmp->input->one(fmt::format(loadfmt, "hello"));