[libnet-dbus-perl] 51/335: When generating introspection XML, sort interfaces, methods & nodes alphabetically to ensure stable ordering in XML output, and thus make things reliably unit-testable!
Intrigeri
intrigeri at moszumanska.debian.org
Sat Mar 21 01:07:21 UTC 2015
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to branch experimental
in repository libnet-dbus-perl.
commit a0339ec367fdc70f933dd7cb8d536929465a2b65
Author: Daniel P. Berrange <dan at berrange.com>
Date: Thu Apr 28 11:21:14 2005 +0000
When generating introspection XML, sort interfaces, methods & nodes alphabetically to ensure stable ordering in XML output, and thus make things reliably unit-testable!
---
lib/Net/DBus/Introspector.pm | 6 +++---
t/40-introspector.t | 42 +++++++++++++++++++++---------------------
2 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/lib/Net/DBus/Introspector.pm b/lib/Net/DBus/Introspector.pm
index 3d76079..0428c8b 100644
--- a/lib/Net/DBus/Introspector.pm
+++ b/lib/Net/DBus/Introspector.pm
@@ -277,10 +277,10 @@ sub to_xml {
my $xml = '';
$xml .= $indent . '<node name="' . $self->{name} . '">' . "\n";
- foreach my $name (keys %{$self->{interfaces}}) {
+ foreach my $name (sort { $a cmp $b } keys %{$self->{interfaces}}) {
my $interface = $self->{interfaces}->{$name};
$xml .= $indent . ' <interface name="' . $name . '">' . "\n";
- foreach my $mname (keys %{$interface->{methods}}) {
+ foreach my $mname (sort { $a cmp $b } keys %{$interface->{methods}}) {
my $method = $interface->{methods}->{$mname};
$xml .= $indent . ' <method name="' . $mname . '">' . "\n";
@@ -294,7 +294,7 @@ sub to_xml {
$xml .= $indent . ' </method>' . "\n";
}
- foreach my $sname (keys %{$interface->{signals}}) {
+ foreach my $sname (sort { $a cmp $b } keys %{$interface->{signals}}) {
my $signal = $interface->{signals}->{$sname};
$xml .= $indent . ' <signal name="' . $sname . '">' . "\n";
diff --git a/t/40-introspector.t b/t/40-introspector.t
index 14bfe1e..1c2bcab 100644
--- a/t/40-introspector.t
+++ b/t/40-introspector.t
@@ -39,17 +39,17 @@ TEST_ONE: {
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="org.example.Object.OtherObject">
<interface name="org.example.SomeInterface">
+ <method name="goodbye">
+ <arg type="a(is)" direction="in"/>
+ <arg type="s" direction="out"/>
+ <arg type="s" direction="out"/>
+ </method>
<method name="hello">
<arg type="i" direction="in"/>
<arg type="i" direction="in"/>
<arg type="(iy)" direction="in"/>
<arg type="i" direction="out"/>
</method>
- <method name="goodbye">
- <arg type="a(is)" direction="in"/>
- <arg type="s" direction="out"/>
- <arg type="s" direction="out"/>
- </method>
<signal name="meltdown">
<arg type="i"/>
<arg type="y"/>
@@ -104,18 +104,24 @@ EOF
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="org.example.Object">
- <interface name="org.example.SomeInterface">
- <method name="hello">
- <arg type="i" direction="in"/>
+ <interface name="org.example.OtherInterface">
+ <method name="hitme">
<arg type="i" direction="in"/>
- <arg type="(iy)" direction="in"/>
- <arg type="u" direction="out"/>
+ <arg type="u" direction="in"/>
</method>
+ </interface>
+ <interface name="org.example.SomeInterface">
<method name="goodbye">
<arg type="aa{is}" direction="in"/>
<arg type="s" direction="out"/>
<arg type="as" direction="out"/>
</method>
+ <method name="hello">
+ <arg type="i" direction="in"/>
+ <arg type="i" direction="in"/>
+ <arg type="(iy)" direction="in"/>
+ <arg type="u" direction="out"/>
+ </method>
<signal name="meltdown">
<arg type="i"/>
<arg type="y"/>
@@ -126,26 +132,20 @@ EOF
<arg type="s" direction="out"/>
</method>
</interface>
- <interface name="org.example.OtherInterface">
- <method name="hitme">
- <arg type="i" direction="in"/>
- <arg type="u" direction="in"/>
- </method>
- </interface>
<node name="org.example.Object.SubObject"/>
<node name="org.example.Object.OtherObject">
<interface name="org.example.SomeInterface">
+ <method name="goodbye">
+ <arg type="a(is)" direction="in"/>
+ <arg type="s" direction="out"/>
+ <arg type="s" direction="out"/>
+ </method>
<method name="hello">
<arg type="i" direction="in"/>
<arg type="i" direction="in"/>
<arg type="(iy)" direction="in"/>
<arg type="i" direction="out"/>
</method>
- <method name="goodbye">
- <arg type="a(is)" direction="in"/>
- <arg type="s" direction="out"/>
- <arg type="s" direction="out"/>
- </method>
<signal name="meltdown">
<arg type="i"/>
<arg type="y"/>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libnet-dbus-perl.git
More information about the Pkg-perl-cvs-commits
mailing list