diff options
author | William Salmon <will.salmon@codethink.co.uk> | 2018-08-01 16:34:40 +0100 |
---|---|---|
committer | William Salmon <will.salmon@codethink.co.uk> | 2018-08-07 14:41:02 +0100 |
commit | 42aa3999be823c2dbe0dd80cae784ff7d9052d31 (patch) | |
tree | 21c15dd5a5b26ff44ec5178ef95ab7ac3e9e001f /tests/sources | |
parent | fc9869e2fa9d458a2ec1642c92365d7b0ffe89f4 (diff) | |
download | buildstream-42aa3999be823c2dbe0dd80cae784ff7d9052d31.tar.gz |
Add warning to git track if track and ref are not present
This is to address https://gitlab.com/BuildStream/buildstream/issues/471 that
documented unhelpfull behavour when tracking git sources.
Diffstat (limited to 'tests/sources')
-rw-r--r-- | tests/sources/git.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/sources/git.py b/tests/sources/git.py index 06888c311..ef18e3ce3 100644 --- a/tests/sources/git.py +++ b/tests/sources/git.py @@ -359,3 +359,45 @@ def test_submodule_track_ignore_inconsistent(cli, tmpdir, datafiles): # Assert that we are just fine without it, and emit a warning to the user. assert "Ignoring inconsistent 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')) +def test_submodule_track_no_ref_or_track(cli, tmpdir, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + + # Create the repo from 'repofiles' subdir + repo = create_repo('git', str(tmpdir)) + ref = repo.create(os.path.join(project, 'repofiles')) + + # Write out our test target + gitsource = repo.source_config(ref=None) + gitsource.pop('track') + element = { + 'kind': 'import', + 'sources': [ + gitsource + ] + } + + _yaml.dump(element, os.path.join(project, 'target.bst')) + + # Track will encounter an inconsistent submodule without any ref + result = cli.run(project=project, args=['track', 'target.bst']) + result.assert_main_error(ErrorDomain.STREAM, None) + result.assert_task_error(ErrorDomain.SOURCE, 'track-attempt-no-track') + + # Assert that we are just fine without it, and emit a warning to the user. + assert "FAILURE git source at" in result.stderr + assert "Without a tracking branch ref can not be updated. Please " + \ + "provide a ref or a track." in result.stderr + + # Track will encounter an inconsistent submodule without any ref + result = cli.run(project=project, args=['build', 'target.bst']) + result.assert_main_error(ErrorDomain.PIPELINE, 'inconsistent-pipeline') + result.assert_task_error(None, None) + + # Assert that we are just fine without it, and emit a warning to the user. + assert "Exact versions are missing for the following elements" in result.stderr + assert "is missing ref and track." in result.stderr + assert "Then track these elements with `bst track`" in result.stderr |