summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-02-06 08:49:28 +0100
committerJürg Billeter <j@bitron.ch>2020-02-06 11:45:41 +0100
commit7890264033816bb1a79648c492e012017d035493 (patch)
treec3850d27909ee7f5f25e3e41f3b337a62278d2c1
parent3f87db2eed9f3ca36908cf8bfe4c0548ae246091 (diff)
downloadbuildstream-7890264033816bb1a79648c492e012017d035493.tar.gz
_workspaces.py: Increment format version, drop support for old versions
Do not accept old versions as bst 1.x workspaces do not separate source and build files.
-rw-r--r--src/buildstream/_workspaces.py40
-rw-r--r--tests/frontend/workspace.py54
2 files changed, 13 insertions, 81 deletions
diff --git a/src/buildstream/_workspaces.py b/src/buildstream/_workspaces.py
index 5c3b4af8f..edc0564c5 100644
--- a/src/buildstream/_workspaces.py
+++ b/src/buildstream/_workspaces.py
@@ -21,12 +21,11 @@ import os
from . import utils
from . import _yaml
-from .node import MappingNode, ScalarNode
from ._exceptions import LoadError
from .exceptions import LoadErrorReason
-BST_WORKSPACE_FORMAT_VERSION = 3
+BST_WORKSPACE_FORMAT_VERSION = 4
BST_WORKSPACE_PROJECT_FORMAT_VERSION = 1
WORKSPACE_PROJECT_FILE = ".bstproject.yaml"
@@ -526,38 +525,17 @@ class Workspaces:
"Format version is not an integer in workspace configuration", LoadErrorReason.INVALID_DATA
)
- if version == 0:
- # Pre-versioning format can be of two forms
- for element, config in workspaces.items():
- config_type = type(config)
-
- if config_type is ScalarNode:
- pass
-
- elif config_type is MappingNode:
- sources = list(config.values())
- if len(sources) > 1:
- detail = (
- "There are multiple workspaces open for '{}'.\n"
- + "This is not supported anymore.\n"
- + "Please remove this element from '{}'."
- )
- raise LoadError(detail.format(element, self._get_filename()), LoadErrorReason.INVALID_DATA)
-
- workspaces[element] = sources[0]
-
- else:
- raise LoadError("Workspace config is in unexpected format.", LoadErrorReason.INVALID_DATA)
-
- res = {
- element: Workspace(self._toplevel_project, path=config.as_str())
- for element, config in workspaces.items()
- }
+ if version < 4:
+ # bst 1.x workspaces do not separate source and build files.
+ raise LoadError(
+ "Workspace configuration format version {} not supported."
+ "Please recreate this workspace.".format(version),
+ LoadErrorReason.INVALID_DATA,
+ )
- elif 1 <= version <= BST_WORKSPACE_FORMAT_VERSION:
+ if 4 <= version <= BST_WORKSPACE_FORMAT_VERSION:
workspaces = workspaces.get_mapping("workspaces", default={})
res = {element: self._load_workspace(node) for element, node in workspaces.items()}
-
else:
raise LoadError(
"Workspace configuration format version {} not supported."
diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py
index e05b6bd1f..5b3ec7b7c 100644
--- a/tests/frontend/workspace.py
+++ b/tests/frontend/workspace.py
@@ -821,6 +821,8 @@ def test_detect_modifications(cli, tmpdir, datafiles, modification, strict):
{"format-version": 0, "alpha.bst": {0: "/workspaces/bravo", 1: "/workspaces/charlie",}},
# Test loading a version with decimals
{"format-version": 0.5},
+ # Test loading an unsupported old version
+ {"format-version": 3},
# Test loading a future version
{"format-version": BST_WORKSPACE_FORMAT_VERSION + 1},
],
@@ -842,58 +844,10 @@ def test_list_unsupported_workspace(cli, datafiles, workspace_cfg):
@pytest.mark.parametrize(
"workspace_cfg,expected",
[
- # Test loading version 0 without a dict
+ # Test loading version 4
(
- {"alpha.bst": "/workspaces/bravo"},
{
- "format-version": BST_WORKSPACE_FORMAT_VERSION,
- "workspaces": {"alpha.bst": {"prepared": False, "path": "/workspaces/bravo", "running_files": {}}},
- },
- ),
- # Test loading version 0 with only one source
- (
- {"alpha.bst": {0: "/workspaces/bravo"}},
- {
- "format-version": BST_WORKSPACE_FORMAT_VERSION,
- "workspaces": {"alpha.bst": {"prepared": False, "path": "/workspaces/bravo", "running_files": {}}},
- },
- ),
- # Test loading version 1
- (
- {"format-version": 1, "workspaces": {"alpha.bst": {"path": "/workspaces/bravo"}}},
- {
- "format-version": BST_WORKSPACE_FORMAT_VERSION,
- "workspaces": {"alpha.bst": {"prepared": False, "path": "/workspaces/bravo", "running_files": {}}},
- },
- ),
- # Test loading version 2
- (
- {
- "format-version": 2,
- "workspaces": {
- "alpha.bst": {
- "path": "/workspaces/bravo",
- "last_successful": "some_key",
- "running_files": {"beta.bst": ["some_file"]},
- }
- },
- },
- {
- "format-version": BST_WORKSPACE_FORMAT_VERSION,
- "workspaces": {
- "alpha.bst": {
- "prepared": False,
- "path": "/workspaces/bravo",
- "last_successful": "some_key",
- "running_files": {"beta.bst": ["some_file"]},
- }
- },
- },
- ),
- # Test loading version 3
- (
- {
- "format-version": 3,
+ "format-version": 4,
"workspaces": {"alpha.bst": {"prepared": True, "path": "/workspaces/bravo", "running_files": {}}},
},
{