Commit ec16561f authored by Jonathan Maw's avatar Jonathan Maw

tests: Add workspace tests for filters

parent 314c25d8
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"))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment