Skip to content

Commit

Permalink
PR fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Brawner <[email protected]>
  • Loading branch information
brawner committed Feb 3, 2021
1 parent 5c20175 commit f667520
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 61 deletions.
1 change: 0 additions & 1 deletion src/Utils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <string>
#include <optional>
#include <vector>
#include "sdf/Console.hh"
#include "sdf/Error.hh"
#include "sdf/Element.hh"
#include "sdf/ParserConfig.hh"
Expand Down
12 changes: 2 additions & 10 deletions src/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -729,11 +729,7 @@ bool readDoc(tinyxml2::XMLDocument *_xmlDoc, ElementPtr _sdf,
if (_convert
&& strcmp(sdfNode->Attribute("version"), SDF::Version().c_str()) != 0)
{
std::stringstream ss;
ss << "Converting a deprecated SDF source[" << _source << "].\n";
addRecoverableWarning(
_config.WarningsPolicy(), ss.str(),
ErrorCode::VERSION_DEPRECATED, _errors);
sdfdbg << "Converting a deprecated SDF source[" << _source << "].\n";

Converter::Convert(_xmlDoc, SDF::Version());
}
Expand Down Expand Up @@ -1273,15 +1269,11 @@ bool readXml(tinyxml2::XMLElement *_xml, ElementPtr _sdf,
if (descCounter == _sdf->GetElementDescriptionCount()
&& std::strchr(elemXml->Value(), ':') == nullptr)
{
std::stringstream ss;
ss << "XML Element[" << elemXml->Value()
sdfdbg << "XML Element[" << elemXml->Value()
<< "], child of element[" << _xml->Value()
<< "], not defined in SDF. Copying[" << elemXml->Value() << "] "
<< "as children of [" << _xml->Value() << "].\n";

addRecoverableWarning(
_config.WarningsPolicy(), ss.str(),
ErrorCode::ELEMENT_INCORRECT_TYPE, _errors);
continue;
}
}
Expand Down
48 changes: 0 additions & 48 deletions test/integration/unknown.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,51 +83,3 @@ TEST(Unknown, CopyUnknownElement)
EXPECT_EQ("my nested xml", nestedElem->Get<std::string>("attr"));
EXPECT_EQ("AString", nestedElem->Get<std::string>("string"));
}

/////////////////////////////////////////////////
/// Test that elements that aren't part of the spec are flagged with pedantic
/// warnings
TEST(UnrecognizedElements, UnrecognizedElementsWithWarningsPolicies)
{
const std::string testFile =
sdf::filesystem::append(PROJECT_SOURCE_PATH, "test", "sdf",
"unrecognized_elements.sdf");

sdf::ParserConfig config;

{
config.SetWarningsPolicy(sdf::WarningsPolicy::PEDANTIC);
sdf::Root root;
const auto errors = root.Load(testFile, config);
EXPECT_FALSE(errors.empty());
}
{
config.SetWarningsPolicy(sdf::WarningsPolicy::WARNED);
sdf::Root root;
const auto errors = root.Load(testFile, config);
EXPECT_TRUE(errors.empty());
}
{
config.SetWarningsPolicy(sdf::WarningsPolicy::IGNORED);
sdf::Root root;
const auto errors = root.Load(testFile, config);
EXPECT_TRUE(errors.empty());
}
}

/////////////////////////////////////////////////
/// Test that elements that aren't part of the spec but have the namespace
/// separator ":" don't cause errors even with pendatic
TEST(UnrecognizedElements, UnrecognizedElementsWithNamespaces)
{
const std::string testFile =
sdf::filesystem::append(PROJECT_SOURCE_PATH, "test", "sdf",
"unrecognized_elements_with_namespace.sdf");

sdf::ParserConfig config;
config.SetWarningsPolicy(sdf::WarningsPolicy::PEDANTIC);

sdf::Root root;
const auto errors = root.Load(testFile, config);
EXPECT_FALSE(errors.empty());
}
4 changes: 2 additions & 2 deletions test/sdf/unrecognized_elements_with_namespace.sdf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" ?>
<sdf version="1.6">
<model name="joint_incorrect_tags" some_attribute="staheousth">
<sdf version="1.8" xmlns:third_party_software="custom_ns_uri">
<model name="joint_incorrect_tags" some_attribute="some value">
<link name="link">
<pose>0 0 1 0 0 0</pose>
<third_party_software:not_a_link_element>This should be ignored because it's namespaced</third_party_software:not_a_link_element>
Expand Down

0 comments on commit f667520

Please sign in to comment.