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 19, 2020
1 parent 6253679 commit ab2bb6a
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 @@ -143,7 +143,7 @@ TEST_F(SystemPathsFixture, FileSystemPaths)
putenv(env);
paths.SetFilePathEnv("IGN_FILE_PATH");
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 @@ -259,7 +259,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 @@ -272,7 +272,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 @@ -282,7 +282,7 @@ 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
static char env[1024];
Expand All @@ -291,17 +291,17 @@ TEST_F(SystemPathsFixture, FindFileURI)

sp.SetFilePathEnv("IGN_FILE_PATH");
EXPECT_EQ("IGN_FILE_PATH", 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"};
snprintf(env, sizeof(env), "%s", (newEnv + "=" + dir2).c_str());
putenv(env);

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 ab2bb6a

Please sign in to comment.