diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2019-01-18 14:37:53 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2019-01-18 14:47:12 +0000 |
commit | af962c6b821eda777df51700f8710d3cdadbe31f (patch) | |
tree | 54a8bace4910ba1a23bce5e00a51ee5e8c242444 | |
parent | 781b31796f705ba9f6e533dc75bca67b63c57e74 (diff) | |
download | buildstream-af962c6b821eda777df51700f8710d3cdadbe31f.tar.gz |
tests/sources/git.py: Skip tests that assume too new a git
test_track_invalid_submodule depends on being able to remove a submodule
by `git rm $submoduledir`, but old versions of git don't update .gitmodules
so BuildStream still thinks there's a submodule present.
For expediency the test is skipped rather than changed to manually remove
the entry from .gitmodules if git hasn't done it,
since in the common case git is new enough to do that itself.
test_git_describe expects --first-parent to find another tag,
but `bst track` will gracefully degrade if the option doesn't work
so a different history will be retained with old versions of git.
It's of marginal benefit to add additional cruft
to test for different output on old versions of git that won't persist forever.
-rw-r--r-- | tests/sources/git.py | 4 | ||||
-rw-r--r-- | tests/testutils/site.py | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/tests/sources/git.py b/tests/sources/git.py index e0560fe5d..f194e9f54 100644 --- a/tests/sources/git.py +++ b/tests/sources/git.py @@ -30,7 +30,7 @@ from buildstream import _yaml from buildstream.plugin import CoreWarnings from tests.testutils import cli, create_repo -from tests.testutils.site import HAVE_GIT +from tests.testutils.site import HAVE_GIT, HAVE_OLD_GIT DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), @@ -664,6 +664,7 @@ def test_invalid_submodule(cli, tmpdir, datafiles, fail): @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") +@pytest.mark.skipif(HAVE_OLD_GIT, reason="old git rm does not update .gitmodules") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) @pytest.mark.parametrize("fail", ['warn', 'error']) def test_track_invalid_submodule(cli, tmpdir, datafiles, fail): @@ -772,6 +773,7 @@ def test_track_fetch(cli, tmpdir, datafiles, ref_format, tag, extra_commit): @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") +@pytest.mark.skipif(HAVE_OLD_GIT, reason="old git describe lacks --first-parent") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) @pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')]) @pytest.mark.parametrize("tag_type", [('annotated'), ('lightweight')]) diff --git a/tests/testutils/site.py b/tests/testutils/site.py index 6ef22babb..3f810c70b 100644 --- a/tests/testutils/site.py +++ b/tests/testutils/site.py @@ -2,6 +2,7 @@ # so we dont have to repeat this everywhere # import os +import subprocess import sys from buildstream import _site, utils, ProgramNotFoundError @@ -16,8 +17,12 @@ except ProgramNotFoundError: try: utils.get_host_tool('git') HAVE_GIT = True + out = str(subprocess.check_output(['git', '--version']), "utf-8") + version = tuple(int(x) for x in out.split(' ', 2)[2].split('.')) + HAVE_OLD_GIT = version < (1, 8, 4) except ProgramNotFoundError: HAVE_GIT = False + HAVE_OLD_GIT = False try: utils.get_host_tool('ostree') |