summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Maat <tm@tlater.net>2018-01-09 10:53:57 +0000
committerTristan Maat <tristan.maat@codethink.co.uk>2018-02-07 13:03:28 +0000
commit4d05c55d8f56077da3720a1adbfc5f5115f1cd88 (patch)
tree64f28a23a776d4898a3aa5f666e6cd58c768b284
parentcb71d0f69c62679b1ce9dd5e8256e4cea86f6cf6 (diff)
downloadbuildstream-4d05c55d8f56077da3720a1adbfc5f5115f1cd88.tar.gz
Add bzr test
-rw-r--r--tests/sources/bzr.py46
-rw-r--r--tests/sources/bzr/basic/test1
-rw-r--r--tests/sources/bzr/project.conf2
3 files changed, 49 insertions, 0 deletions
diff --git a/tests/sources/bzr.py b/tests/sources/bzr.py
new file mode 100644
index 000000000..4675aec05
--- /dev/null
+++ b/tests/sources/bzr.py
@@ -0,0 +1,46 @@
+import os
+import pytest
+
+from buildstream._pipeline import PipelineError
+from buildstream import _yaml
+
+from tests.testutils import cli, create_repo
+from tests.testutils.site import HAVE_BZR
+
+DATA_DIR = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ 'bzr'
+)
+
+
+@pytest.mark.skipif(HAVE_BZR is False, reason="bzr is not available")
+@pytest.mark.datafiles(os.path.join(DATA_DIR))
+def test_fetch_checkout(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ checkoutdir = os.path.join(str(tmpdir), 'checkout')
+
+ repo = create_repo('bzr', str(tmpdir))
+ ref = repo.create(os.path.join(project, 'basic'))
+
+ # 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'])
+ assert result.exit_code == 0
+ result = cli.run(project=project, args=['build', 'target.bst'])
+ assert result.exit_code == 0
+ result = cli.run(project=project, args=['checkout', 'target.bst', checkoutdir])
+ assert result.exit_code == 0
+
+ # Assert we checked out the file as it was commited
+ with open(os.path.join(checkoutdir, 'test')) as f:
+ text = f.read()
+
+ assert text == 'test\n'
diff --git a/tests/sources/bzr/basic/test b/tests/sources/bzr/basic/test
new file mode 100644
index 000000000..9daeafb98
--- /dev/null
+++ b/tests/sources/bzr/basic/test
@@ -0,0 +1 @@
+test
diff --git a/tests/sources/bzr/project.conf b/tests/sources/bzr/project.conf
new file mode 100644
index 000000000..04b84631f
--- /dev/null
+++ b/tests/sources/bzr/project.conf
@@ -0,0 +1,2 @@
+# Basic Project
+name: foo