diff options
author | Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> | 2017-06-07 07:41:55 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-07 16:00:49 +0100 |
commit | 4a7612c7a12b9a381fb8343ba9586272b889fc15 (patch) | |
tree | 288e4e557853a3074f4796d14f77e4e0c6304812 /meta/lib | |
parent | 576821ea0a7558b626ccc87e9ae0e9ee40864956 (diff) | |
download | poky-4a7612c7a12b9a381fb8343ba9586272b889fc15.tar.gz |
buildhistory: skip tests if GitPython module is missing
Catching a possible exception when importing the git module,
allows us to skip test if the latter is missing on the host.
Also, import oe.buildhistory_analysis inside fuctions
because this module also needs git to work correctly.
[YOCTO #11620]
(From OE-Core rev: 186882ca62bf683b93cd7a250963921b89ba071f)
Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/oelib/buildhistory.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py b/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py index 4e877517c1..f9bec53d4a 100644 --- a/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py +++ b/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py | |||
@@ -1,9 +1,7 @@ | |||
1 | import os | 1 | import os |
2 | from oeqa.selftest.case import OESelftestTestCase | 2 | from oeqa.selftest.case import OESelftestTestCase |
3 | import tempfile | 3 | import tempfile |
4 | from git import Repo | ||
5 | from oeqa.utils.commands import get_bb_var | 4 | from oeqa.utils.commands import get_bb_var |
6 | from oe.buildhistory_analysis import blob_to_dict, compare_dict_blobs | ||
7 | 5 | ||
8 | class TestBlobParsing(OESelftestTestCase): | 6 | class TestBlobParsing(OESelftestTestCase): |
9 | 7 | ||
@@ -12,7 +10,12 @@ class TestBlobParsing(OESelftestTestCase): | |||
12 | self.repo_path = tempfile.mkdtemp(prefix='selftest-buildhistory', | 10 | self.repo_path = tempfile.mkdtemp(prefix='selftest-buildhistory', |
13 | dir=get_bb_var('TOPDIR')) | 11 | dir=get_bb_var('TOPDIR')) |
14 | 12 | ||
15 | self.repo = Repo.init(self.repo_path) | 13 | try: |
14 | from git import Repo | ||
15 | self.repo = Repo.init(self.repo_path) | ||
16 | except ImportError: | ||
17 | self.skipTest('Python module GitPython is not present') | ||
18 | |||
16 | self.test_file = "test" | 19 | self.test_file = "test" |
17 | self.var_map = {} | 20 | self.var_map = {} |
18 | 21 | ||
@@ -40,6 +43,7 @@ class TestBlobParsing(OESelftestTestCase): | |||
40 | """ | 43 | """ |
41 | Test convertion of git blobs to dictionary | 44 | Test convertion of git blobs to dictionary |
42 | """ | 45 | """ |
46 | from oe.buildhistory_analysis import blob_to_dict | ||
43 | valuesmap = { "foo" : "1", "bar" : "2" } | 47 | valuesmap = { "foo" : "1", "bar" : "2" } |
44 | self.commit_vars(to_add = valuesmap) | 48 | self.commit_vars(to_add = valuesmap) |
45 | 49 | ||
@@ -51,6 +55,8 @@ class TestBlobParsing(OESelftestTestCase): | |||
51 | """ | 55 | """ |
52 | Test comparisson of dictionaries extracted from git blobs | 56 | Test comparisson of dictionaries extracted from git blobs |
53 | """ | 57 | """ |
58 | from oe.buildhistory_analysis import compare_dict_blobs | ||
59 | |||
54 | changesmap = { "foo-2" : ("2", "8"), "bar" : ("","4"), "bar-2" : ("","5")} | 60 | changesmap = { "foo-2" : ("2", "8"), "bar" : ("","4"), "bar-2" : ("","5")} |
55 | 61 | ||
56 | self.commit_vars(to_add = { "foo" : "1", "foo-2" : "2", "foo-3" : "3" }) | 62 | self.commit_vars(to_add = { "foo" : "1", "foo-2" : "2", "foo-3" : "3" }) |
@@ -69,6 +75,7 @@ class TestBlobParsing(OESelftestTestCase): | |||
69 | """ | 75 | """ |
70 | Test default values for comparisson of git blob dictionaries | 76 | Test default values for comparisson of git blob dictionaries |
71 | """ | 77 | """ |
78 | from oe.buildhistory_analysis import compare_dict_blobs | ||
72 | defaultmap = { x : ("default", "1") for x in ["PKG", "PKGE", "PKGV", "PKGR"]} | 79 | defaultmap = { x : ("default", "1") for x in ["PKG", "PKGE", "PKGV", "PKGR"]} |
73 | 80 | ||
74 | self.commit_vars(to_add = { "foo" : "1" }) | 81 | self.commit_vars(to_add = { "foo" : "1" }) |