diff options
author | Chandan Singh <csingh43@bloomberg.net> | 2019-01-29 14:58:44 +0000 |
---|---|---|
committer | Chandan Singh <csingh43@bloomberg.net> | 2019-01-29 14:58:44 +0000 |
commit | c324f1cb61e5616ba57338acbeb4e2baae5237de (patch) | |
tree | eeb1d5741f827abcb12b814cb0864cbad1fe67cf | |
parent | aae35e13e8f5ed550d7ccdd6611482c225a4ff81 (diff) | |
download | buildstream-chandan/fix-git-version-mac.tar.gz |
testutils/site.py: Support parsing more exotic git versionschandan/fix-git-version-mac
We use output of `git --version` to determine if we can run some tests
that rely on features from newer git versions. Usually, we expect the
output to be like:
git version 2.17.2
On some platforms, like MacOS, there could be a suffix after the version
string, so that it looks something like:
git version 2.17.2 (Apple Git-113)
This causes things to fail like so:
ValueError: invalid literal for int() with base 10: '2 (Apple Git-113)\n'
Fix logic around `HAVE_OLD_GIT` such that we split the output of
`git --version` without limit on how many times we split. Previously we
used to split only twice so the suffixes like `(Apple Git-113)` are not
part of the parsed version.
-rw-r--r-- | tests/testutils/site.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/testutils/site.py b/tests/testutils/site.py index b7bfa11cf..31bcffbca 100644 --- a/tests/testutils/site.py +++ b/tests/testutils/site.py @@ -18,7 +18,7 @@ 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('.')) + version = tuple(int(x) for x in out.split(' ')[2].split('.')) HAVE_OLD_GIT = version < (1, 8, 5) except ProgramNotFoundError: HAVE_GIT = False |