]> granicus.if.org Git - graphviz/commitdiff
tests: unify 'bitarray' and 'sprint' test orchestrators
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 5 Apr 2022 00:13:37 +0000 (17:13 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 12 Apr 2022 00:00:42 +0000 (17:00 -0700)
lib/cgraph/test_sprint.c
rtest/test_c_utils.py
rtest/test_regression.py

index 885b4be004996362d70fb2edca2bc2bb066c6c33..8ead3bb0ee6de1b0248eefba0cc21d4d88b87c6e 100644 (file)
 
 // print ""
 static void test_empty_string(void) {
+// For some reason, GCC thinks this deserves a compiler warning because
+// `printf("")` is a no-op. Apparently our annotations that tell it `gv_sprint`
+// is `printf` like lead it to decide it is a little _too_ `printf` like.
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-zero-length"
+#endif
   char *s = gv_sprint("");
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
   assert(strcmp(s, "") == 0);
   free(s);
 }
index 85df8dd694fd6a894edae89564fc9fbaeb9df213..b303357c0e452e39e68cf577e0ce177a16746d85 100644 (file)
@@ -2,16 +2,19 @@
 
 import os
 from pathlib import Path
+import platform
 import sys
+import pytest
 
 sys.path.append(os.path.dirname(__file__))
 from gvtest import run_c #pylint: disable=C0413
 
-def test_sprint():
-  """run the sprint unit tests"""
+@pytest.mark.parametrize("utility", ("bitarray", "sprint"))
+def test_utility(utility: str):
+  """run the given utility’s unit tests"""
 
-  # locate the sprint unit tests
-  src = Path(__file__).parent.resolve() / "../lib/cgraph/test_sprint.c"
+  # locate the unit tests
+  src = Path(__file__).parent.resolve() / f"../lib/cgraph/test_{utility}.c"
   assert src.exists()
 
   # locate lib directory that needs to be in the include path
@@ -19,5 +22,7 @@ def test_sprint():
 
   # extra C flags this compilation needs
   cflags = ['-I', lib]
+  if platform.system() != "Windows":
+    cflags += ["-std=gnu99", "-Wall", "-Wextra", "-Werror"]
 
   _, _ = run_c(src, cflags=cflags)
index 8243e6ee4b386cf0817a814d68c9d7e1e8e5f2d0..e288c23c17e144184d3d234e067858a7284cf7e6 100644 (file)
@@ -1718,23 +1718,6 @@ def test_gvmap_fclose():
   # pass this through gvmap
   subprocess.run(["gvmap"], input=input.encode("utf-8"), check=True)
 
-def test_bitarray():
-  """run the bitarray unit tests"""
-
-  # locate the bitarray unit tests
-  src = Path(__file__).parent.resolve() / "../lib/cgraph/test_bitarray.c"
-  assert src.exists()
-
-  # locate lib directory that needs to be in the include path
-  lib = Path(__file__).parent.resolve() / "../lib"
-
-  # extra C flags this compilation needs
-  cflags = ["-I", lib]
-  if platform.system() != "Windows":
-    cflags += ["-std=gnu99", "-Wall", "-Wextra", "-Werror"]
-
-  _, _ = run_c(src, cflags=cflags)
-
 @pytest.mark.skipif(shutil.which("gvpr") is None, reason="gvpr not available")
 def test_gvpr_usage():
   """