Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • willsalmon/buildstream
  • CumHoleZH/buildstream
  • tchaik/buildstream
  • DCotyPortfolio/buildstream
  • jesusoctavioas/buildstream
  • patrickmmartin/buildstream
  • franred/buildstream
  • tintou/buildstream
  • alatiera/buildstream
  • martinblanchard/buildstream
  • neverdie22042524/buildstream
  • Mattlk13/buildstream
  • PServers/buildstream
  • phamnghia610909/buildstream
  • chiaratolentino/buildstream
  • eysz7-x-x/buildstream
  • kerrick1/buildstream
  • matthew-yates/buildstream
  • twofeathers/buildstream
  • mhadjimichael/buildstream
  • pointswaves/buildstream
  • Mr.JackWilson/buildstream
  • Tw3akG33k/buildstream
  • AlexFazakas/buildstream
  • eruidfkiy/buildstream
  • clamotion2/buildstream
  • nanonyme/buildstream
  • wickyjaaa/buildstream
  • nmanchev/buildstream
  • bojorquez.ja/buildstream
  • mostynb/buildstream
  • highpit74/buildstream
  • Demo112/buildstream
  • ba2014sheer/buildstream
  • tonimadrino/buildstream
  • usuario2o/buildstream
  • Angelika123456/buildstream
  • neo355/buildstream
  • corentin-ferlay/buildstream
  • coldtom/buildstream
  • wifitvbox81/buildstream
  • 358253885/buildstream
  • seanborg/buildstream
  • SotK/buildstream
  • DouglasWinship/buildstream
  • karansthr97/buildstream
  • louib/buildstream
  • bwh-ct/buildstream
  • robjh/buildstream
  • we88c0de/buildstream
  • zhengxian5555/buildstream
51 results
Show changes
Commits on Source (2)
  • William Salmon's avatar
    tests/frontend/workspace.py: Refactor of support functions. · d396eb73
    William Salmon authored
    Refactoring the support functions for the workspace cli tests.
    
    The main motivation for this was to allow multiple elements to be
    created before running the workspace command.
    
    Also the support functions are now broken up so that test that test for
    failure can still reuse all the function that create elements, but call
    bst workspace with custom arguments and expect other things than success.
    
    Finally this patch also adds the regression test for workspaces.
    d396eb73
  • William Salmon's avatar
    Updating all remaining tests that use workspaces · 5d17b726
    William Salmon authored
    This updates all remaining tests that have been affected by the braking
    CLI change to workspaces.
    5d17b726
