]> granicus.if.org Git - graphviz/commitdiff
add #2184 test cases
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 10 Mar 2022 03:41:56 +0000 (19:41 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 17 Mar 2022 04:14:10 +0000 (21:14 -0700)
rtest/2184.dot [new file with mode: 0644]
rtest/test_regression.py

diff --git a/rtest/2184.dot b/rtest/2184.dot
new file mode 100644 (file)
index 0000000..655234c
--- /dev/null
@@ -0,0 +1,23 @@
+digraph G {
+       subgraph clusterSurround1 {
+
+               subgraph cluster1 {
+                       graph [color=purple]
+                       x1 -> y1 
+                       x1 -> z1 
+               }
+               subgraph cluster2 {
+                       graph [color=pink]
+                       x2 -> y2 
+                       x2 -> z2
+                       subgraph cluster2a {
+                               graph [color=blue  label=C2 boss=worker]                        
+                               x21 ->x22
+                       }
+               }
+               q0 -> x2;
+               z2 -> x1
+       }
+       graph [label="My Cool Graph" fontcolor=red id=boss]  //  this line will be repositioned
+}
+
index cc46c2c60f38bc9172ea1d9bda5f065eadb5a3af..63e90948c7a12f0e5440f5e6a3effdf7e94e0ec7 100644 (file)
@@ -1398,6 +1398,45 @@ def test_2179_1():
   assert "Warning: no hard-coded metrics for" not in stderr, \
     "incorrect warning triggered"
 
+@pytest.mark.skipif(shutil.which("nop") is None, reason="nop not available")
+@pytest.mark.xfail(strict=True) # FIXME
+def test_2184_1():
+  """
+  nop should not reposition labelled graph nodes
+  https://gitlab.com/graphviz/graphviz/-/issues/2184
+  """
+
+  # run `nop` on a sample with a labelled graph node at the end
+  source = Path(__file__).parent / "2184.dot"
+  assert source.exists(), "missing test case"
+  nopped = subprocess.check_output(["nop", source], universal_newlines=True)
+
+  # the normalized output should have a graph with no label within
+  # `clusterSurround1`
+  m = re.search(r'\bclusterSurround1\b.*\bgraph\b.*\bcluster1\b', nopped,
+                flags=re.DOTALL)
+  assert m is not None, \
+    "nop rearranged a graph in a not-semantically-preserving way"
+
+@pytest.mark.xfail(strict=True) # FIXME
+def test_2184_2():
+  """
+  canonicalization should not reposition labelled graph nodes
+  https://gitlab.com/graphviz/graphviz/-/issues/2184
+  """
+
+  # canonicalize a sample with a labelled graph node at the end
+  source = Path(__file__).parent / "2184.dot"
+  assert source.exists(), "missing test case"
+  canonicalized = dot("canon", source)
+
+  # the canonicalized output should have a graph with no label within
+  # `clusterSurround1`
+  m = re.search(r'\bclusterSurround1\b.*\bgraph\b.*\bcluster1\b', canonicalized,
+                flags=re.DOTALL)
+  assert m is not None, \
+    "`dot -Tcanon` rearranged a graph in a not-semantically-preserving way"
+
 def test_2185_1():
   """
   GVPR should deal with strings correctly