| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
""" |
| 4 |
test cases that are only relevant to run in CI |
| 5 |
""" |
| 6 |
|
| 7 |
import os |
| 8 |
import platform |
| 9 |
import subprocess |
| 10 |
import sys |
| 11 |
|
| 12 |
import pytest |
| 13 |
|
| 14 |
sys.path.append(os.path.join(os.path.dirname(__file__), "../tests")) |
| 15 |
from gvtest import ( # pylint: disable=wrong-import-position |
| 16 |
ROOT, |
| 17 |
build_system, |
| 18 |
dot, |
| 19 |
freedesktop_os_release, |
| 20 |
is_cmake, |
| 21 |
is_macos, |
| 22 |
is_mingw, |
| 23 |
is_static_build, |
| 24 |
is_ubuntu_2510, |
| 25 |
run, |
| 26 |
which, |
| 27 |
) |
| 28 |
|
| 29 |
|
| 30 |
@pytest.mark.parametrize( |
| 31 |
"binary", |
| 32 |
[ |
| 33 |
"acyclic", |
| 34 |
"bcomps", |
| 35 |
"ccomps", |
| 36 |
"circo", |
| 37 |
"cluster", |
| 38 |
"diffimg", |
| 39 |
"dijkstra", |
| 40 |
"dot", |
| 41 |
"dot2gxl", |
| 42 |
"dot_builtins", |
| 43 |
"edgepaint", |
| 44 |
"fdp", |
| 45 |
"gc", |
| 46 |
"gml2gv", |
| 47 |
"graphml2gv", |
| 48 |
"gv2gml", |
| 49 |
"gv2gxl", |
| 50 |
"gvcolor", |
| 51 |
"gvedit", |
| 52 |
"gvgen", |
| 53 |
"gvmap", |
| 54 |
"gvmap.sh", |
| 55 |
"gvpack", |
| 56 |
"gvpr", |
| 57 |
"gxl2dot", |
| 58 |
"gxl2gv", |
| 59 |
"mingle", |
| 60 |
"mm2gv", |
| 61 |
"neato", |
| 62 |
"nop", |
| 63 |
"osage", |
| 64 |
"patchwork", |
| 65 |
"prune", |
| 66 |
"sccmap", |
| 67 |
"sfdp", |
| 68 |
"smyrna", |
| 69 |
"tred", |
| 70 |
"twopi", |
| 71 |
"unflatten", |
| 72 |
"vimdot", |
| 73 |
], |
| 74 |
) |
| 75 |
def test_existence(binary: str): |
| 76 |
""" |
| 77 |
check that a given binary was built and is on $PATH |
| 78 |
""" |
| 79 |
|
| 80 |
os_id = freedesktop_os_release().get("ID") |
| 81 |
|
| 82 |
# https://gitlab.com/graphviz/graphviz/-/issues/1834 |
| 83 |
if os_id == "rocky" and binary == "smyrna": |
| 84 |
check_that_tool_does_not_exist(binary, os_id) |
| 85 |
pytest.skip("smyrna is not built for Rocky due to lacking libgts") |
| 86 |
|
| 87 |
if os_id == "rocky" and binary == "mingle": |
| 88 |
check_that_tool_does_not_exist(binary, os_id) |
| 89 |
pytest.skip("mingle is not built for Rocky due to lacking libANN") |
| 90 |
|
| 91 |
if binary == "mingle" and is_mingw(): |
| 92 |
check_that_tool_does_not_exist(binary, os_id) |
| 93 |
pytest.skip(f"{binary} is not built on some Windows due to lacking libANN") |
| 94 |
|
| 95 |
if binary == "gvedit" and platform.system() == "Windows" and not is_mingw(): |
| 96 |
check_that_tool_does_not_exist(binary, os_id) |
| 97 |
pytest.skip(f"{binary} is not built on Windows due to lacking Qt") |
| 98 |
|
| 99 |
# Smyrna dependencies are not avaiable in other jobs |
| 100 |
if binary == "smyrna" and platform.system() != "Linux": |
| 101 |
check_that_tool_does_not_exist(binary, os_id) |
| 102 |
pytest.skip("smyrna is not built on non-Linux due to lacking dependencies") |
| 103 |
|
| 104 |
if binary == "smyrna" and is_ubuntu_2510(): |
| 105 |
check_that_tool_does_not_exist(binary, os_id) |
| 106 |
pytest.skip("smyrna is not built on Ubuntu ≥ 25.10 due to lacking dependencies") |
| 107 |
|
| 108 |
if binary == "gvmap.sh" and platform.system() == "Windows": |
| 109 |
pytest.skip(f"{binary} detection is unreliable on Windows") |
| 110 |
|
| 111 |
if binary == "vimdot" and platform.system() == "Windows": |
| 112 |
check_that_tool_does_not_exist(binary, os_id) |
| 113 |
pytest.skip(f"{binary} is not installed on Windows") |
| 114 |
|
| 115 |
if binary == "vimdot" and not is_cmake() and is_macos(): |
| 116 |
check_that_tool_does_not_exist(binary, os_id) |
| 117 |
pytest.skip("https://gitlab.com/graphviz/graphviz/-/issues/2423") |
| 118 |
|
| 119 |
if binary == "dot_builtins" and is_static_build(): |
| 120 |
pytest.skip("dot_builtins may not be built in a static build") |
| 121 |
|
| 122 |
assert which(binary) is not None |
| 123 |
|
| 124 |
|
| 125 |
def check_that_tool_does_not_exist(tool, os_id): |
| 126 |
""" |
| 127 |
validate that the given tool does *not* exist |
| 128 |
""" |
| 129 |
assert which(tool) is None, ( |
| 130 |
f"{tool} has been resurrected in the " |
| 131 |
f"{build_system()} build on {os_id}. Please remove skip." |
| 132 |
) |
| 133 |
|
| 134 |
|
| 135 |
def test_1786(): |
| 136 |
""" |
| 137 |
png:gd format should be supported |
| 138 |
https://gitlab.com/graphviz/graphviz/-/issues/1786 |
| 139 |
""" |
| 140 |
|
| 141 |
# run a trivial graph through Graphviz |
| 142 |
dot("png:gd", source="digraph { a -> b; }") |
| 143 |
|
| 144 |
|
| 145 |
def test_2469(): |
| 146 |
""" |
| 147 |
svgz format should be supported |
| 148 |
https://gitlab.com/graphviz/graphviz/-/issues/2469 |
| 149 |
""" |
| 150 |
|
| 151 |
# run a trivial graph through Graphviz |
| 152 |
dot("svgz", source="digraph { a -> b; }") |
| 153 |
|
| 154 |
|
| 155 |
def test_installation(): |
| 156 |
""" |
| 157 |
check that Graphviz reports the expected version number |
| 158 |
""" |
| 159 |
|
| 160 |
expected_version = run([sys.executable, ROOT / "gen_version.py"]).strip() |
| 161 |
|
| 162 |
actual_version_string = run(["dot", "-V"], stderr=subprocess.STDOUT) |
| 163 |
try: |
| 164 |
actual_version = actual_version_string.split()[4] |
| 165 |
except IndexError: |
| 166 |
pytest.fail(f"Malformed version string: {actual_version_string}") |
| 167 |
assert actual_version == expected_version |