Skip to content

Commit

Permalink
Save http URIS (fix tests) (#271)
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <louise@openrobotics.org>
  • Loading branch information
chapulina authored Aug 5, 2020
1 parent fb8ece7 commit 2fd9547
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
12 changes: 8 additions & 4 deletions src/SdfGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,11 @@ namespace sdf_generator
/// \brief Recursively go through the child elements of the input element and
/// update all relative URIs to absolute.
///
/// The resulting URI will have a "file://" scheme regardless of whether the
/// original URI had the scheme. i.e, absolute URIs without the "file://"
/// scheme will also be updated by this function.
/// URIs with http / https scheme won't be modified.
///
/// For all other URIs, the resulting URI will have a "file://" scheme
/// regardless of whether the original URI had the scheme. i.e, absolute URIs
/// without the "file://" scheme will also be updated by this function.
/// \param[in] _elem Input element to update
/// \param[in] _prefixPath Path to be prepended to relative URIs.
static void relativeToAbsoluteUri(const sdf::ElementPtr &_elem,
Expand All @@ -214,7 +216,9 @@ namespace sdf_generator
auto uriStr = uriElem->Get<std::string>();
// If the URI starts with "file://", it is assumed to be an
// absolute path, so there is no need to update it.
if (uriStr.find("file://") == std::string::npos)
if (uriStr.find("file://") == std::string::npos &&
uriStr.find("http://") == std::string::npos &&
uriStr.find("https://") == std::string::npos)
{
if (uriStr[0] != '/')
{
Expand Down
11 changes: 1 addition & 10 deletions src/SdfGenerator_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,11 @@ static bool isSubset(const sdf::ElementPtr &_elemA,
{
if (_elemA->GetName() != _elemB->GetName())
{
igndbg << "[" << _elemA->GetName() << "] different from ["
<< _elemB->GetName() << "]" << std::endl;
return false;
}

if (_elemA->GetAttributeCount() != _elemB->GetAttributeCount())
{
igndbg << "[" << _elemA->GetAttributeCount() << "] different from ["
<< _elemB->GetAttributeCount() << "]" << std::endl;
return false;
}

Expand All @@ -71,14 +68,10 @@ static bool isSubset(const sdf::ElementPtr &_elemA,
sdf::ParamPtr attrB = _elemB->GetAttribute(attrA->GetKey());
if (attrA->GetTypeName() != attrB->GetTypeName())
{
igndbg << "[" << attrA->GetTypeName() << "] different from ["
<< attrB->GetTypeName() << "]" << std::endl;
return false;
}
if (attrA->GetAsString() != attrB->GetAsString())
{
igndbg << "[" << attrA->GetAsString() << "] different from ["
<< attrB->GetAsString() << "]" << std::endl;
return false;
}
}
Expand Down Expand Up @@ -855,8 +848,6 @@ TEST_F(GenerateWorldFixture, ModelsInline)
const std::optional<std::string> worldStr = sdf_generator::generateWorld(
this->ecm, worldEntity, this->includeUriMap, this->sdfGenConfig);
ASSERT_TRUE(worldStr.has_value());
// std::cout << "Generated world:" << std::endl;
// std::cout << worldStr << std::endl;
sdf::Root newRoot;
newRoot.LoadSdfString(*worldStr);
EXPECT_TRUE(isSubset(newRoot.Element(), this->root.Element()));
Expand Down

0 comments on commit 2fd9547

Please sign in to comment.