diff options
author | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2018-02-05 17:17:06 +0000 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2018-02-19 15:17:02 +0000 |
commit | 3d4d5688eb965a6e248b5a0bda7c1f95f3de8c14 (patch) | |
tree | c98d3c50b89512c7aa44ec285d0c759464297ba7 | |
parent | 445372c4691f8ac020bc06d61f47ca4123f2c6f7 (diff) | |
download | buildstream-3d4d5688eb965a6e248b5a0bda7c1f95f3de8c14.tar.gz |
tests: Add a git test that project overrides work
-rw-r--r-- | tests/sources/git.py | 39 | ||||
-rw-r--r-- | tests/sources/git/project-override/project.conf | 11 | ||||
-rw-r--r-- | tests/sources/git/project-override/repofiles/file.txt | 1 | ||||
-rw-r--r-- | tests/sources/git/project-override/subrepofiles/ponyfile.txt | 1 |
4 files changed, 52 insertions, 0 deletions
diff --git a/tests/sources/git.py b/tests/sources/git.py index e96d6b4ce..b2e336811 100644 --- a/tests/sources/git.py +++ b/tests/sources/git.py @@ -283,3 +283,42 @@ def test_submodule_fetch_submodule_individual_checkout_explicit(cli, tmpdir, dat assert os.path.exists(os.path.join(checkoutdir, 'file.txt')) assert not os.path.exists(os.path.join(checkoutdir, 'subdir', 'ponyfile.txt')) assert os.path.exists(os.path.join(checkoutdir, 'othersubdir', 'unicornfile.txt')) + + +@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project-override')) +def test_submodule_fetch_project_override(cli, tmpdir, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + checkoutdir = os.path.join(str(tmpdir), "checkout") + + # Create the submodule first 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)) + ref = repo.create(os.path.join(project, 'repofiles')) + + # Add a submodule pointing to the one we created + ref = repo.add_submodule('subdir', 'file://' + subrepo.repo) + + # Write out our test target + element = { + 'kind': 'import', + 'sources': [ + repo.source_config(ref=ref) + ] + } + _yaml.dump(element, os.path.join(project, 'target.bst')) + + # Fetch, build, checkout + result = cli.run(project=project, args=['fetch', 'target.bst']) + result.assert_success() + result = cli.run(project=project, args=['build', 'target.bst']) + result.assert_success() + result = cli.run(project=project, args=['checkout', 'target.bst', checkoutdir]) + result.assert_success() + + # Assert we checked out both files at their expected location + assert os.path.exists(os.path.join(checkoutdir, 'file.txt')) + assert not os.path.exists(os.path.join(checkoutdir, 'subdir', 'ponyfile.txt')) diff --git a/tests/sources/git/project-override/project.conf b/tests/sources/git/project-override/project.conf new file mode 100644 index 000000000..299992f15 --- /dev/null +++ b/tests/sources/git/project-override/project.conf @@ -0,0 +1,11 @@ +# Basic project +name: foo +sources: + git: + config: + checkout-submodules: False +elements: + manual: + config: + build-commands: + - "foo" diff --git a/tests/sources/git/project-override/repofiles/file.txt b/tests/sources/git/project-override/repofiles/file.txt new file mode 100644 index 000000000..f62144808 --- /dev/null +++ b/tests/sources/git/project-override/repofiles/file.txt @@ -0,0 +1 @@ +pony diff --git a/tests/sources/git/project-override/subrepofiles/ponyfile.txt b/tests/sources/git/project-override/subrepofiles/ponyfile.txt new file mode 100644 index 000000000..f73f3093f --- /dev/null +++ b/tests/sources/git/project-override/subrepofiles/ponyfile.txt @@ -0,0 +1 @@ +file |