summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Mewett <tom.mewett@codethink.co.uk>2019-12-10 12:04:12 +0000
committerTom Mewett <tom.mewett@codethink.co.uk>2019-12-13 16:49:02 +0000
commitd48b380e525c47b9a580b884e4125bdc2c1a7cbf (patch)
tree157c3b0038ef25837850de2fe200bf6e2854887b
parentc97b385d5e30ee1eb4079b83a318049456d0b6f5 (diff)
downloadbuildstream-d48b380e525c47b9a580b884e4125bdc2c1a7cbf.tar.gz
tests/sources/git.py: Add recursive submodule test
-rw-r--r--tests/sources/git.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/sources/git.py b/tests/sources/git.py
index e4252fe51..096338bbe 100644
--- a/tests/sources/git.py
+++ b/tests/sources/git.py
@@ -94,6 +94,46 @@ def test_submodule_fetch_checkout(cli, tmpdir, datafiles):
@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available")
@pytest.mark.datafiles(os.path.join(DATA_DIR, "template"))
+def test_recursive_submodule_fetch_checkout(cli, tmpdir, datafiles):
+ project = str(datafiles)
+ checkoutdir = os.path.join(str(tmpdir), "checkout")
+
+ # Create a submodule from the 'othersubrepofiles' subdir
+ subsubrepo = create_repo("git", str(tmpdir), "subsubrepo")
+ subsubrepo.create(os.path.join(project, "othersubrepofiles"))
+
+ # Create another submodule from the 'subrepofiles' subdir
+ subrepo = create_repo("git", str(tmpdir), "subrepo")
+ subrepo.create(os.path.join(project, "subrepofiles"))
+
+ # Create the repo from 'repofiles' subdir
+ repo = create_repo("git", str(tmpdir))
+ repo.create(os.path.join(project, "repofiles"))
+
+ # Configure submodules
+ subrepo.add_submodule("subdir", "file://" + subsubrepo.repo)
+ ref = repo.add_submodule("subdir", "file://" + subrepo.repo)
+
+ # Write out our test target
+ element = {"kind": "import", "sources": [repo.source_config(ref=ref)]}
+ _yaml.roundtrip_dump(element, os.path.join(project, "target.bst"))
+
+ # Fetch, build, checkout
+ result = cli.run(project=project, args=["source", "fetch", "target.bst"])
+ result.assert_success()
+ result = cli.run(project=project, args=["build", "target.bst"])
+ result.assert_success()
+ result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir])
+ result.assert_success()
+
+ # Assert we checked out all files at their expected location
+ assert os.path.exists(os.path.join(checkoutdir, "file.txt"))
+ assert os.path.exists(os.path.join(checkoutdir, "subdir", "ponyfile.txt"))
+ assert os.path.exists(os.path.join(checkoutdir, "subdir", "subdir", "unicornfile.txt"))
+
+
+@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available")
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "template"))
def test_submodule_fetch_source_enable_explicit(cli, tmpdir, datafiles):
project = str(datafiles)
checkoutdir = os.path.join(str(tmpdir), "checkout")