Skip to content

Commit

Permalink
Fix API differences between URI in 3 and 4
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <michael@openrobotics.org>
  • Loading branch information
mjcarroll committed Oct 27, 2020
1 parent 466164e commit 68d9445
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/SystemPaths.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ std::string SystemPaths::FindFileURI(const std::string &_uri) const
}

const auto uri = ignition::common::URI(_uri);
std::cout << "Debug URI[" << uri.Str() << "]\n";
return this->FindFileURI(uri);
}

Expand Down
16 changes: 8 additions & 8 deletions src/SystemPaths_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ TEST_F(SystemPathsFixture, FileSystemPaths)
common::setenv(kFilePath, SystemPathsJoin(filePaths));
paths.SetFilePathEnv(kFilePath);
EXPECT_EQ(file1, paths.FindFile("test_f1")) << paths.FindFile("test_f1");
EXPECT_EQ(file1, paths.FindFile("model://test_f1"));
EXPECT_EQ(file1, paths.FindFile("model:test_f1"));
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -243,7 +243,7 @@ TEST_F(SystemPathsFixture, FindFileURI)
};

EXPECT_EQ("", sp.FindFileURI("robot://test_f1"));
EXPECT_EQ("", sp.FindFileURI("osrf://test_f2"));
EXPECT_EQ("", sp.FindFileURI("osrf:test_f2"));

// We still want to test the deprecated function until it is removed.
#ifndef _WIN32
Expand All @@ -256,7 +256,7 @@ TEST_F(SystemPathsFixture, FindFileURI)
#endif

EXPECT_EQ(file1, sp.FindFileURI("robot://test_f1"));
EXPECT_EQ("", sp.FindFileURI("osrf://test_f2"));
EXPECT_EQ("", sp.FindFileURI("osrf:test_f2"));

sp.AddFindFileURICallback(osrfCb);
EXPECT_EQ(file1, sp.FindFileURI("robot://test_f1"));
Expand All @@ -266,21 +266,21 @@ TEST_F(SystemPathsFixture, FindFileURI)
// second handler for the same protocol is available
sp.AddFindFileURICallback(robot2Cb);
EXPECT_EQ(file1, sp.FindFileURI("robot://test_f1"));
EXPECT_EQ(file2, sp.FindFileURI("osrf://test_f2"));
EXPECT_EQ(file2, sp.FindFileURI("osrf:test_f2"));

// URI + env var
common::setenv(kFilePath, dir1);
sp.SetFilePathEnv(kFilePath);
EXPECT_EQ(kFilePath, sp.FilePathEnv());
EXPECT_EQ(file1, sp.FindFileURI("anything://test_f1"));
EXPECT_NE(file2, sp.FindFileURI("anything://test_f2"));
EXPECT_EQ(file1, sp.FindFileURI("anything:test_f1"));
EXPECT_NE(file2, sp.FindFileURI("anything:test_f2"));

std::string newEnv{"IGN_NEW_FILE_PATH"};
common::setenv(newEnv, dir2);
sp.SetFilePathEnv(newEnv);
EXPECT_EQ(newEnv, sp.FilePathEnv());
EXPECT_NE(file1, sp.FindFileURI("anything://test_f1"));
EXPECT_EQ(file2, sp.FindFileURI("anything://test_f2"));
EXPECT_NE(file1, sp.FindFileURI("anything:test_f1"));
EXPECT_EQ(file2, sp.FindFileURI("anything:test_f2"));
}

//////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/Util_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ TEST(Util_TEST, findFile)
"test_f1"), true));

// Relative prefixed by file://
EXPECT_EQ(file1, ignition::common::findFile("file://test_dir1/test_f1"));
EXPECT_EQ(file1, ignition::common::findFile("file:test_dir1/test_f1"));

// Custom callback
#ifndef _WIN32
Expand Down

0 comments on commit 68d9445

Please sign in to comment.