summaryrefslogtreecommitdiff
path: root/tests/testutils/repo/git.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/testutils/repo/git.py')
-rw-r--r--tests/testutils/repo/git.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/testutils/repo/git.py b/tests/testutils/repo/git.py
index a1309bc7b..46338f445 100644
--- a/tests/testutils/repo/git.py
+++ b/tests/testutils/repo/git.py
@@ -17,10 +17,13 @@ GIT_ENV = {
class Git(Repo):
- def __init__(self, directory):
+ def __init__(self, directory, subdir):
if not HAVE_GIT:
pytest.skip("git is not available")
- super(Git, self).__init__(directory)
+
+ self.submodules = {}
+
+ super(Git, self).__init__(directory, subdir)
def create(self, directory):
self.copy_directory(directory, self.repo)
@@ -29,6 +32,12 @@ class Git(Repo):
subprocess.call(['git', 'commit', '-m', 'Initial commit'], env=GIT_ENV, cwd=self.repo)
return self.latest_commit()
+ def add_submodule(self, subdir, url):
+ self.submodules[subdir] = url
+ subprocess.call(['git', 'submodule', 'add', url, subdir], env=GIT_ENV, cwd=self.repo)
+ subprocess.call(['git', 'commit', '-m', 'Added the submodule'], env=GIT_ENV, cwd=self.repo)
+ return self.latest_commit()
+
def source_config(self, ref=None):
config = {
'kind': 'git',
@@ -38,6 +47,11 @@ class Git(Repo):
if ref is not None:
config['ref'] = ref
+ if self.submodules:
+ config['submodules'] = {}
+ for subdir, url in self.submodules.items():
+ config['submodules'][subdir] = {'url': url}
+
return config
def latest_commit(self):