gazebosim / sdformat

Simulation Description Format (SDFormat) parser and description files.
http://sdformat.org
Apache License 2.0
169 stars 97 forks source link

Empty attributes in a <plugin/> tag are not printed by Element::ToString unless they are in a custom XML namespace #1421

Closed scpeters closed 6 months ago

scpeters commented 6 months ago

Environment

Description

Steps to reproduce

  1. Apply the following patch (from https://github.com/gazebosim/sdformat/pull/1407#issuecomment-2088798546):
diff --git a/test/integration/plugin_attribute.cc b/test/integration/plugin_attribute.cc
index 7f4f9f4c..b66c9da1 100644
--- a/test/integration/plugin_attribute.cc
+++ b/test/integration/plugin_attribute.cc
@@ -65,4 +65,9 @@ TEST(PluginAttribute, ParseAttributes)
     EXPECT_EQ(value->Get<std::string>(""),
               std::string("value"));
   }
+  {
+    auto pluginToString = plugin->ToString("");
+    EXPECT_NE(std::string::npos, pluginToString.find("empty_attribute=''"))
+      << pluginToString;
+  }
 }
  1. Build and run INTEGRATION_plugin_attribute test
  2. Observe test failure
[ RUN      ] PluginAttribute.ParseAttributes
/Users/scpeters/ws/dome/src/sdformat/test/integration/plugin_attribute.cc:70: Failure
Expected: (std::string::npos) != (pluginToString.find("empty_attribute=''")), actual: 18446744073709551615 vs 18446744073709551615
<plugin name='example' filename='libexample.so'>
  <user attribute='attribute'/>
  <value attribute='attribute'>value</value>
</plugin>

[  FAILED  ] PluginAttribute.ParseAttributes (56 ms)

Output

scpeters commented 6 months ago

As I noted in https://github.com/gazebosim/sdformat/pull/1407#issuecomment-2088798546, I don't have a good idea for how to fix this. I'm going to close this as "won't fix", but feel free to comment here if you have an idea and we can reconsider it.