summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrichardmaw-codethink <richard.maw@codethink.co.uk>2018-09-14 10:55:16 +0000
committerrichardmaw-codethink <richard.maw@codethink.co.uk>2018-09-14 10:55:16 +0000
commitd7152ef47c73c8f56812d132d317f14a6665523a (patch)
treeabbe59a338a9bc5e8f126df3b67e538c22d48c37
parentf86ab8f6f5623da2988ab1ea7b83e8a655632177 (diff)
parent800a8403f4a27175ea041ceb3af26cdedb269d3f (diff)
downloadbuildstream-d7152ef47c73c8f56812d132d317f14a6665523a.tar.gz
Merge branch 'richardmaw/test-config-fixes' into 'master'
Fix tests that attempt to access the home directory See merge request BuildStream/buildstream!780
-rw-r--r--tests/frontend/logging.py5
-rw-r--r--tests/frontend/workspace.py38
2 files changed, 23 insertions, 20 deletions
diff --git a/tests/frontend/logging.py b/tests/frontend/logging.py
index 4c70895a5..733c7e85d 100644
--- a/tests/frontend/logging.py
+++ b/tests/frontend/logging.py
@@ -54,8 +54,7 @@ def test_custom_logging(cli, tmpdir, datafiles):
custom_log_format = '%{elapsed},%{elapsed-us},%{wallclock},%{key},%{element},%{action},%{message}'
user_config = {'logging': {'message-format': custom_log_format}}
- user_config_file = str(tmpdir.join('buildstream.conf'))
- _yaml.dump(_yaml.node_sanitize(user_config), filename=user_config_file)
+ cli.configure(user_config)
# Create our repo object of the given source type with
# the bin files, and then collect the initial ref.
@@ -75,7 +74,7 @@ def test_custom_logging(cli, tmpdir, datafiles):
element_name))
# Now try to fetch it
- result = cli.run(project=project, args=['-c', user_config_file, 'fetch', element_name])
+ result = cli.run(project=project, args=['fetch', element_name])
result.assert_success()
m = re.search("\d\d:\d\d:\d\d,\d\d:\d\d:\d\d.\d{6},\d\d:\d\d:\d\d,,,SUCCESS,Checking sources", result.stderr)
diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py
index 86cb3952d..47d3b6a85 100644
--- a/tests/frontend/workspace.py
+++ b/tests/frontend/workspace.py
@@ -43,10 +43,13 @@ DATA_DIR = os.path.join(
)
-def open_workspace(cli, tmpdir, datafiles, kind, track, suffix='', workspace_dir=None):
+def open_workspace(cli, tmpdir, datafiles, kind, track, suffix='', workspace_dir=None, project_path=None):
if not workspace_dir:
workspace_dir = os.path.join(str(tmpdir), 'workspace{}'.format(suffix))
- project_path = os.path.join(datafiles.dirname, datafiles.basename)
+ 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)
@@ -218,41 +221,42 @@ def test_close(cli, tmpdir, datafiles, kind):
@pytest.mark.datafiles(DATA_DIR)
def test_close_external_after_move_project(cli, tmpdir, datafiles):
- tmp_parent = os.path.dirname(str(tmpdir))
- workspace_dir = os.path.join(tmp_parent, "workspace")
- element_name, project_path, _ = open_workspace(cli, tmpdir, datafiles, 'git', False, "", workspace_dir)
+ workspace_dir = os.path.join(str(tmpdir), "workspace")
+ project_path = os.path.join(str(tmpdir), 'initial_project')
+ element_name, _, _ = open_workspace(cli, tmpdir, datafiles, 'git', False, "", workspace_dir, project_path)
assert os.path.exists(workspace_dir)
- tmp_dir = os.path.join(tmp_parent, 'external_project')
- shutil.move(project_path, tmp_dir)
- assert os.path.exists(tmp_dir)
+ moved_dir = os.path.join(str(tmpdir), 'external_project')
+ shutil.move(project_path, moved_dir)
+ assert os.path.exists(moved_dir)
# Close the workspace
- result = cli.run(configure=False, project=tmp_dir, args=[
+ result = cli.run(project=moved_dir, args=[
'workspace', 'close', '--remove-dir', element_name
])
result.assert_success()
# Assert the workspace dir has been deleted
assert not os.path.exists(workspace_dir)
- # Move directory back inside tmp directory so it can be recognised
- shutil.move(tmp_dir, project_path)
@pytest.mark.datafiles(DATA_DIR)
def test_close_internal_after_move_project(cli, tmpdir, datafiles):
- element_name, project, _ = open_workspace(cli, tmpdir, datafiles, 'git', False)
- tmp_dir = os.path.join(os.path.dirname(str(tmpdir)), 'external_project')
- shutil.move(str(tmpdir), tmp_dir)
- assert os.path.exists(tmp_dir)
+ initial_dir = os.path.join(str(tmpdir), 'initial_project')
+ initial_workspace = os.path.join(initial_dir, 'workspace')
+ element_name, _, _ = open_workspace(cli, tmpdir, datafiles, 'git', False,
+ workspace_dir=initial_workspace, project_path=initial_dir)
+ moved_dir = os.path.join(str(tmpdir), 'internal_project')
+ shutil.move(initial_dir, moved_dir)
+ assert os.path.exists(moved_dir)
# Close the workspace
- result = cli.run(configure=False, project=tmp_dir, args=[
+ result = cli.run(project=moved_dir, args=[
'workspace', 'close', '--remove-dir', element_name
])
result.assert_success()
# Assert the workspace dir has been deleted
- workspace = os.path.join(tmp_dir, 'workspace')
+ workspace = os.path.join(moved_dir, 'workspace')
assert not os.path.exists(workspace)