]> granicus.if.org Git - graphviz/commitdiff
test case for #1910
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 22 Dec 2020 02:39:02 +0000 (18:39 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 12 Jan 2021 01:39:32 +0000 (17:39 -0800)
rtest/1910.c [new file with mode: 0644]
rtest/test_regression.py

diff --git a/rtest/1910.c b/rtest/1910.c
new file mode 100644 (file)
index 0000000..22f874f
--- /dev/null
@@ -0,0 +1,19 @@
+/* test case for repeated use of agmemread()
+ * (see test_regression.py:test_1910())
+ */
+
+#include <assert.h>
+#include <graphviz/cgraph.h>
+
+#ifdef NDEBUG
+  #error "this code is not intended to be compiled with assertions disabled"
+#endif
+
+int main(void) {
+
+  /* we should be able to parse a trivial graph successfully twice */
+  assert(agmemread("digraph { a -> b }"));
+  assert(agmemread("digraph { a -> b }"));
+
+  return 0;
+}
index 8f0573f7f1615c27e0ac7f1bc9193ccc665523d6..2ca4882653bc46de7eea4100de75c982ed795bdc 100644 (file)
@@ -588,3 +588,36 @@ def test_1909():
                      ' a -> b;\n' \
                      ' b -> c;\n' \
                      '}\n'
+
+@pytest.mark.xfail(strict=True) # FIXME
+def test_1910():
+    '''
+    Repeatedly using agmemread() should have consistent results
+    https://gitlab.com/graphviz/graphviz/-/issues/1910
+    '''
+
+    # FIXME: Remove skip when
+    # https://gitlab.com/graphviz/graphviz/-/issues/1777 is fixed
+    if os.getenv('build_system') == 'msbuild':
+      pytest.skip('Windows MSBuild release does not contain any header files (#1777)')
+
+    # find co-located test source
+    c_src = os.path.abspath(os.path.join(os.path.dirname(__file__), '1910.c'))
+    assert os.path.exists(c_src), 'missing test case'
+
+    # create some scratch space to work in
+    with tempfile.TemporaryDirectory() as tmp:
+
+      # compile our test code
+      exe = os.path.join(tmp, 'a.exe')
+      rt_lib_option = '-MDd' if os.environ.get('configuration') == 'Debug' else '-MD'
+
+      if platform.system() == 'Windows':
+          subprocess.check_call(['cl', c_src, '-Fe:', exe, '-nologo',
+            rt_lib_option, '-link', 'cgraph.lib', 'gvc.lib'])
+      else:
+          cc = os.environ.get('CC', 'cc')
+          subprocess.check_call([cc, c_src, '-o', exe, '-lcgraph', '-lgvc'])
+
+      # run the test
+      subprocess.check_call([exe])