提交 265349a7 编写于 作者: L Lukáš Doktor

tree: Sort TreeEnvironment on fingerprint

The fingerprint must be static across executions, but TreeEnvironment is
simple unsorted dictionary. Let's sort it on demand (usually only for
fingerprint).
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 7d401ce5
......@@ -84,12 +84,31 @@ class TreeEnvironment(dict):
return cpy
def __str__(self):
"""
String representation using __str__ on items to improve readability
"""
return self.to_text(False)
def to_text(self, sort=False):
"""
Human readable representation
:param sort: Sorted to provide stable output
:rtype: str
"""
def _iteritems_sorted(dictionary):
return sorted(iteritems(dictionary))
# Use __str__ instead of __repr__ to improve readability
if self:
_values = ["%s: %s" % _ for _ in iteritems(self)]
if sort:
_iteritems = _iteritems_sorted
else:
_iteritems = iteritems
_values = ["%s: %s" % _ for _ in _iteritems(self)]
values = "{%s}" % ", ".join(_values)
_origin = ["%s: %s" % (key, node.path)
for key, node in iteritems(self.origin)]
for key, node in _iteritems(self.origin)]
origin = "{%s}" % ", ".join(_origin)
else:
values = "{}"
......@@ -133,7 +152,7 @@ class TreeNodeEnvOnly(object):
return True
def fingerprint(self):
return "%s%s" % (self.path, self.environment)
return "%s%s" % (self.path, self.environment.to_text(True))
def get_environment(self):
return self.environment
......@@ -225,7 +244,7 @@ class TreeNode(object):
"""
Reports string which represents the value of this node.
"""
return "%s%s" % (self.path, self.environment)
return "%s%s" % (self.path, self.environment.to_text(True))
def add_child(self, node):
"""
......
......@@ -14,7 +14,7 @@ basedir = os.path.abspath(basedir)
AVOCADO = os.environ.get("UNITTEST_AVOCADO_CMD", "./scripts/avocado")
DEBUG_OUT = b"""
Variant mint-debug-amd-virtio-a9d2: amd@optional_plugins/varianter_yaml_to_mux/tests/.data/mux-environment.yaml, virtio@optional_plugins/varianter_yaml_to_mux/tests/.data/mux-environment.yaml, mint@optional_plugins/varianter_yaml_to_mux/tests/.data/mux-environment.yaml, debug@optional_plugins/varianter_yaml_to_mux/tests/.data/mux-environment.yaml
Variant mint-debug-amd-virtio-022a: amd@optional_plugins/varianter_yaml_to_mux/tests/.data/mux-environment.yaml, virtio@optional_plugins/varianter_yaml_to_mux/tests/.data/mux-environment.yaml, mint@optional_plugins/varianter_yaml_to_mux/tests/.data/mux-environment.yaml, debug@optional_plugins/varianter_yaml_to_mux/tests/.data/mux-environment.yaml
/distro/mint:init => systemv@optional_plugins/varianter_yaml_to_mux/tests/.data/mux-environment.yaml:/distro/mint
/env/debug:opt_CFLAGS => -O0 -g@optional_plugins/varianter_yaml_to_mux/tests/.data/mux-environment.yaml:/env/debug
/hw/cpu/amd:cpu_CFLAGS => -march=athlon64@optional_plugins/varianter_yaml_to_mux/tests/.data/mux-environment.yaml:/hw/cpu/amd
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册