From 091926ef742fa51430b8e68c35d0f030978ed3fa Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 23 Mar 2022 19:24:52 -0700 Subject: [PATCH] move installation test into CI-only tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This test was introduced in !1347¹ in response to some version confusion due to the Graphviz version being generated in several different places. Locally, this test could fail misleadingly if the developer had new commits in their Graphviz checkout and had not recompiled. But these failures are not relevant; running the test suite against a slightly different version of Graphviz should not unconditionally fail one of the tests. Moreover a developer working locally is generally only running a single work flow, so their local Graphviz version is generated in a single place. The place where we do worry about version divergence is in CI, where the steps for generating the Graphviz version for different platforms are in different places and can accidentally skew. So this change makes the test only run in CI, not locally. Note that we can also drop the conditional logic to recover the version from the GRAPHVIZ_VERSION file because the `$GV_VERSION` environment variable is defined in all the CI testing jobs. ¹ https://gitlab.com/graphviz/graphviz/-/merge_requests/1347 --- ci/tests.py | 22 +++++++++++ configure.ac | 1 - tests/regression_tests/Makefile.am | 2 +- .../regression_tests/installation/Makefile.am | 2 - .../installation/test_installation.py | 38 ------------------- 5 files changed, 23 insertions(+), 42 deletions(-) delete mode 100644 tests/regression_tests/installation/Makefile.am delete mode 100644 tests/regression_tests/installation/test_installation.py diff --git a/ci/tests.py b/ci/tests.py index a2a2dae10..4d9c8777b 100644 --- a/ci/tests.py +++ b/ci/tests.py @@ -8,6 +8,7 @@ import os from pathlib import Path import platform import shutil +import subprocess import sys from typing import Dict import pytest @@ -195,3 +196,24 @@ def test_1786(): # run a trivial graph through Graphviz dot("png:gd", source="digraph { a -> b; }") + +def test_installation(): + """ + check that Graphviz reports the expected version number + """ + + expected_version = os.environ["GV_VERSION"] + + actual_version_string = subprocess.check_output( + [ + "dot", + "-V", + ], + universal_newlines=True, + stderr=subprocess.STDOUT, + ) + try: + actual_version = actual_version_string.split()[4] + except IndexError: + pytest.fail(f"Malformed version string: {actual_version_string}") + assert actual_version == expected_version diff --git a/configure.ac b/configure.ac index 703ee1048..02e15c657 100644 --- a/configure.ac +++ b/configure.ac @@ -2746,7 +2746,6 @@ AC_CONFIG_FILES(Makefile tests/unit_tests/lib/Makefile tests/unit_tests/lib/common/Makefile tests/regression_tests/Makefile - tests/regression_tests/installation/Makefile tests/regression_tests/shapes/Makefile tests/regression_tests/shapes/reference/Makefile tests/regression_tests/vuln/Makefile diff --git a/tests/regression_tests/Makefile.am b/tests/regression_tests/Makefile.am index 41125d9f3..ea04cf01f 100644 --- a/tests/regression_tests/Makefile.am +++ b/tests/regression_tests/Makefile.am @@ -1,3 +1,3 @@ -SUBDIRS = installation shapes vuln +SUBDIRS = shapes vuln EXTRA_DIST = regression_test_helpers.py diff --git a/tests/regression_tests/installation/Makefile.am b/tests/regression_tests/installation/Makefile.am deleted file mode 100644 index 438b2206c..000000000 --- a/tests/regression_tests/installation/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -EXTRA_DIST = \ - test_installation.py diff --git a/tests/regression_tests/installation/test_installation.py b/tests/regression_tests/installation/test_installation.py deleted file mode 100644 index b0f59518f..000000000 --- a/tests/regression_tests/installation/test_installation.py +++ /dev/null @@ -1,38 +0,0 @@ -""" -Graphviz version consistency tests -""" - -import os -from pathlib import Path -import subprocess -import sys -import pytest - -def test_installation(): - """ - check that Graphviz reports the expected version number - """ - - expected_version = os.environ.get("GV_VERSION") - - # If $GV_VERSION is not set, run the CI step that derives it. This will fail - # if the user is in a snapshot directory without Git installed, but assume - # they can live with that. - if expected_version is None: - ROOT = Path(__file__).parent.parent.parent.parent - expected_version = subprocess.check_output([sys.executable, - "gen_version.py"], cwd=ROOT, universal_newlines=True).strip() - - actual_version_string = subprocess.check_output( - [ - "dot", - "-V", - ], - universal_newlines=True, - stderr=subprocess.STDOUT, - ) - try: - actual_version = actual_version_string.split()[4] - except IndexError: - pytest.fail(f"Malformed version string: {actual_version_string}") - assert actual_version == expected_version -- 2.50.1