summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-05-24 18:17:38 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-05-24 19:52:10 +0900
commita5a5053812377b48469f43b7a4bd7dc0f2a0564d (patch)
treec30c4558d34e094c6226c11ac1416a539b301e9c
parent002190d996edad6a8a29158fef5c94586d889524 (diff)
downloadbuildstream-a5a5053812377b48469f43b7a4bd7dc0f2a0564d.tar.gz
tests/frontend/show.py: Test behavior of unfetched/inconsistent workspaced junctionstristan/fix-workspaced-junctions-1.2
We already test the behavior without workspaces, lets just augment these tests to also run with a workspaced junction and check the results. This guards against regressions of #1030.
-rw-r--r--tests/frontend/show.py43
1 files changed, 37 insertions, 6 deletions
diff --git a/tests/frontend/show.py b/tests/frontend/show.py
index a7d71dc42..2569d4611 100644
--- a/tests/frontend/show.py
+++ b/tests/frontend/show.py
@@ -114,7 +114,8 @@ def test_target_is_dependency(cli, tmpdir, datafiles):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')])
@pytest.mark.parametrize("element_name", ['junction-dep.bst', 'junction.bst:import-etc.bst'])
-def test_unfetched_junction(cli, tmpdir, datafiles, ref_storage, element_name):
+@pytest.mark.parametrize("workspaced", [True, False], ids=["workspace", "no-workspace"])
+def test_unfetched_junction(cli, tmpdir, datafiles, ref_storage, element_name, workspaced):
project = os.path.join(datafiles.dirname, datafiles.basename)
subproject_path = os.path.join(project, 'files', 'sub-project')
junction_path = os.path.join(project, 'elements', 'junction.bst')
@@ -156,17 +157,29 @@ def test_unfetched_junction(cli, tmpdir, datafiles, ref_storage, element_name):
}
_yaml.dump(project_refs, os.path.join(project, 'junction.refs'))
+ # Open a workspace if we're testing workspaced behavior
+ if workspaced:
+ result = cli.run(project=project, silent=True, args=[
+ 'workspace', 'open', '--no-checkout', 'junction.bst', subproject_path
+ ])
+ result.assert_success()
+
# Assert the correct error when trying to show the pipeline
result = cli.run(project=project, silent=True, args=[
'show', element_name])
- result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_FETCH_NEEDED)
+ # If a workspace is open, no fetch is needed
+ if workspaced:
+ result.assert_success()
+ else:
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_FETCH_NEEDED)
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')])
@pytest.mark.parametrize("element_name", ['junction-dep.bst', 'junction.bst:import-etc.bst'])
-def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage, element_name):
+@pytest.mark.parametrize("workspaced", [True, False], ids=["workspace", "no-workspace"])
+def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage, element_name, workspaced):
project = os.path.join(datafiles.dirname, datafiles.basename)
subproject_path = os.path.join(project, 'files', 'sub-project')
junction_path = os.path.join(project, 'elements', 'junction.bst')
@@ -192,16 +205,28 @@ def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage, element_name
}
_yaml.dump(element, element_path)
+ # Open a workspace if we're testing workspaced behavior
+ if workspaced:
+ result = cli.run(project=project, silent=True, args=[
+ 'workspace', 'open', '--no-checkout', 'junction.bst', subproject_path
+ ])
+ result.assert_success()
+
# Assert the correct error when trying to show the pipeline
result = cli.run(project=project, silent=True, args=[
'show', element_name])
- result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_INCONSISTENT)
+ # If a workspace is open, no ref is needed
+ if workspaced:
+ result.assert_success()
+ else:
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_INCONSISTENT)
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("element_name", ['junction-dep.bst', 'junction.bst:import-etc.bst'])
-def test_fetched_junction(cli, tmpdir, datafiles, element_name):
+@pytest.mark.parametrize("workspaced", [True, False], ids=["workspace", "no-workspace"])
+def test_fetched_junction(cli, tmpdir, datafiles, element_name, workspaced):
project = os.path.join(datafiles.dirname, datafiles.basename)
subproject_path = os.path.join(project, 'files', 'sub-project')
junction_path = os.path.join(project, 'elements', 'junction.bst')
@@ -225,9 +250,15 @@ def test_fetched_junction(cli, tmpdir, datafiles, element_name):
result = cli.run(project=project, silent=True, args=[
'fetch', 'junction.bst'])
-
result.assert_success()
+ # Open a workspace if we're testing workspaced behavior
+ if workspaced:
+ result = cli.run(project=project, silent=True, args=[
+ 'workspace', 'open', '--no-checkout', 'junction.bst', subproject_path
+ ])
+ result.assert_success()
+
# Assert the correct error when trying to show the pipeline
result = cli.run(project=project, silent=True, args=[
'show', '--format', '%{name}-%{state}', element_name])