[oe-commits] [bitbake] 01/02: tests/fetch: add test_git_submodule_branch_new_module
git at git.openembedded.org
git at git.openembedded.org
Wed Aug 23 12:50:13 UTC 2017
This is an automated email from the git hooks/post-receive script.
rpurdie pushed a commit to branch master-next
in repository bitbake.
commit df9c327d63f87ddbdcacb55fb00804596014bb86
Author: Christopher Larson <chris_larson at mentor.com>
AuthorDate: Mon Aug 21 21:37:40 2017 +0500
tests/fetch: add test_git_submodule_branch_new_module
This local test validates that we can switch branches for a gitsm URI and the
submodules are correct for that branch when unpacked.
[YOCTO #11830]
Signed-off-by: Christopher Larson <chris_larson at mentor.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
lib/bb/tests/fetch.py | 60 ++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 57 insertions(+), 3 deletions(-)
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index faa5c74..f91621c 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -19,11 +19,12 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
-import unittest
-import tempfile
-import subprocess
import collections
import os
+import shutil
+import subprocess
+import tempfile
+import unittest
from bb.fetch2 import URI
from bb.fetch2 import FetchMethod
import bb
@@ -517,6 +518,59 @@ class FetcherLocalTest(FetcherTest):
with self.assertRaises(bb.fetch2.UnpackError):
self.fetchUnpack(['file://a;subdir=/bin/sh'])
+ def test_git_submodule_branch_new_module(self):
+ def git(gitdir, *cmd):
+ if len(cmd) == 1 and isinstance(cmd[0], list, str):
+ cmd = cmd[0]
+
+ if isinstance(cmd, str):
+ cmd = 'git ' + cmd
+ else:
+ cmd = ['git'] + list(cmd)
+ return bb.process.run(cmd, cwd=gitdir)[0]
+
+ def newrepo(name):
+ gitdir = os.path.join(self.tempdir, name)
+ bb.process.run(['git', 'init', gitdir])
+ open(os.path.join(gitdir, 'a'), 'w').close()
+ git(gitdir, 'add', 'a')
+ git(gitdir, 'commit', '-m', 'add a')
+ return gitdir
+
+ sub1 = newrepo('upstream-submodule1')
+ upstream = newrepo('upstream')
+ git(upstream, 'submodule', 'add', sub1, 'sub1')
+ git(upstream, 'add', '.gitmodules')
+ git(upstream, 'commit', '-m', 'add submodule1')
+
+ git(upstream, 'checkout', '-b', 'with-sub2')
+ sub2 = newrepo('upstream-submodule2')
+ git(upstream, 'submodule', 'add', sub2, 'sub2')
+ git(upstream, 'add', '.gitmodules')
+ git(upstream, 'commit', '-m', 'add submodule2')
+
+ git(upstream, 'checkout', 'master')
+
+ self.d.setVar('SRCREV', '${@bb.fetch2.get_autorev(d)}')
+
+ bb.utils.mkdirhier(self.unpackdir)
+ tree = self.fetchUnpack(["gitsm://%s;protocol=file;branch=master" % upstream])
+ tree = filter(lambda f: not f.startswith('git/.git/'), tree)
+ self.assertEqual(list(tree), ['git/.gitmodules', 'git/a', 'git/sub1/.git', 'git/sub1/a'])
+
+ shutil.rmtree(self.unpackdir)
+ bb.utils.mkdirhier(self.unpackdir)
+ tree = self.fetchUnpack(["gitsm://%s;protocol=file;branch=with-sub2" % upstream])
+ tree = filter(lambda f: not f.startswith('git/.git/'), tree)
+ self.assertEqual(list(tree), ['git/.gitmodules', 'git/a', 'git/sub1/.git', 'git/sub1/a', 'git/sub2/.git', 'git/sub2/a'])
+
+ shutil.rmtree(self.unpackdir)
+ bb.utils.mkdirhier(self.unpackdir)
+ tree = self.fetchUnpack(["gitsm://%s;protocol=file;branch=master" % upstream])
+ tree = filter(lambda f: not f.startswith('git/.git/'), tree)
+ self.assertEqual(list(tree), ['git/.gitmodules', 'git/a', 'git/sub1/.git', 'git/sub1/a'])
+
+
class FetcherNetworkTest(FetcherTest):
if os.environ.get("BB_SKIP_NETTESTS") == "yes":
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list