def test_xdot_json(): """ check the output of xdot’s JSON API """ # find our collocated C helper c_src = Path(__file__).parent / "xdot2json.c" # some valid xdot commands to process input = "c 9 -#fffffe00 C 7 -#ffffff P 4 0 0 0 36 54 36 54 0" # ask our C helper to process this try: ret, output, err = run_c(c_src, input=input, link=["xdot"]) except subprocess.CalledProcessError: # FIXME: Remove this try-catch 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)") raise assert ret == 0 assert err == "" if os.getenv("build_system") == "msbuild": pytest.fail("Windows MSBuild unexpectedly passed compilation of a " "Graphviz header. Remove the above try-catch? (#1777)") # confirm the output was what we expected assert output == '[\n' \ '{c : "#fffffe00"},\n' \ '{C : "#ffffff"},\n' \ '{P : [0.000000,0.000000,0.000000,36.000000,54.000000,' \ '36.000000,54.000000,0.000000]}\n' \ ']\n'
def test_2089_2(): """ HTML-like and non-HTML-like strings should peacefully coexist https://gitlab.com/graphviz/graphviz/-/issues/2089 """ # find co-located test source c_src = (Path(__file__).parent / "2089.c").resolve() assert c_src.exists(), "missing test case" # run it ret, stdout, stderr = run_c(c_src, link=["cgraph"]) sys.stdout.write(stdout) sys.stderr.write(stderr) assert ret == 0
def test_itos(): """run the itos unit tests""" # locate the itos unit tests src = Path(__file__).parent.resolve() / "../lib/cgraph/test_itos.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] ret, _, _ = run_c(src, cflags=cflags) assert ret == 0
def test_vmalloc(): """run the vmalloc unit tests""" # locate the vmalloc unit tests src = Path(__file__).parent.resolve() / "../lib/vmalloc/test.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"] ret, _, _ = run_c(src, cflags=cflags) assert ret == 0
def test_package_version(): """ The graphviz_version.h header should define a non-empty PACKAGE_VERSION """ # 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 = (Path(__file__).parent / "check-package-version.c").resolve() assert c_src.exists(), "missing test case" # run the test ret, _, _ = run_c(c_src) assert ret == 0
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 = (Path(__file__).parent / "1910.c").resolve() assert c_src.exists(), "missing test case" # run the test ret, _, _ = run_c(c_src, link=["cgraph", "gvc"]) assert ret == 0
def test_2057(): """ gvToolTred should be usable by user code https://gitlab.com/graphviz/graphviz/-/issues/2057 """ # 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 = (Path(__file__).parent / "2057.c").resolve() assert c_src.exists(), "missing test case" # run the test ret, _, _ = run_c(c_src, link=["gvc"]) assert ret == 0
def test_compile_example(src): """try to compile the example""" # construct an absolute path to the example filepath = Path(__file__).parent.resolve() / ".." / "dot.demo" / src libs = ["cgraph", "gvc"] # FIXME: Remove skip of execution of neatopack.c example when # https://gitlab.com/graphviz/graphviz/-/issues/1800 has been fixed if src == "neatopack.c": pytest.skip("Executing neatopack gives segmentation fault (#1800)") # run the example args = ["-Kneato"] if src in ["demo.c", "dot.c"] else [] ret, out, err = run_c(filepath, args, "graph {a -- b}", link=libs) print(f"returncode: {ret} = 0x{ret:08x}") if ret != 0: print(out) print(err) assert ret == 0
def test_1767(): """ using the Pango plugin multiple times should produce consistent results https://gitlab.com/graphviz/graphviz/-/issues/1767 """ # 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 = (Path(__file__).parent / "1767.c").resolve() assert c_src.exists(), "missing test case" # find our co-located dot input dot = (Path(__file__).parent / "1767.dot").resolve() assert dot.exists(), "missing test case" ret, stdout, _ = run_c(c_src, [dot], link=["cgraph", "gvc"]) assert ret == 0