Skip to content

Commit

Permalink
Fix two tests on Windows (#1779)
Browse files Browse the repository at this point in the history
* Fix Server_TEST and remove some ignition::
* Fix SystemLoader_TEST on Windows
  Use NormalizeDirectoryPath to fix path comparisons.

Signed-off-by: Steve Peters <[email protected]>
  • Loading branch information
scpeters authored Nov 4, 2022
1 parent 61df2c3 commit 6b103a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/Server_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1108,9 +1108,9 @@ TEST_P(ServerFixture, AddResourcePaths)
/////////////////////////////////////////////////
TEST_P(ServerFixture, ResolveResourcePaths)
{
ignition::common::setenv("IGN_GAZEBO_RESOURCE_PATH", "");
ignition::common::setenv("SDF_PATH", "");
ignition::common::setenv("IGN_FILE_PATH", "");
common::setenv("IGN_GAZEBO_RESOURCE_PATH", "");
common::setenv("SDF_PATH", "");
common::setenv("IGN_FILE_PATH", "");

ServerConfig serverConfig;
gazebo::Server server(serverConfig);
Expand Down Expand Up @@ -1143,10 +1143,10 @@ TEST_P(ServerFixture, ResolveResourcePaths)
});

// Make sure the resource path is clear
ignition::common::setenv("IGN_GAZEBO_RESOURCE_PATH", "");
common::setenv("IGN_GAZEBO_RESOURCE_PATH", "");

// An absolute path should return the same absolute path
test(PROJECT_SOURCE_PATH, PROJECT_SOURCE_PATH, true);
// A valid path should be returned as an absolute path
test(PROJECT_SOURCE_PATH, common::absPath(PROJECT_SOURCE_PATH), true);

// An absolute path, with the file:// prefix, should return the absolute path
test(std::string("file://") +
Expand All @@ -1168,7 +1168,7 @@ TEST_P(ServerFixture, ResolveResourcePaths)

// The model:// URI should not resolve
test("model://include_nested/model.sdf", "", false);
ignition::common::setenv("IGN_GAZEBO_RESOURCE_PATH",
common::setenv("IGN_GAZEBO_RESOURCE_PATH",
common::joinPaths(PROJECT_SOURCE_PATH, "test", "worlds", "models"));
// The model:// URI should now resolve because the RESOURCE_PATH has been
// updated.
Expand Down
9 changes: 5 additions & 4 deletions src/SystemLoader_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <sdf/World.hh>

#include <ignition/common/Filesystem.hh>
#include <ignition/common/SystemPaths.hh>
#include "ignition/gazebo/System.hh"
#include "ignition/gazebo/SystemLoader.hh"

Expand Down Expand Up @@ -93,13 +94,13 @@ TEST(SystemLoader, PluginPaths)
for (const auto &s : paths)
{
// the returned path string may not be exact match due to extra '/'
// appended at the end of the string. So use absPath to generate
// a path string that matches the format returned by joinPaths
if (common::absPath(s) == testBuildPath)
// appended at the end of the string. So use NormalizeDirectoryPath
if (common::SystemPaths::NormalizeDirectoryPath(s) ==
common::SystemPaths::NormalizeDirectoryPath(testBuildPath))
{
hasPath = true;
break;
}
}
EXPECT_TRUE(hasPath);
EXPECT_TRUE(hasPath) << testBuildPath;
}

0 comments on commit 6b103a0

Please sign in to comment.