summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2018-03-14 14:42:04 +0000
committerJonathan Maw <jonathan.maw@codethink.co.uk>2018-05-17 16:45:50 +0100
commitec16561f114430e54526bbff2202aa69c849de81 (patch)
tree35b81329d7ce48a86c81f6af3312c67fc2d98dda /tests
parent314c25d848d2bbbc44b75ac867c73c48842af56f (diff)
downloadbuildstream-ec16561f114430e54526bbff2202aa69c849de81.tar.gz
tests: Add workspace tests for filters
Diffstat (limited to 'tests')
-rw-r--r--tests/plugins/filter.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/plugins/filter.py b/tests/plugins/filter.py
index 3c092c201..9c7e74b7e 100644
--- a/tests/plugins/filter.py
+++ b/tests/plugins/filter.py
@@ -1,5 +1,6 @@
import os
import pytest
+import shutil
from tests.testutils.runcli import cli
from buildstream._exceptions import ErrorDomain
@@ -85,3 +86,72 @@ def test_filter_forbid_also_rdep(datafiles, cli):
project = os.path.join(datafiles.dirname, datafiles.basename)
result = cli.run(project=project, args=['build', 'forbidden-also-rdep.bst'])
result.assert_main_error(ErrorDomain.ELEMENT, 'filter-bdepend-also-rdepend')
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
+def test_filter_workspace_open(datafiles, cli, tmpdir):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ workspace_dir = os.path.join(tmpdir.dirname, tmpdir.basename, "workspace")
+ result = cli.run(project=project, args=['workspace', 'open', 'deps-permitted.bst', workspace_dir])
+ result.assert_success()
+ assert os.path.exists(os.path.join(workspace_dir, "foo"))
+ assert os.path.exists(os.path.join(workspace_dir, "bar"))
+ assert os.path.exists(os.path.join(workspace_dir, "baz"))
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
+def test_filter_workspace_build(datafiles, cli, tmpdir):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ tempdir = os.path.join(tmpdir.dirname, tmpdir.basename)
+ workspace_dir = os.path.join(tempdir, "workspace")
+ result = cli.run(project=project, args=['workspace', 'open', 'output-orphans.bst', workspace_dir])
+ result.assert_success()
+ src = os.path.join(workspace_dir, "foo")
+ dst = os.path.join(workspace_dir, "quux")
+ shutil.copyfile(src, dst)
+ result = cli.run(project=project, args=['build', 'output-orphans.bst'])
+ result.assert_success()
+ checkout_dir = os.path.join(tempdir, "checkout")
+ result = cli.run(project=project, args=['checkout', 'output-orphans.bst', checkout_dir])
+ result.assert_success()
+ assert os.path.exists(os.path.join(checkout_dir, "quux"))
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
+def test_filter_workspace_close(datafiles, cli, tmpdir):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ tempdir = os.path.join(tmpdir.dirname, tmpdir.basename)
+ workspace_dir = os.path.join(tempdir, "workspace")
+ result = cli.run(project=project, args=['workspace', 'open', 'output-orphans.bst', workspace_dir])
+ result.assert_success()
+ src = os.path.join(workspace_dir, "foo")
+ dst = os.path.join(workspace_dir, "quux")
+ shutil.copyfile(src, dst)
+ result = cli.run(project=project, args=['workspace', 'close', 'deps-permitted.bst'])
+ result.assert_success()
+ result = cli.run(project=project, args=['build', 'output-orphans.bst'])
+ result.assert_success()
+ checkout_dir = os.path.join(tempdir, "checkout")
+ result = cli.run(project=project, args=['checkout', 'output-orphans.bst', checkout_dir])
+ result.assert_success()
+ assert not os.path.exists(os.path.join(checkout_dir, "quux"))
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
+def test_filter_workspace_reset(datafiles, cli, tmpdir):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ tempdir = os.path.join(tmpdir.dirname, tmpdir.basename)
+ workspace_dir = os.path.join(tempdir, "workspace")
+ result = cli.run(project=project, args=['workspace', 'open', 'output-orphans.bst', workspace_dir])
+ result.assert_success()
+ src = os.path.join(workspace_dir, "foo")
+ dst = os.path.join(workspace_dir, "quux")
+ shutil.copyfile(src, dst)
+ result = cli.run(project=project, args=['workspace', 'reset', 'deps-permitted.bst'])
+ result.assert_success()
+ result = cli.run(project=project, args=['build', 'output-orphans.bst'])
+ result.assert_success()
+ checkout_dir = os.path.join(tempdir, "checkout")
+ result = cli.run(project=project, args=['checkout', 'output-orphans.bst', checkout_dir])
+ result.assert_success()
+ assert not os.path.exists(os.path.join(checkout_dir, "quux"))