summaryrefslogtreecommitdiff
path: root/tests/frontend/track.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-09-04 02:26:37 -0400
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-09-04 04:14:54 -0400
commit3b8b8f9cee23fc87502af801ad406e32bfc348b4 (patch)
treefeb72f7cdbb0939c5f2163d17949f24837959d05 /tests/frontend/track.py
parentae31df34ebb556a94d678c78574254a4bac2990f (diff)
downloadbuildstream-3b8b8f9cee23fc87502af801ad406e32bfc348b4.tar.gz
tests/frontend/track.py: Added test case for `bst track`
Diffstat (limited to 'tests/frontend/track.py')
-rw-r--r--tests/frontend/track.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/frontend/track.py b/tests/frontend/track.py
new file mode 100644
index 000000000..e4364e687
--- /dev/null
+++ b/tests/frontend/track.py
@@ -0,0 +1,57 @@
+import os
+import pytest
+from tests.testutils.runcli import cli
+from tests.testutils.repo import create_repo
+
+from buildstream import _yaml
+
+
+# Project directory
+DATA_DIR = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ "project",
+)
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("kind", [('git'), ('bzr'), ('ostree'), ('tar')])
+def test_track(cli, tmpdir, datafiles, kind):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ dev_files_path = os.path.join(project, 'files', 'dev-files')
+ element_path = os.path.join(project, 'elements')
+ element_name = 'track-test-{}.bst'.format(kind)
+
+ # Create our repo object of the given source type with
+ # the dev files, and then collect the initial ref.
+ #
+ repo = create_repo(kind, str(tmpdir))
+ ref = repo.create(dev_files_path)
+
+ # Write out our test target
+ element = {
+ 'kind': 'import',
+ 'sources': [
+ repo.source_config()
+ ]
+ }
+ _yaml.dump(element,
+ os.path.join(element_path,
+ element_name))
+
+ # Assert that a fetch is needed
+ assert cli.get_element_state(project, element_name) == 'no reference'
+
+ # Now first try to track it
+ result = cli.run(project=project, args=['track', element_name])
+ assert result.exit_code == 0
+
+ # And now fetch it: The Source has probably already cached the
+ # latest ref locally, but it is not required to have cached
+ # the associated content of the latest ref at track time, that
+ # is the job of fetch.
+ result = cli.run(project=project, args=['fetch', element_name])
+ assert result.exit_code == 0
+
+ # Assert that we are now buildable because the source is
+ # now cached.
+ assert cli.get_element_state(project, element_name) == 'buildable'