From a1df2e312924e57187e5480566b97b6b4354b139 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 6 Jul 2022 16:49:08 +0200 Subject: [PATCH] Fix UNIT_Server_TEST on Windows Signed-off-by: Silvio --- src/Server_TEST.cc | 14 ++++++++++---- src/Util.cc | 14 +++++++------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/Server_TEST.cc b/src/Server_TEST.cc index f18e16c8a4..6023c036ea 100644 --- a/src/Server_TEST.cc +++ b/src/Server_TEST.cc @@ -1004,7 +1004,9 @@ TEST_P(ServerFixture, IGN_UTILS_TEST_DISABLED_ON_WIN32(ResourcePath)) TEST_P(ServerFixture, GetResourcePaths) { ignition::common::setenv("IGN_GAZEBO_RESOURCE_PATH", - "/tmp/some/path:/home/user/another_path"); + std::string("/tmp/some/path") + + common::SystemPaths::Delimiter() + + std::string("/home/user/another_path")); ServerConfig serverConfig; gazebo::Server server(serverConfig); @@ -1034,7 +1036,9 @@ TEST_P(ServerFixture, GetResourcePaths) TEST_P(ServerFixture, AddResourcePaths) { ignition::common::setenv("IGN_GAZEBO_RESOURCE_PATH", - "/tmp/some/path:/home/user/another_path"); + std::string("/tmp/some/path") + + common::SystemPaths::Delimiter() + + std::string("/home/user/another_path")); ignition::common::setenv("SDF_PATH", ""); ignition::common::setenv("IGN_FILE_PATH", ""); @@ -1063,7 +1067,9 @@ TEST_P(ServerFixture, AddResourcePaths) // Add path msgs::StringMsg_V req; req.add_data("/tmp/new_path"); - req.add_data("/tmp/more:/tmp/even_more"); + req.add_data(std::string("/tmp/more") + + common::SystemPaths::Delimiter() + + std::string("/tmp/even_more")); req.add_data("/tmp/some/path"); bool executed = node.Request("/gazebo/resource_paths/add", req); EXPECT_TRUE(executed); @@ -1082,7 +1088,7 @@ TEST_P(ServerFixture, AddResourcePaths) { char *pathCStr = std::getenv(env); - auto paths = common::Split(pathCStr, ':'); + auto paths = common::Split(pathCStr, common::SystemPaths::Delimiter()); paths.erase(std::remove_if(paths.begin(), paths.end(), [](std::string const &_path) { diff --git a/src/Util.cc b/src/Util.cc index e24718bfac..ca545bf39f 100644 --- a/src/Util.cc +++ b/src/Util.cc @@ -408,7 +408,7 @@ std::vector resourcePaths() char *gzPathCStr = std::getenv(kResourcePathEnv.c_str()); if (gzPathCStr && *gzPathCStr != '\0') { - gzPaths = common::Split(gzPathCStr, ':'); + gzPaths = common::Split(gzPathCStr, common::SystemPaths::Delimiter()); } gzPaths.erase(std::remove_if(gzPaths.begin(), gzPaths.end(), @@ -428,7 +428,7 @@ void addResourcePaths(const std::vector &_paths) char *sdfPathCStr = std::getenv(kSdfPathEnv.c_str()); if (sdfPathCStr && *sdfPathCStr != '\0') { - sdfPaths = common::Split(sdfPathCStr, ':'); + sdfPaths = common::Split(sdfPathCStr, common::SystemPaths::Delimiter()); } // Ignition file paths (for s) @@ -437,7 +437,7 @@ void addResourcePaths(const std::vector &_paths) char *ignPathCStr = std::getenv(systemPaths->FilePathEnv().c_str()); if (ignPathCStr && *ignPathCStr != '\0') { - ignPaths = common::Split(ignPathCStr, ':'); + ignPaths = common::Split(ignPathCStr, common::SystemPaths::Delimiter()); } // Gazebo resource paths @@ -445,7 +445,7 @@ void addResourcePaths(const std::vector &_paths) char *gzPathCStr = std::getenv(kResourcePathEnv.c_str()); if (gzPathCStr && *gzPathCStr != '\0') { - gzPaths = common::Split(gzPathCStr, ':'); + gzPaths = common::Split(gzPathCStr, common::SystemPaths::Delimiter()); } // Add new paths to gzPaths @@ -474,20 +474,20 @@ void addResourcePaths(const std::vector &_paths) // Update the vars std::string sdfPathsStr; for (const auto &path : sdfPaths) - sdfPathsStr += ':' + path; + sdfPathsStr += common::SystemPaths::Delimiter() + path; ignition::common::setenv(kSdfPathEnv.c_str(), sdfPathsStr.c_str()); std::string ignPathsStr; for (const auto &path : ignPaths) - ignPathsStr += ':' + path; + ignPathsStr += common::SystemPaths::Delimiter() + path; ignition::common::setenv( systemPaths->FilePathEnv().c_str(), ignPathsStr.c_str()); std::string gzPathsStr; for (const auto &path : gzPaths) - gzPathsStr += ':' + path; + gzPathsStr += common::SystemPaths::Delimiter() + path; ignition::common::setenv(kResourcePathEnv.c_str(), gzPathsStr.c_str());