diff options
author | Jürg Billeter <j@bitron.ch> | 2020-02-06 08:49:28 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2020-02-11 21:07:39 +0100 |
commit | 2d0ef3aa9edb9794ac79abda98e6350efbee8b57 (patch) | |
tree | 7821528e6abc47da42dfa917c797450e75ce98d3 | |
parent | 2ddcc45138adaabd4b9c81d96c859c76794978bc (diff) | |
download | buildstream-2d0ef3aa9edb9794ac79abda98e6350efbee8b57.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.py | 40 | ||||
-rw-r--r-- | tests/frontend/workspace.py | 54 |
2 files changed, 13 insertions, 81 deletions
diff --git a/src/buildstream/_workspaces.py b/src/buildstream/_workspaces.py index 478b7d3b5..3035411d6 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" @@ -511,38 +510,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": {}}}, }, { |