From: Matthew Fernandez Date: Tue, 5 Apr 2022 00:13:37 +0000 (-0700) Subject: tests: unify 'bitarray' and 'sprint' test orchestrators X-Git-Tag: 4.0.0~113^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=23cbf6b3a339293af7c5b869b23ad851c2c746fe;p=graphviz tests: unify 'bitarray' and 'sprint' test orchestrators --- diff --git a/lib/cgraph/test_sprint.c b/lib/cgraph/test_sprint.c index 885b4be00..8ead3bb0e 100644 --- a/lib/cgraph/test_sprint.c +++ b/lib/cgraph/test_sprint.c @@ -16,7 +16,17 @@ // 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); } diff --git a/rtest/test_c_utils.py b/rtest/test_c_utils.py index 85df8dd69..b303357c0 100644 --- a/rtest/test_c_utils.py +++ b/rtest/test_c_utils.py @@ -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) diff --git a/rtest/test_regression.py b/rtest/test_regression.py index 8243e6ee4..e288c23c1 100644 --- a/rtest/test_regression.py +++ b/rtest/test_regression.py @@ -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(): """