]> granicus.if.org Git - graphviz/commitdiff
add a test case for #517
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 24 Jun 2021 02:04:27 +0000 (19:04 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 5 Jul 2021 23:08:39 +0000 (16:08 -0700)
rtest/test_regression.py

index 9d3638d7d631788abd9ff1777f5f4af1f3e951b9..8380564e5b84cf75e117f9d026c82151e991060f 100644 (file)
@@ -243,6 +243,43 @@ def test_167():
   # Graphviz should not have caused a segfault
   assert ret != -signal.SIGSEGV, "Graphviz segfaulted"
 
+@pytest.mark.xfail(strict=True)
+@pytest.mark.skipif(shutil.which("gv2gxl") is None or
+                    shutil.which("gxl2gv") is None,
+                    reason="GXL tools not available")
+def test_517():
+  """
+  round tripping a graph through gv2gxl should not lose HTML labels
+  https://gitlab.com/graphviz/graphviz/-/issues/517
+  """
+
+  # our test case input
+  input = \
+    'digraph{\n' \
+    '  A[label=<<TABLE><TR><TD>(</TD><TD>A</TD><TD>)</TD></TR></TABLE>>]\n' \
+    '  B[label="<TABLE><TR><TD>(</TD><TD>B</TD><TD>)</TD></TR></TABLE>"]\n' \
+    '}'
+
+  # translate it to GXL
+  p = subprocess.Popen(["gv2gxl"], stdin=subprocess.PIPE,
+    stdout=subprocess.PIPE, universal_newlines=True)
+  gxl, _ = p.communicate(input)
+  assert p.returncode == 0
+
+  # translate this back to Dot
+  p = subprocess.Popen(["gxl2gv"], stdin=subprocess.PIPE,
+    stdout=subprocess.PIPE, universal_newlines=True)
+  dot, _ = p.communicate(gxl)
+  assert p.returncode == 0
+
+  # the result should have both expected labels somewhere
+  assert \
+    "label=<<TABLE><TR><TD>(</TD><TD>A</TD><TD>)</TD></TR></TABLE>>" in dot, \
+    "HTML label missing"
+  assert \
+    'label="<TABLE><TR><TD>(</TD><TD>B</TD><TD>)</TD></TR></TABLE>"' in dot, \
+    "regular label missing"
+
 def test_793():
   """
   Graphviz should not crash when using VRML output with a non-writable current