summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-12-06 22:44:35 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-12-06 23:18:31 +0900
commit573002016397bb657f3dee980f68814aadb07b25 (patch)
treeddc221ec21a07860cc50b8af698bcf258bfa16bb
parentafe1aa9fc2355bc71563ec0112ce4a26d9eebdce (diff)
downloadbuildstream-573002016397bb657f3dee980f68814aadb07b25.tar.gz
tests/sources/git.py: Test unlisted submodules warning appearing after track
-rw-r--r--tests/sources/git.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/sources/git.py b/tests/sources/git.py
index dc18a3c20..64acbd770 100644
--- a/tests/sources/git.py
+++ b/tests/sources/git.py
@@ -531,6 +531,69 @@ def test_unlisted_submodule(cli, tmpdir, datafiles, fail):
@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available")
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'template'))
@pytest.mark.parametrize("fail", ['warn', 'error'])
+def test_track_unlisted_submodule(cli, tmpdir, datafiles, fail):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+
+ # Make the warning an error if we're testing errors
+ if fail == 'error':
+ project_template = {
+ "name": "foo",
+ "fatal-warnings": ['git:unlisted-submodule']
+ }
+ _yaml.dump(project_template, os.path.join(project, 'project.conf'))
+
+ # 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, but use
+ # the original ref, let the submodules appear after tracking
+ repo.add_submodule('subdir', 'file://' + subrepo.repo)
+
+ # Create the source, and delete the explicit configuration
+ # of the submodules.
+ gitsource = repo.source_config(ref=ref)
+ del gitsource['submodules']
+
+ # Write out our test target
+ element = {
+ 'kind': 'import',
+ 'sources': [
+ gitsource
+ ]
+ }
+ _yaml.dump(element, os.path.join(project, 'target.bst'))
+
+ # Fetch the repo, we will not see the warning because we
+ # are still pointing to a ref which predates the submodules
+ result = cli.run(project=project, args=['fetch', 'target.bst'])
+ result.assert_success()
+ assert "git:unlisted-submodule" not in result.stderr
+
+ # We won't get a warning/error when tracking either, the source
+ # has not become Consistency.CACHED so the opportunity to check
+ # for the warning has not yet arisen.
+ result = cli.run(project=project, args=['track', 'target.bst'])
+ result.assert_success()
+ assert "git:unlisted-submodule" not in result.stderr
+
+ # Fetching the repo at the new ref will finally reveal the warning
+ result = cli.run(project=project, args=['fetch', 'target.bst'])
+ if fail == 'error':
+ result.assert_main_error(ErrorDomain.STREAM, None)
+ result.assert_task_error(ErrorDomain.PLUGIN, 'git:unlisted-submodule')
+ else:
+ result.assert_success()
+ assert "git:unlisted-submodule" in result.stderr
+
+
+@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available")
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'template'))
+@pytest.mark.parametrize("fail", ['warn', 'error'])
def test_invalid_submodule(cli, tmpdir, datafiles, fail):
project = os.path.join(datafiles.dirname, datafiles.basename)