summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/sources/bzr.py194
-rw-r--r--tests/sources/bzr/basic-no-ref/project.conf2
-rw-r--r--tests/sources/bzr/basic-no-ref/target.bst6
-rw-r--r--tests/sources/bzr/basic-no-track/project.conf2
-rw-r--r--tests/sources/bzr/basic-no-track/target.bst6
-rw-r--r--tests/sources/bzr/basic/project.conf2
-rw-r--r--tests/sources/bzr/basic/target.bst7
-rw-r--r--tests/sources/bzr/fetch/foo/bar/b1
-rw-r--r--tests/sources/bzr/fetch/foo/bar/c/d1
-rw-r--r--tests/sources/bzr/fetch/foo/bar/c/e1
-rw-r--r--tests/sources/bzr/fetch/project.conf2
-rw-r--r--tests/sources/bzr/fetch/target-bad-ref.bst7
-rw-r--r--tests/sources/bzr/fetch/target.bst7
13 files changed, 0 insertions, 238 deletions
diff --git a/tests/sources/bzr.py b/tests/sources/bzr.py
deleted file mode 100644
index 5a5878f88..000000000
--- a/tests/sources/bzr.py
+++ /dev/null
@@ -1,194 +0,0 @@
-import os
-import pytest
-import subprocess
-
-from buildstream import SourceError, LoadError, Consistency, PluginError
-
-from tests.testutils.site import HAVE_BZR
-from .fixture import Setup
-
-
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- 'bzr',
-)
-
-
-class BzrSetup(Setup):
- bzr_env = {"BZR_EMAIL": "Testy McTesterson <testy.mctesterson@example.com>"}
-
- def __init__(self, datafiles, bstfile, tmpdir):
- super().__init__(datafiles, bstfile, tmpdir)
- self.source.preflight()
- print("Host bzr is {}".format(self.source.host_bzr))
-
- def bzr_init(self, target_dir):
- self.source.call(['bzr', 'init', target_dir],
- fail="Failed to initialize bzr branch at {}"
- .format(target_dir),
- env=self.bzr_env)
-
- def bzr_create(self, target_dir):
- if not os.path.exists(target_dir):
- os.makedirs(target_dir)
- self.bzr_init(target_dir)
-
- def bzr_initrepo(self, target_dir):
- self.source.call(['bzr', 'init-repo', target_dir],
- fail="Faile to init bzr repo at {}".format(target_dir),
- env=self.bzr_env)
-
- def bzr_createrepo(self, target_dir):
- if not os.path.exist(target_dir):
- os.makedirs(target_dir)
- self.bzr_initrepo(target_dir)
-
- def bzr_commit(self, bzr_dir, filename):
- if not os.path.exists(bzr_dir):
- raise FileNotFoundError("{} doesn't exist!".format(bzr_dir))
- self.source.call(['bzr', 'add', filename], cwd=bzr_dir,
- fail="Failed to add file {}".format(filename),
- env=self.bzr_env)
- self.source.call(['bzr', 'commit', '--message="Add file {}"'.format(filename)],
- cwd=bzr_dir,
- fail="Failed to commit file {}".format(filename),
- env=self.bzr_env)
-
-
-# Test that the source can be parsed meaningfully.
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
-@pytest.mark.skipif(HAVE_BZR is False, reason="`bzr` is not available")
-def test_create_source(tmpdir, datafiles):
- setup = Setup(datafiles, 'target.bst', tmpdir)
- assert(setup.source.get_kind() == 'bzr')
- assert(setup.source.url == 'http://www.example.com')
- assert(setup.source.get_ref() == 'foo')
- assert(setup.source.tracking == 'trunk')
-
-
-# Test that without ref, consistency is set appropriately.
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic-no-ref'))
-@pytest.mark.skipif(HAVE_BZR is False, reason="`bzr` is not available")
-def test_no_ref(tmpdir, datafiles):
- setup = Setup(datafiles, 'target.bst', tmpdir)
- assert(setup.source.get_consistency() == Consistency.INCONSISTENT)
-
-
-# Test that with ref, consistency is resolved
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
-@pytest.mark.skipif(HAVE_BZR is False, reason="`bzr` is not available")
-def test_consistency_resolved(tmpdir, datafiles):
- setup = BzrSetup(datafiles, 'target.bst', tmpdir)
- assert(setup.source.get_consistency() == Consistency.RESOLVED)
-
-
-# Test that with ref and fetching, consistency is cached
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch'))
-@pytest.mark.skipif(HAVE_BZR is False, reason="`bzr` is not available")
-def test_consistency_cached(tmpdir, datafiles):
- setup = BzrSetup(datafiles, 'target.bst', tmpdir)
- repodir = os.path.join(str(datafiles), 'foo')
- branchdir = os.path.join(repodir, 'bar')
- setup.bzr_initrepo(repodir)
- setup.bzr_init(branchdir)
- setup.bzr_commit(branchdir, 'b')
- setup.bzr_commit(branchdir, 'c/d')
- setup.bzr_commit(branchdir, 'c/e')
- setup.source.fetch()
-
- found_consistency = setup.source.get_consistency()
- print("Consistency is {}".format(found_consistency))
- assert(found_consistency == Consistency.CACHED)
-
-
-# Test that without track, consistency is set appropriately.
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic-no-track'))
-@pytest.mark.skipif(HAVE_BZR is False, reason="`bzr` is not available")
-def test_no_track(tmpdir, datafiles):
- with pytest.raises(LoadError):
- setup = Setup(datafiles, 'target.bst', tmpdir)
-
-
-# Test that when I fetch, it ends up in the cache.
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch'))
-@pytest.mark.skipif(HAVE_BZR is False, reason="`bzr` is not available")
-def test_fetch(tmpdir, datafiles):
- # Pretty long setup
- setup = BzrSetup(datafiles, 'target.bst', tmpdir)
- repodir = os.path.join(str(datafiles), 'foo')
- branchdir = os.path.join(repodir, 'bar')
- setup.bzr_initrepo(repodir)
- setup.bzr_init(branchdir)
- setup.bzr_commit(branchdir, 'b')
- setup.bzr_commit(branchdir, 'c/d')
- setup.bzr_commit(branchdir, 'c/e')
-
- # Fetch the branch
- setup.source.fetch()
- assert(os.path.isdir(setup.source._get_mirror_dir()))
- assert(os.path.isdir(setup.source._get_branch_dir()))
- assert(os.path.isdir(os.path.join(setup.source._get_mirror_dir(), ".bzr")))
-
-
-# Test that staging fails without ref
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch'))
-@pytest.mark.skipif(HAVE_BZR is False, reason="`bzr` is not available")
-def test_stage_bad_ref(tmpdir, datafiles):
- # Pretty long setup
- setup = BzrSetup(datafiles, 'target-bad-ref.bst', tmpdir)
- repodir = os.path.join(str(datafiles), 'foo')
- branchdir = os.path.join(repodir, 'bar')
- setup.bzr_initrepo(repodir)
- setup.bzr_init(branchdir)
- setup.bzr_commit(branchdir, 'b')
- setup.bzr_commit(branchdir, 'c/d')
- setup.bzr_commit(branchdir, 'c/e')
-
- setup.source.fetch()
- stagedir = os.path.join(str(tmpdir), 'stage')
-
- with pytest.raises(PluginError):
- setup.source.stage(stagedir)
-
-
-# Test that I can stage the repo successfully
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch'))
-@pytest.mark.skipif(HAVE_BZR is False, reason="`bzr` is not available")
-def test_stage(tmpdir, datafiles):
- # Pretty long setup
- setup = BzrSetup(datafiles, 'target.bst', tmpdir)
- repodir = os.path.join(str(datafiles), 'foo')
- branchdir = os.path.join(repodir, 'bar')
- setup.bzr_initrepo(repodir)
- setup.bzr_init(branchdir)
- setup.bzr_commit(branchdir, 'b')
- setup.bzr_commit(branchdir, 'c/d')
- setup.bzr_commit(branchdir, 'c/e')
-
- setup.source.fetch()
- stagedir = os.path.join(str(tmpdir), 'stage')
- setup.source.stage(stagedir)
- expected_files = ['.bzr', 'b', 'c/d', 'c/e']
- for f in expected_files:
- dstpath = os.path.join(stagedir, f)
- print(dstpath)
- assert(os.path.exists(dstpath))
-
-
-# Test that I can track the branch
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch'))
-@pytest.mark.skipif(HAVE_BZR is False, reason="`bzr` is not available")
-def test_track(tmpdir, datafiles):
- # Pretty long setup
- setup = BzrSetup(datafiles, 'target-bad-ref.bst', tmpdir)
- repodir = os.path.join(str(datafiles), 'foo')
- branchdir = os.path.join(repodir, 'bar')
- setup.bzr_initrepo(repodir)
- setup.bzr_init(branchdir)
- setup.bzr_commit(branchdir, 'b')
- setup.bzr_commit(branchdir, 'c/d')
- setup.bzr_commit(branchdir, 'c/e')
-
- generated_ref = setup.source.track()
- print("Found ref {}".format(generated_ref))
- assert(generated_ref == '3')
diff --git a/tests/sources/bzr/basic-no-ref/project.conf b/tests/sources/bzr/basic-no-ref/project.conf
deleted file mode 100644
index afa0f5475..000000000
--- a/tests/sources/bzr/basic-no-ref/project.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-# Basic project
-name: foo
diff --git a/tests/sources/bzr/basic-no-ref/target.bst b/tests/sources/bzr/basic-no-ref/target.bst
deleted file mode 100644
index 12d479197..000000000
--- a/tests/sources/bzr/basic-no-ref/target.bst
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: foo
-description: The kind of this element is irrelevant.
-sources:
-- kind: bzr
- url: http://www.example.com
- track: trunk
diff --git a/tests/sources/bzr/basic-no-track/project.conf b/tests/sources/bzr/basic-no-track/project.conf
deleted file mode 100644
index afa0f5475..000000000
--- a/tests/sources/bzr/basic-no-track/project.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-# Basic project
-name: foo
diff --git a/tests/sources/bzr/basic-no-track/target.bst b/tests/sources/bzr/basic-no-track/target.bst
deleted file mode 100644
index e56e51585..000000000
--- a/tests/sources/bzr/basic-no-track/target.bst
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: foo
-description: The kind of this element is irrelevant.
-sources:
-- kind: bzr
- url: http://www.example.com
- ref: foo
diff --git a/tests/sources/bzr/basic/project.conf b/tests/sources/bzr/basic/project.conf
deleted file mode 100644
index afa0f5475..000000000
--- a/tests/sources/bzr/basic/project.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-# Basic project
-name: foo
diff --git a/tests/sources/bzr/basic/target.bst b/tests/sources/bzr/basic/target.bst
deleted file mode 100644
index 03108bf02..000000000
--- a/tests/sources/bzr/basic/target.bst
+++ /dev/null
@@ -1,7 +0,0 @@
-kind: foo
-description: The kind of this element is irrelevant.
-sources:
-- kind: bzr
- url: http://www.example.com
- track: trunk
- ref: foo
diff --git a/tests/sources/bzr/fetch/foo/bar/b b/tests/sources/bzr/fetch/foo/bar/b
deleted file mode 100644
index 617807982..000000000
--- a/tests/sources/bzr/fetch/foo/bar/b
+++ /dev/null
@@ -1 +0,0 @@
-b
diff --git a/tests/sources/bzr/fetch/foo/bar/c/d b/tests/sources/bzr/fetch/foo/bar/c/d
deleted file mode 100644
index b9a1dd099..000000000
--- a/tests/sources/bzr/fetch/foo/bar/c/d
+++ /dev/null
@@ -1 +0,0 @@
-dddd
diff --git a/tests/sources/bzr/fetch/foo/bar/c/e b/tests/sources/bzr/fetch/foo/bar/c/e
deleted file mode 100644
index 3befbedb1..000000000
--- a/tests/sources/bzr/fetch/foo/bar/c/e
+++ /dev/null
@@ -1 +0,0 @@
-eeeee
diff --git a/tests/sources/bzr/fetch/project.conf b/tests/sources/bzr/fetch/project.conf
deleted file mode 100644
index afa0f5475..000000000
--- a/tests/sources/bzr/fetch/project.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-# Basic project
-name: foo
diff --git a/tests/sources/bzr/fetch/target-bad-ref.bst b/tests/sources/bzr/fetch/target-bad-ref.bst
deleted file mode 100644
index 7cbeda9f4..000000000
--- a/tests/sources/bzr/fetch/target-bad-ref.bst
+++ /dev/null
@@ -1,7 +0,0 @@
-kind: foo
-description: The kind of this element is irrelevant.
-sources:
-- kind: bzr
- url: datafiles:/foo
- track: bar
- ref: 12
diff --git a/tests/sources/bzr/fetch/target.bst b/tests/sources/bzr/fetch/target.bst
deleted file mode 100644
index 2fdb56ac2..000000000
--- a/tests/sources/bzr/fetch/target.bst
+++ /dev/null
@@ -1,7 +0,0 @@
-kind: foo
-description: The kind of this element is irrelevant.
-sources:
-- kind: bzr
- url: datafiles:/foo
- track: bar
- ref: 3