......@@ -55,7 +55,7 @@ def test_open_workspace(cli, tmpdir, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
workspace_dir = os.path.join(str(tmpdir), "workspace_hello")
result = cli.run(project=project, args=['workspace', 'open', '-f', 'hello.bst', workspace_dir])
result = cli.run(project=project, args=['workspace', 'open', '-f', '--directory', workspace_dir, 'hello.bst', ])
result.assert_success()
result = cli.run(project=project, args=['workspace', 'list'])
......@@ -72,7 +72,7 @@ def test_make_change_in_workspace(cli, tmpdir, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
workspace_dir = os.path.join(str(tmpdir), "workspace_hello")
result = cli.run(project=project, args=['workspace', 'open', '-f', 'hello.bst', workspace_dir])
result = cli.run(project=project, args=['workspace', 'open', '-f', '--directory', workspace_dir, 'hello.bst'])
result.assert_success()
result = cli.run(project=project, args=['workspace', 'list'])
......
......@@ -44,7 +44,7 @@ def test_open_cross_junction_workspace(cli, tmpdir, datafiles):
workspace_dir = os.path.join(str(tmpdir), "workspace_hello_junction")
result = cli.run(project=project,
args=['workspace', 'open', 'hello-junction.bst:hello.bst', workspace_dir])
args=['workspace', 'open', '--directory', workspace_dir, 'hello-junction.bst:hello.bst'])
result.assert_success()
result = cli.run(project=project,
......
......@@ -509,7 +509,7 @@ def test_build_checkout_workspaced_junction(cli, tmpdir, datafiles):
# Now open a workspace on the junction
#
result = cli.run(project=project, args=['workspace', 'open', 'junction.bst', workspace])
result = cli.run(project=project, args=['workspace', 'open', '--directory', workspace, 'junction.bst'])
result.assert_success()
filename = os.path.join(workspace, 'files', 'etc-files', 'etc', 'animal.conf')
......
......@@ -47,7 +47,7 @@ def open_cross_junction(cli, tmpdir):
workspace = tmpdir.join("workspace")
element = 'sub.bst:data.bst'
args = ['workspace', 'open', element, str(workspace)]
args = ['workspace', 'open', '--directory', str(workspace), element]
result = cli.run(project=project, args=args)
result.assert_success()
......
......@@ -21,6 +21,7 @@
# Phillip Smyth <phillip.smyth@codethink.co.uk>
# Jonathan Maw <jonathan.maw@codethink.co.uk>
# Richard Maw <richard.maw@codethink.co.uk>
# William Salmon <will.salmon@codethink.co.uk>
#
import os
......@@ -43,72 +44,195 @@ DATA_DIR = os.path.join(
)
class WorkspaceCreater():
def __init__(self, cli, tmpdir, datafiles, project_path=None):
self.cli = cli
self.tmpdir = tmpdir
self.datafiles = datafiles
if not project_path:
project_path = os.path.join(datafiles.dirname, datafiles.basename)
else:
shutil.copytree(os.path.join(datafiles.dirname, datafiles.basename), project_path)
self.project_path = project_path
self.bin_files_path = os.path.join(project_path, 'files', 'bin-files')
self.workspace_cmd = os.path.join(self.project_path, 'workspace_cmd')
def create_workspace_element(self, kind, track, suffix='', workspace_dir=None,
element_attrs=None):
element_name = 'workspace-test-{}{}.bst'.format(kind, suffix)
element_path = os.path.join(self.project_path, 'elements')
if not workspace_dir:
workspace_dir = os.path.join(self.workspace_cmd, element_name.rstrip('.bst'))
# Create our repo object of the given source type with
# the bin files, and then collect the initial ref.
repo = create_repo(kind, str(self.tmpdir))
ref = repo.create(self.bin_files_path)
if track:
ref = None
# Write out our test target
element = {
'kind': 'import',
'sources': [
repo.source_config(ref=ref)
]
}
if element_attrs:
element = {**element, **element_attrs}
_yaml.dump(element,
os.path.join(element_path,
element_name))
return element_name, element_path, workspace_dir
def create_workspace_elements(self, kinds, track, suffixs=None, workspace_dir_usr=None,
element_attrs=None):
element_tuples = []
if suffixs is None:
suffixs = ['', ] * len(kinds)
else:
if len(suffixs) != len(kinds):
raise "terable error"
for suffix, kind in zip(suffixs, kinds):
element_name, element_path, workspace_dir = \
self.create_workspace_element(kind, track, suffix, workspace_dir_usr,
element_attrs)
# Assert that there is no reference, a track & fetch is needed
state = self.cli.get_element_state(self.project_path, element_name)
if track:
assert state == 'no reference'
else:
assert state == 'fetch needed'
element_tuples.append((element_name, workspace_dir))
return element_tuples
def open_workspaces(self, kinds, track, suffixs=None, workspace_dir=None,
element_attrs=None):
element_tuples = self.create_workspace_elements(kinds, track, suffixs, workspace_dir,
element_attrs)
os.makedirs(self.workspace_cmd, exist_ok=True)
# Now open the workspace, this should have the effect of automatically
# tracking & fetching the source from the repo.
args = ['workspace', 'open']
if track:
args.append('--track')
if workspace_dir is not None:
assert len(element_tuples) == 1, "test logic error"
_, workspace_dir = element_tuples[0]
args.extend(['--directory', workspace_dir])
args.extend([element_name for element_name, workspace_dir_suffix in element_tuples])
result = self.cli.run(cwd=self.workspace_cmd, project=self.project_path, args=args)
result.assert_success()
for element_name, workspace_dir in element_tuples:
# Assert that we are now buildable because the source is
# now cached.
assert self.cli.get_element_state(self.project_path, element_name) == 'buildable'
# Check that the executable hello file is found in the workspace
filename = os.path.join(workspace_dir, 'usr', 'bin', 'hello')
assert os.path.exists(filename)
return element_tuples
def open_workspace(cli, tmpdir, datafiles, kind, track, suffix='', workspace_dir=None,
project_path=None, element_attrs=None):
if not workspace_dir:
workspace_dir = os.path.join(str(tmpdir), 'workspace{}'.format(suffix))
if not project_path:
project_path = os.path.join(datafiles.dirname, datafiles.basename)
else:
shutil.copytree(os.path.join(datafiles.dirname, datafiles.basename), project_path)
bin_files_path = os.path.join(project_path, 'files', 'bin-files')
element_path = os.path.join(project_path, 'elements')
element_name = 'workspace-test-{}{}.bst'.format(kind, suffix)
workspace_object = WorkspaceCreater(cli, tmpdir, datafiles, project_path)
workspaces = workspace_object.open_workspaces((kind, ), track, (suffix, ), workspace_dir,
element_attrs)
assert len(workspaces) == 1
element_name, workspace = workspaces[0]
return element_name, workspace_object.project_path, workspace
# Create our repo object of the given source type with
# the bin files, and then collect the initial ref.
#
repo = create_repo(kind, str(tmpdir))
ref = repo.create(bin_files_path)
if track:
ref = None
# Write out our test target
element = {
'kind': 'import',
'sources': [
repo.source_config(ref=ref)
]
}
if element_attrs:
element = {**element, **element_attrs}
_yaml.dump(element,
os.path.join(element_path,
element_name))
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("kind", repo_kinds)
def test_open(cli, tmpdir, datafiles, kind):
open_workspace(cli, tmpdir, datafiles, kind, False)
# Assert that there is no reference, a track & fetch is needed
state = cli.get_element_state(project_path, element_name)
if track:
assert state == 'no reference'
else:
assert state == 'fetch needed'
@pytest.mark.datafiles(DATA_DIR)
def test_open_multi(cli, tmpdir, datafiles):
workspace_object = WorkspaceCreater(cli, tmpdir, datafiles)
workspaces = workspace_object.open_workspaces(repo_kinds, False)
for (elname, workspace), kind in zip(workspaces, repo_kinds):
assert kind in elname
workspace_lsdir = os.listdir(workspace)
if kind == 'git':
assert('.git' in workspace_lsdir)
elif kind == 'bzr':
assert('.bzr' in workspace_lsdir)
else:
assert not ('.git' in workspace_lsdir)
assert not ('.bzr' in workspace_lsdir)
@pytest.mark.datafiles(DATA_DIR)
def test_open_multi_with_directory(cli, tmpdir, datafiles):
workspace_object = WorkspaceCreater(cli, tmpdir, datafiles)
element_tuples = workspace_object.create_workspace_elements(repo_kinds, False, repo_kinds)
os.makedirs(workspace_object.workspace_cmd, exist_ok=True)
# Now open the workspace, this should have the effect of automatically
# tracking & fetching the source from the repo.
args = ['workspace', 'open']
args.extend(['--directory', 'any/dir/should/fail'])
args.extend([element_name for element_name, workspace_dir_suffix in element_tuples])
result = workspace_object.cli.run(cwd=workspace_object.workspace_cmd, project=workspace_object.project_path,
args=args)
result.assert_main_error(ErrorDomain.ARTIFACT, None)
assert ("Directory option can only be used if a single element is given" in result.stderr)
@pytest.mark.datafiles(DATA_DIR)
def test_open_defaultlocation(cli, tmpdir, datafiles):
workspace_object = WorkspaceCreater(cli, tmpdir, datafiles)
((element_name, workspace_dir), ) = workspace_object.create_workspace_elements(['git'], False, ['git'])
os.makedirs(workspace_object.workspace_cmd, exist_ok=True)
# Now open the workspace, this should have the effect of automatically
# tracking & fetching the source from the repo.
args = ['workspace', 'open']
if track:
args.append('--track')
args.extend([element_name, workspace_dir])
result = cli.run(project=project_path, args=args)
args.append(element_name)
# In the other tests we set the cmd to workspace_object.workspace_cmd with the optional
# argument, cwd for the workspace_object.cli.run function. But hear we set the default
# workspace location to workspace_object.workspace_cmd and run the cli.run function with
# no cwd option so that it runs in the project directory.
cli.configure({'workspacedir': workspace_object.workspace_cmd})
result = workspace_object.cli.run(project=workspace_object.project_path,
args=args)
result.assert_success()
# Assert that we are now buildable because the source is
# now cached.
assert cli.get_element_state(project_path, element_name) == 'buildable'
assert cli.get_element_state(workspace_object.project_path, element_name) == 'buildable'
# Check that the executable hello file is found in the workspace
# even though the cli.run function was not run with cwd = workspace_object.workspace_cmd
# the workspace should be created in there as we used the 'workspacedir' configuration
# option.
filename = os.path.join(workspace_dir, 'usr', 'bin', 'hello')
assert os.path.exists(filename)
return (element_name, project_path, workspace_dir)
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("kind", repo_kinds)
def test_open(cli, tmpdir, datafiles, kind):
open_workspace(cli, tmpdir, datafiles, kind, False)
@pytest.mark.datafiles(DATA_DIR)
def test_open_bzr_customize(cli, tmpdir, datafiles):
......@@ -150,7 +274,7 @@ def test_open_force(cli, tmpdir, datafiles, kind):
# Now open the workspace again with --force, this should happily succeed
result = cli.run(project=project, args=[
'workspace', 'open', '--force', element_name, workspace
'workspace', 'open', '--force', '--directory', workspace, element_name
])
result.assert_success()
......@@ -165,7 +289,7 @@ def test_open_force_open(cli, tmpdir, datafiles, kind):
# Now open the workspace again with --force, this should happily succeed
result = cli.run(project=project, args=[
'workspace', 'open', '--force', element_name, workspace
'workspace', 'open', '--force', '--directory', workspace, element_name
])
result.assert_success()
......@@ -196,7 +320,7 @@ def test_open_force_different_workspace(cli, tmpdir, datafiles, kind):
# Now open the workspace again with --force, this should happily succeed
result = cli.run(project=project, args=[
'workspace', 'open', '--force', element_name2, workspace
'workspace', 'open', '--force', '--directory', workspace, element_name2
])
# Assert that the file in workspace 1 has been replaced
......@@ -504,7 +628,7 @@ def test_buildable_no_ref(cli, tmpdir, datafiles):
# Now open the workspace. We don't need to checkout the source though.
workspace = os.path.join(str(tmpdir), 'workspace-no-ref')
os.makedirs(workspace)
args = ['workspace', 'open', '--no-checkout', element_name, workspace]
args = ['workspace', 'open', '--no-checkout', '--directory', workspace, element_name]
result = cli.run(project=project, args=args)
result.assert_success()
......@@ -766,7 +890,7 @@ def test_list_supported_workspace(cli, tmpdir, datafiles, workspace_cfg, expecte
element_name))
# Make a change to the workspaces file
result = cli.run(project=project, args=['workspace', 'open', element_name, workspace])
result = cli.run(project=project, args=['workspace', 'open', '--directory', workspace, element_name])
result.assert_success()
result = cli.run(project=project, args=['workspace', 'close', '--remove-dir', element_name])
result.assert_success()
......
......@@ -278,7 +278,7 @@ def test_workspace_visible(cli, tmpdir, datafiles):
# Open a workspace on our build failing element
#
res = cli.run(project=project, args=['workspace', 'open', element_name, workspace])
res = cli.run(project=project, args=['workspace', 'open', '--directory', workspace, element_name])
assert res.exit_code == 0
# Ensure the dependencies of our build failing element are built
......@@ -312,7 +312,7 @@ def test_sysroot_workspace_visible(cli, tmpdir, datafiles):
# Open a workspace on our build failing element
#
res = cli.run(project=project, args=['workspace', 'open', element_name, workspace])
res = cli.run(project=project, args=['workspace', 'open', '--directory', workspace, element_name])
assert res.exit_code == 0
# Ensure the dependencies of our build failing element are built
......
......@@ -23,7 +23,7 @@ def test_workspace_mount(cli, tmpdir, datafiles):
workspace = os.path.join(cli.directory, 'workspace')
element_name = 'workspace/workspace-mount.bst'
res = cli.run(project=project, args=['workspace', 'open', element_name, workspace])
res = cli.run(project=project, args=['workspace', 'open', '--directory', workspace, element_name])
assert res.exit_code == 0
res = cli.run(project=project, args=['build', element_name])
......@@ -39,7 +39,7 @@ def test_workspace_commanddir(cli, tmpdir, datafiles):
workspace = os.path.join(cli.directory, 'workspace')
element_name = 'workspace/workspace-commanddir.bst'
res = cli.run(project=project, args=['workspace', 'open', element_name, workspace])
res = cli.run(project=project, args=['workspace', 'open', '--directory', workspace, element_name])
assert res.exit_code == 0
res = cli.run(project=project, args=['build', element_name])
......@@ -75,7 +75,7 @@ def test_workspace_updated_dependency(cli, tmpdir, datafiles):
_yaml.dump(dependency, os.path.join(element_path, dep_name))
# First open the workspace
res = cli.run(project=project, args=['workspace', 'open', element_name, workspace])
res = cli.run(project=project, args=['workspace', 'open', '--directory', workspace, element_name])
assert res.exit_code == 0
# We build the workspaced element, so that we have an artifact
......@@ -130,7 +130,7 @@ def test_workspace_update_dependency_failed(cli, tmpdir, datafiles):
_yaml.dump(dependency, os.path.join(element_path, dep_name))
# First open the workspace
res = cli.run(project=project, args=['workspace', 'open', element_name, workspace])
res = cli.run(project=project, args=['workspace', 'open', '--directory', workspace, element_name])
assert res.exit_code == 0
# We build the workspaced element, so that we have an artifact
......@@ -205,7 +205,7 @@ def test_updated_dependency_nested(cli, tmpdir, datafiles):
_yaml.dump(dependency, os.path.join(element_path, dep_name))
# First open the workspace
res = cli.run(project=project, args=['workspace', 'open', element_name, workspace])
res = cli.run(project=project, args=['workspace', 'open', '--directory', workspace, element_name])
assert res.exit_code == 0
# We build the workspaced element, so that we have an artifact
......@@ -258,7 +258,7 @@ def test_incremental_configure_commands_run_only_once(cli, tmpdir, datafiles):
_yaml.dump(element, os.path.join(element_path, element_name))
# We open a workspace on the above element
res = cli.run(project=project, args=['workspace', 'open', element_name, workspace])
res = cli.run(project=project, args=['workspace', 'open', '--directory', workspace, element_name])
res.assert_success()
# Then we build, and check whether the configure step succeeded
......
......@@ -108,7 +108,7 @@ def test_filter_forbid_also_rdep(datafiles, cli):
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 = cli.run(project=project, args=['workspace', 'open', '--directory', workspace_dir, 'deps-permitted.bst'])
result.assert_success()
assert os.path.exists(os.path.join(workspace_dir, "foo"))
assert os.path.exists(os.path.join(workspace_dir, "bar"))
......@@ -120,7 +120,7 @@ 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 = cli.run(project=project, args=['workspace', 'open', '--directory', workspace_dir, 'output-orphans.bst'])
result.assert_success()
src = os.path.join(workspace_dir, "foo")
dst = os.path.join(workspace_dir, "quux")
......@@ -138,7 +138,7 @@ 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 = cli.run(project=project, args=['workspace', 'open', '--directory', workspace_dir, 'output-orphans.bst'])
result.assert_success()
src = os.path.join(workspace_dir, "foo")
dst = os.path.join(workspace_dir, "quux")
......@@ -158,7 +158,7 @@ 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 = cli.run(project=project, args=['workspace', 'open', '--directory', workspace_dir, 'output-orphans.bst'])
result.assert_success()
src = os.path.join(workspace_dir, "foo")
dst = os.path.join(workspace_dir, "quux")
......