diff options
Diffstat (limited to 'tests/frontend')
31 files changed, 85 insertions, 41 deletions
diff --git a/tests/frontend/__init__.py b/tests/frontend/__init__.py index ad1f9ea92..65ecda3ef 100644 --- a/tests/frontend/__init__.py +++ b/tests/frontend/__init__.py @@ -6,5 +6,6 @@ from buildstream import _yaml # def configure_project(path, config): config["name"] = "test" + config["min-version"] = "2.0" config["element-path"] = "elements" _yaml.roundtrip_dump(config, os.path.join(path, "project.conf")) diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index 1aa9bbd01..96c96ccfe 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -1001,6 +1001,7 @@ def test_partial_artifact_checkout_fetch(cli, datafiles, tmpdir): project = str(tmpdir) project_config = { "name": "partial-artifact-checkout-fetch", + "min-version": "2.0", "element-path": "elements", } project_file = os.path.join(str(tmpdir), "project.conf") diff --git a/tests/frontend/completions/no-element-path/project.conf b/tests/frontend/completions/no-element-path/project.conf index e7e35e716..4090cce21 100644 --- a/tests/frontend/completions/no-element-path/project.conf +++ b/tests/frontend/completions/no-element-path/project.conf @@ -1,2 +1,3 @@ # Project config for frontend build test name: test +min-version: 2.0 diff --git a/tests/frontend/completions/project/project.conf b/tests/frontend/completions/project/project.conf index 854e38693..5ba316874 100644 --- a/tests/frontend/completions/project/project.conf +++ b/tests/frontend/completions/project/project.conf @@ -1,4 +1,4 @@ # Project config for frontend build test name: test - +min-version: 2.0 element-path: elements diff --git a/tests/frontend/completions/sub-folders/project.conf b/tests/frontend/completions/sub-folders/project.conf index 854e38693..5ba316874 100644 --- a/tests/frontend/completions/sub-folders/project.conf +++ b/tests/frontend/completions/sub-folders/project.conf @@ -1,4 +1,4 @@ # Project config for frontend build test name: test - +min-version: 2.0 element-path: elements diff --git a/tests/frontend/configurable_warnings.py b/tests/frontend/configurable_warnings.py index be0706360..e61db6c37 100644 --- a/tests/frontend/configurable_warnings.py +++ b/tests/frontend/configurable_warnings.py @@ -16,6 +16,7 @@ TOP_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "configuredw def get_project(fatal_warnings): return { "name": "test", + "min-version": "2.0", "element-path": "elements", "plugins": [ {"origin": "local", "path": "plugins", "elements": {"warninga": 0, "warningb": 0, "corewarn": 0,}} diff --git a/tests/frontend/configuredwarning/project.conf b/tests/frontend/configuredwarning/project.conf index c73d217b8..195ee176a 100644 --- a/tests/frontend/configuredwarning/project.conf +++ b/tests/frontend/configuredwarning/project.conf @@ -1,4 +1,5 @@ name: test +min-version: 2.0 element-path: elements plugins: - origin: local diff --git a/tests/frontend/consistencyerror/project.conf b/tests/frontend/consistencyerror/project.conf index 524a32134..d28ba12df 100644 --- a/tests/frontend/consistencyerror/project.conf +++ b/tests/frontend/consistencyerror/project.conf @@ -1,6 +1,7 @@ # Basic project configuration that doesnt override anything # name: test +min-version: 2.0 # Whitelist the local test Sources # diff --git a/tests/frontend/cross_junction_workspace.py b/tests/frontend/cross_junction_workspace.py index 574de2bed..5e25d1fa8 100644 --- a/tests/frontend/cross_junction_workspace.py +++ b/tests/frontend/cross_junction_workspace.py @@ -13,8 +13,8 @@ def prepare_junction_project(cli, tmpdir): os.makedirs(str(main_project)) os.makedirs(str(sub_project)) - _yaml.roundtrip_dump({"name": "main"}, str(main_project.join("project.conf"))) - _yaml.roundtrip_dump({"name": "sub"}, str(sub_project.join("project.conf"))) + _yaml.roundtrip_dump({"name": "main", "min-version": "2.0"}, str(main_project.join("project.conf"))) + _yaml.roundtrip_dump({"name": "sub", "min-version": "2.0"}, str(sub_project.join("project.conf"))) import_dir = tmpdir.join("import") os.makedirs(str(import_dir)) diff --git a/tests/frontend/default-target/files/sub-project/project.conf b/tests/frontend/default-target/files/sub-project/project.conf index db76b5267..85e67e961 100644 --- a/tests/frontend/default-target/files/sub-project/project.conf +++ b/tests/frontend/default-target/files/sub-project/project.conf @@ -1,3 +1,3 @@ name: test-default-target-subproject - +min-version: 2.0 element-path: elements diff --git a/tests/frontend/default-target/project.conf b/tests/frontend/default-target/project.conf index 17937ed73..095c54610 100644 --- a/tests/frontend/default-target/project.conf +++ b/tests/frontend/default-target/project.conf @@ -1,3 +1,3 @@ name: test-default-target - +min-version: 2.0 element-path: elements diff --git a/tests/frontend/default_target.py b/tests/frontend/default_target.py index d2a75c961..bb7a49592 100644 --- a/tests/frontend/default_target.py +++ b/tests/frontend/default_target.py @@ -40,6 +40,7 @@ def test_default_target(cli, datafiles, operation, expected_state): # First, modify project configuration to set a default target project_conf = { "name": "test-default-target", + "min-version": "2.0", "element-path": "elements", "defaults": {"targets": ["dummy_stack.bst"]}, } @@ -102,6 +103,7 @@ def test_default_target_track(cli, tmpdir, datafiles): # Then, make it the default target project_conf = { "name": "test-default-target", + "min-version": "2.0", "element-path": "elements", "defaults": {"targets": [target]}, } @@ -131,6 +133,7 @@ def test_default_target_fetch(cli, tmpdir, datafiles): # Then, make it the default target project_conf = { "name": "test-default-target", + "min-version": "2.0", "element-path": "elements", "defaults": {"targets": [target]}, } @@ -157,6 +160,7 @@ def test_default_target_push_pull(cli, tmpdir, datafiles): # Set a default target project_conf = { "name": "test-default-target", + "min-version": "2.0", "element-path": "elements", "defaults": {"targets": [target]}, } diff --git a/tests/frontend/exceptions/project.conf b/tests/frontend/exceptions/project.conf index 2027cc27a..716db37ac 100644 --- a/tests/frontend/exceptions/project.conf +++ b/tests/frontend/exceptions/project.conf @@ -1,3 +1,4 @@ # Basic project configuration that doesnt override anything # name: pony +min-version: 2.0 diff --git a/tests/frontend/init.py b/tests/frontend/init.py index 78aa3eb19..db1b9c955 100644 --- a/tests/frontend/init.py +++ b/tests/frontend/init.py @@ -6,9 +6,24 @@ import pytest from buildstream.testing import cli # pylint: disable=unused-import from buildstream import _yaml +from buildstream import utils from buildstream._frontend.app import App from buildstream.exceptions import ErrorDomain, LoadErrorReason -from buildstream._versions import BST_FORMAT_VERSION + + +def get_default_min_version(): + bst_major, bst_minor = utils.get_bst_version() + + # For the version check, artificially set the version to at least + # version 2.0 + # + # TODO: Remove this code block after releasing 2.0 + # + if bst_major < 2: + bst_major = 2 + bst_minor = 0 + + return "{}.{}".format(bst_major, bst_minor) def test_defaults(cli, tmpdir): @@ -20,7 +35,7 @@ def test_defaults(cli, tmpdir): project_conf = _yaml.load(project_path) assert project_conf.get_str("name") == "foo" - assert project_conf.get_str("format-version") == str(BST_FORMAT_VERSION) + assert project_conf.get_str("min-version") == get_default_min_version() assert project_conf.get_str("element-path") == "elements" @@ -29,13 +44,13 @@ def test_all_options(cli, tmpdir): project_path = os.path.join(project, "project.conf") result = cli.run( - args=["init", "--project-name", "foo", "--format-version", "2", "--element-path", "ponies", project] + args=["init", "--project-name", "foo", "--min-version", "2.0", "--element-path", "ponies", project] ) result.assert_success() project_conf = _yaml.load(project_path) assert project_conf.get_str("name") == "foo" - assert project_conf.get_str("format-version") == str(2) + assert project_conf.get_str("min-version") == "2.0" assert project_conf.get_str("element-path") == "ponies" elements_dir = os.path.join(project, "ponies") @@ -68,7 +83,7 @@ def test_force_overwrite_project(cli, tmpdir): project_conf = _yaml.load(project_path) assert project_conf.get_str("name") == "foo" - assert project_conf.get_str("format-version") == str(BST_FORMAT_VERSION) + assert project_conf.get_str("min-version") == get_default_min_version() def test_relative_path_directory_as_argument(cli, tmpdir): @@ -82,7 +97,7 @@ def test_relative_path_directory_as_argument(cli, tmpdir): project_conf = _yaml.load(project_path) assert project_conf.get_str("name") == "foo" - assert project_conf.get_int("format-version") == BST_FORMAT_VERSION + assert project_conf.get_str("min-version") == get_default_min_version() assert project_conf.get_str("element-path") == "elements" @@ -97,10 +112,10 @@ def test_bad_project_name(cli, tmpdir, project_name): result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_SYMBOL_NAME) -@pytest.mark.parametrize("format_version", [(str(-1)), (str(BST_FORMAT_VERSION + 1))]) -def test_bad_format_version(cli, tmpdir, format_version): - result = cli.run(args=["init", "--project-name", "foo", "--format-version", format_version, str(tmpdir)]) - result.assert_main_error(ErrorDomain.APP, "invalid-format-version") +@pytest.mark.parametrize("min_version", [("-1"), ("1.4"), ("2.900"), ("abc")]) +def test_bad_min_version(cli, tmpdir, min_version): + result = cli.run(args=["init", "--project-name", "foo", "--min-version", min_version, str(tmpdir)]) + result.assert_main_error(ErrorDomain.APP, "invalid-min-version") @pytest.mark.parametrize("element_path", [("/absolute/path"), ("../outside/of/project")]) @@ -124,7 +139,7 @@ def test_element_path_interactive(cli, tmp_path, monkeypatch, element_path): return DummyInteractiveApp(*args, **kwargs) def _init_project_interactive(self, *args, **kwargs): # pylint: disable=arguments-differ - return ("project_name", "0", element_path) + return ("project_name", "2.0", element_path) monkeypatch.setattr(App, "create", DummyInteractiveApp.create) @@ -136,5 +151,5 @@ def test_element_path_interactive(cli, tmp_path, monkeypatch, element_path): project_conf = _yaml.load(str(project_conf_path)) assert project_conf.get_str("name") == "project_name" - assert project_conf.get_str("format-version") == "0" + assert project_conf.get_str("min-version") == "2.0" assert project_conf.get_str("element-path") == element_path diff --git a/tests/frontend/interactive_init.py b/tests/frontend/interactive_init.py index c8f169000..b8cbe522f 100644 --- a/tests/frontend/interactive_init.py +++ b/tests/frontend/interactive_init.py @@ -1,23 +1,33 @@ import os import pexpect -from ruamel import yaml -from buildstream._versions import BST_FORMAT_VERSION +from buildstream import _yaml +from buildstream import utils from tests.testutils.constants import PEXPECT_TIMEOUT_SHORT def test_init(tmpdir): session = pexpect.spawn("bst", ["--no-colors", "init", str(tmpdir)], timeout=PEXPECT_TIMEOUT_SHORT) name = "test-project" - format_version = 24 + min_version = "2.0" element_path = "my-elements" + bst_major, bst_minor = utils.get_bst_version() + + # For the version check, artificially set the version to at least + # version 2.0 + # + # TODO: Remove this code block after releasing 2.0 + # + if bst_major < 2: + bst_major = 2 + bst_minor = 0 session.expect_exact("Project name:") session.sendline(name) - session.expect_exact("Format version [{}]:".format(BST_FORMAT_VERSION)) - session.sendline(str(format_version)) + session.expect_exact("Minimum version [{}.{}]:".format(bst_major, bst_minor)) + session.sendline(str(min_version)) session.expect_exact("Element path [elements]:") session.sendline(element_path) @@ -26,9 +36,7 @@ def test_init(tmpdir): session.close() # Now assert that a project.conf got created with expected values - with open(os.path.join(str(tmpdir), "project.conf")) as f: - project_conf = yaml.safe_load(f) - - assert project_conf["name"] == name - assert project_conf["format-version"] == format_version - assert project_conf["element-path"] == element_path + project_conf = _yaml.load(os.path.join(str(tmpdir), "project.conf")) + assert project_conf.get_str("name") == name + assert project_conf.get_str("min-version") == min_version + assert project_conf.get_str("element-path") == element_path diff --git a/tests/frontend/invalid_element_path/project.conf b/tests/frontend/invalid_element_path/project.conf index 7b09276e1..e752d22d5 100644 --- a/tests/frontend/invalid_element_path/project.conf +++ b/tests/frontend/invalid_element_path/project.conf @@ -1,4 +1,4 @@ # Project config for frontend build test name: test - +min-version: 2.0 elephant-path: elements diff --git a/tests/frontend/mirror.py b/tests/frontend/mirror.py index f71cb554d..848047ee8 100644 --- a/tests/frontend/mirror.py +++ b/tests/frontend/mirror.py @@ -41,6 +41,7 @@ def generate_element(output_file): def generate_project(): project = { "name": "test", + "min-version": "2.0", "element-path": "elements", "aliases": {"foo": "FOO/", "bar": "BAR/",}, "mirrors": [ @@ -95,6 +96,7 @@ def test_mirror_fetch_ref_storage(cli, tmpdir, datafiles, ref_storage, mirror): project = { "name": "test", + "min-version": "2.0", "element-path": "elements", "aliases": {alias: upstream_map + "/"}, "ref-storage": ref_storage, @@ -290,6 +292,7 @@ def test_mirror_git_submodule_fetch(cli, tmpdir, datafiles): mirror_map, _ = os.path.split(full_mirror) project = { "name": "test", + "min-version": "2.0", "element-path": "elements", "aliases": {alias: "http://www.example.com/"}, "mirrors": [{"name": "middle-earth", "aliases": {alias: [mirror_map + "/"],},},], @@ -361,6 +364,7 @@ def test_mirror_fallback_git_only_submodules(cli, tmpdir, datafiles): project = { "name": "test", + "min-version": "2.0", "element-path": "elements", "aliases": {alias: upstream_map + "/"}, "mirrors": [{"name": "middle-earth", "aliases": {alias: [mirror_map + "/"],}}], @@ -446,6 +450,7 @@ def test_mirror_fallback_git_with_submodules(cli, tmpdir, datafiles): project = { "name": "test", + "min-version": "2.0", "element-path": "elements", "aliases": {alias: upstream_map + "/"}, "mirrors": [{"name": "middle-earth", "aliases": {alias: [mirror_map + "/"],}}], diff --git a/tests/frontend/overlaps.py b/tests/frontend/overlaps.py index d734a3781..a45fc700d 100644 --- a/tests/frontend/overlaps.py +++ b/tests/frontend/overlaps.py @@ -14,7 +14,7 @@ DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "overlaps") def gen_project(project_dir, fail_on_overlap, use_fatal_warnings=True, project_name="test"): - template = {"name": project_name} + template = {"name": project_name, "min-version": "2.0"} if use_fatal_warnings: template["fatal-warnings"] = [CoreWarnings.OVERLAPS] if fail_on_overlap else [] else: diff --git a/tests/frontend/project/files/sub-project/project.conf b/tests/frontend/project/files/sub-project/project.conf index bbb8414a3..74cfd2583 100644 --- a/tests/frontend/project/files/sub-project/project.conf +++ b/tests/frontend/project/files/sub-project/project.conf @@ -1,4 +1,4 @@ # Project config for frontend build test name: subtest - +min-version: 2.0 element-path: elements diff --git a/tests/frontend/project/files/sub2-project/project.conf b/tests/frontend/project/files/sub2-project/project.conf index bbb8414a3..74cfd2583 100644 --- a/tests/frontend/project/files/sub2-project/project.conf +++ b/tests/frontend/project/files/sub2-project/project.conf @@ -1,4 +1,4 @@ # Project config for frontend build test name: subtest - +min-version: 2.0 element-path: elements diff --git a/tests/frontend/project/project.conf b/tests/frontend/project/project.conf index ed18221e4..c82f85bb6 100644 --- a/tests/frontend/project/project.conf +++ b/tests/frontend/project/project.conf @@ -1,6 +1,6 @@ # Project config for frontend build test name: test - +min-version: 2.0 element-path: elements fatal-warnings: diff --git a/tests/frontend/project_fail/project.conf b/tests/frontend/project_fail/project.conf index 854e38693..5ba316874 100644 --- a/tests/frontend/project_fail/project.conf +++ b/tests/frontend/project_fail/project.conf @@ -1,4 +1,4 @@ # Project config for frontend build test name: test - +min-version: 2.0 element-path: elements diff --git a/tests/frontend/pull.py b/tests/frontend/pull.py index 1845f320e..e38cd1bcb 100644 --- a/tests/frontend/pull.py +++ b/tests/frontend/pull.py @@ -312,6 +312,7 @@ def test_pull_missing_local_blob(cli, tmpdir, datafiles): project = str(tmpdir) project_config = { "name": "pull-missing-local-blob", + "min-version": "2.0", "element-path": "elements", } project_file = os.path.join(str(tmpdir), "project.conf") diff --git a/tests/frontend/push.py b/tests/frontend/push.py index c2f52c514..362084372 100644 --- a/tests/frontend/push.py +++ b/tests/frontend/push.py @@ -640,6 +640,7 @@ def test_push_after_rebuild(cli, tmpdir, datafiles): project, config={ "element-path": "elements", + "min-version": "2.0", "plugins": [{"origin": "local", "path": "plugins", "elements": {"randomelement": 0}}], }, ) diff --git a/tests/frontend/strict-depends/project.conf b/tests/frontend/strict-depends/project.conf index 627522526..1e02cb89a 100644 --- a/tests/frontend/strict-depends/project.conf +++ b/tests/frontend/strict-depends/project.conf @@ -1,2 +1,3 @@ name: test element-path: elements +min-version: 2.0 diff --git a/tests/frontend/track-cross-junction/subproject/project.conf b/tests/frontend/track-cross-junction/subproject/project.conf index b32753625..20636c446 100644 --- a/tests/frontend/track-cross-junction/subproject/project.conf +++ b/tests/frontend/track-cross-junction/subproject/project.conf @@ -1 +1,2 @@ name: test +min-version: 2.0 diff --git a/tests/frontend/track-optional-inline/project.conf b/tests/frontend/track-optional-inline/project.conf index 3f02c4718..47a2552c7 100644 --- a/tests/frontend/track-optional-inline/project.conf +++ b/tests/frontend/track-optional-inline/project.conf @@ -1,5 +1,5 @@ name: test - +min-version: 2.0 options: test: type: bool diff --git a/tests/frontend/track-optional-project-refs/project.conf b/tests/frontend/track-optional-project-refs/project.conf index 37fe02caa..3cb9bdc46 100644 --- a/tests/frontend/track-optional-project-refs/project.conf +++ b/tests/frontend/track-optional-project-refs/project.conf @@ -1,4 +1,5 @@ name: test +min-version: 2.0 ref-storage: project.refs diff --git a/tests/frontend/track.py b/tests/frontend/track.py index 07a89d428..2ebaae81f 100644 --- a/tests/frontend/track.py +++ b/tests/frontend/track.py @@ -144,7 +144,7 @@ def test_track_cross_junction(cli, tmpdir, datafiles, cross_junction, ref_storag # Generate project.conf # - project_conf = {"name": "test", "ref-storage": ref_storage} + project_conf = {"name": "test", "min-version": "2.0", "ref-storage": ref_storage} _yaml.roundtrip_dump(project_conf, os.path.join(project, "project.conf")) # diff --git a/tests/frontend/workspaced-build-dep/project.conf b/tests/frontend/workspaced-build-dep/project.conf index 48da02ff0..a4b4e7cca 100644 --- a/tests/frontend/workspaced-build-dep/project.conf +++ b/tests/frontend/workspaced-build-dep/project.conf @@ -1,8 +1,8 @@ # Unique project name name: test -# Required BuildStream format version -format-version: 18 +# Required BuildStream version +min-version: 2.0 # Subdirectory where elements are stored element-path: elements diff --git a/tests/frontend/workspaced-runtime-dep/project.conf b/tests/frontend/workspaced-runtime-dep/project.conf index 48da02ff0..a4b4e7cca 100644 --- a/tests/frontend/workspaced-runtime-dep/project.conf +++ b/tests/frontend/workspaced-runtime-dep/project.conf @@ -1,8 +1,8 @@ # Unique project name name: test -# Required BuildStream format version -format-version: 18 +# Required BuildStream version +min-version: 2.0 # Subdirectory where elements are stored element-path: elements |