From ffc2e8d391a67b1d56459dd7278aa7b96c89e828 Mon Sep 17 00:00:00 2001 From: Magnus Jacobsson Date: Mon, 27 Jul 2020 12:46:52 +0200 Subject: [PATCH] Make test_installation.py self-contained to run also on Windows Also removed the now obsolete check_installation.sh bash script. --- .gitlab-ci.yml | 3 ++- .../regression_tests/installation/Makefile.am | 3 +-- .../installation/check_installation.sh | 1 - .../installation/test_installation.py | 20 ++++++++++++++----- 4 files changed, 18 insertions(+), 9 deletions(-) delete mode 100755 tests/regression_tests/installation/check_installation.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 77405a6cb..93527be64 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -92,7 +92,7 @@ portable-source: msbuild /p:Configuration=$env:configuration } # Package - - $GV_VERSION=$( cat VERSION ) + - $Env:GV_VERSION=$( cat VERSION ) - >- if($env:platform -eq "x64") { $API = "win64"; @@ -172,6 +172,7 @@ portable-source: stage: test script: - ci/install-packages.sh + - export GV_VERSION=$( cat VERSION ) - python3 -m pytest --junitxml=report.xml tests rtest artifacts: reports: diff --git a/tests/regression_tests/installation/Makefile.am b/tests/regression_tests/installation/Makefile.am index 1fe871c88..55b238068 100644 --- a/tests/regression_tests/installation/Makefile.am +++ b/tests/regression_tests/installation/Makefile.am @@ -1,6 +1,5 @@ check test rtest: - ./check_installation.sh + python3 -m pytest EXTRA_DIST = \ - check_installation.sh \ test_installation.py diff --git a/tests/regression_tests/installation/check_installation.sh b/tests/regression_tests/installation/check_installation.sh deleted file mode 100755 index 33e34ba9a..000000000 --- a/tests/regression_tests/installation/check_installation.sh +++ /dev/null @@ -1 +0,0 @@ -dot -V 2>&1 | grep "dot - graphviz version ${GV_VERSION}" || (dot -V && false) diff --git a/tests/regression_tests/installation/test_installation.py b/tests/regression_tests/installation/test_installation.py index daf43b328..7985eface 100644 --- a/tests/regression_tests/installation/test_installation.py +++ b/tests/regression_tests/installation/test_installation.py @@ -1,9 +1,19 @@ +import pytest import subprocess import os def test_installation(): - os.chdir(os.path.dirname(os.path.realpath(__file__))) - result = subprocess.Popen(['bash', './check_installation.sh']) - text = result.communicate()[0] - print(text) - assert result.returncode == 0 + 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('Malformed version string: {0}'.format(actual_version_string)) + assert actual_version == expected_version -- 2.40.0