forked from AcademySoftwareFoundation/rez
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix --fail-graph when there is indirect cycles (AcademySoftwareFounda…
…tion#1620) Fix --fail-graph when there is indirect cycles (AcademySoftwareFoundation#1620) Signed-off-by: Michael Nowakowski <m_nowakowski@apple.com> Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com> Co-authored-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com> Signed-off-by: Jose Enriquez <jose.enriquez@barnstormvfx.com>
- Loading branch information
1 parent
1105bbf
commit dccddda
Showing
2 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright Contributors to the Rez Project | ||
|
||
|
||
""" | ||
unit tests for 'utils.resolve_graph' module | ||
""" | ||
from rez.tests.util import TestBase | ||
from rez.utils import resolve_graph | ||
import rez.utils.graph_utils | ||
import unittest | ||
|
||
|
||
class TestResolveGraph(TestBase): | ||
def test_conflict_graph_with_cycle(self): | ||
""" Tests creating a test digraph which contains a cycle foo-1.0.0 => bar-0.0.1 => !foo-1.0.0 | ||
Note that the solver doesn't detect this as a cycle. See #1568 | ||
""" | ||
|
||
g = ''' | ||
digraph g { | ||
_1 [label="foo-1", fontsize="10", fillcolor="#FFFFAA", style="filled,dashed"]; | ||
_2 [label="bar", fontsize="10", fillcolor="#FFFFAA", style="filled,dashed"]; | ||
_6 [label="foo-1.0.0[]", fontsize="10", fillcolor="#AAFFAA", style="filled"]; | ||
_7 [label="bar-0.0.1[]", fontsize="10", fillcolor="#AAFFAA", style="filled"]; | ||
_8 [label="!foo-1.0.0", fontsize="10", fillcolor="#F6F6F6", style="filled,dashed"]; | ||
_1 -> _6 [arrowsize="0.5"]; | ||
_2 -> _7 [arrowsize="0.5"]; | ||
_6 -> _2 [arrowsize="0.5"]; | ||
_7 -> _8 [arrowsize="0.5"]; | ||
_8 -> _6 [arrowsize="1", style="bold", color="red", fontcolor="red", label=CONFLICT]; | ||
} | ||
''' | ||
graph = rez.utils.graph_utils.read_graph_from_string(g) | ||
# strip extra quoting from fill color | ||
for k, v in graph.node_attr.items(): | ||
for index, a in enumerate(v): | ||
if a[0] == "fillcolor": | ||
stripped_color = a[1].strip("'").strip('"') | ||
v[index] = ("fillcolor", stripped_color) | ||
|
||
# attempt to graph result | ||
result = resolve_graph.failure_detail_from_graph(graph) | ||
self.assertTrue("foo-1 --> foo-1.0.0 --> bar-0.0.1 --> !foo-1.0.0" in result) | ||
self.assertTrue("bar --> bar-0.0.1 --> !foo-1.0.0" in result) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters