diff options
author | Jürg Billeter <j@bitron.ch> | 2018-12-20 11:03:52 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2018-12-20 11:07:20 +0100 |
commit | b325989ef3817ef265b3f80deca67815cb19bad1 (patch) | |
tree | cc882088ccb44dbbb30720699de245d051c6d8da /tests/sources/no_fetch_cached.py | |
parent | 7a102144e0d3728d03b6102dd94a1f5f4ade60fe (diff) | |
download | buildstream-b325989ef3817ef265b3f80deca67815cb19bad1.tar.gz |
tests/sources: Test that fetch() is not called for cached sources
Diffstat (limited to 'tests/sources/no_fetch_cached.py')
-rw-r--r-- | tests/sources/no_fetch_cached.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/sources/no_fetch_cached.py b/tests/sources/no_fetch_cached.py new file mode 100644 index 000000000..d2880f628 --- /dev/null +++ b/tests/sources/no_fetch_cached.py @@ -0,0 +1,44 @@ +import os +import pytest + +from buildstream import _yaml + +from tests.testutils import cli, create_repo +from tests.testutils.site import HAVE_GIT + +DATA_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + 'no-fetch-cached' +) + + +################################################################## +# Tests # +################################################################## +# Test that fetch() is not called for cached sources +@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") +@pytest.mark.datafiles(DATA_DIR) +def test_no_fetch_cached(cli, tmpdir, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + + # Create the repo from 'files' subdir + repo = create_repo('git', str(tmpdir)) + ref = repo.create(os.path.join(project, 'files')) + + # Write out test target with a cached and a non-cached source + element = { + 'kind': 'import', + 'sources': [ + repo.source_config(ref=ref), + { + 'kind': 'always_cached' + } + ] + } + _yaml.dump(element, os.path.join(project, 'target.bst')) + + # Test fetch of target with a cached and a non-cached source + result = cli.run(project=project, args=[ + 'source', 'fetch', 'target.bst' + ]) + result.assert_success() |