From 485bfaf7b6e8d55f8726c1b1229e486f298fffbe Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Mon, 25 Sep 2023 12:34:30 +0300 Subject: [PATCH] Install sc-meta when installing rust --- multiversx_sdk_cli/dependencies/modules.py | 24 +++++------- multiversx_sdk_cli/tests/shared.sh | 2 +- multiversx_sdk_cli/tests/test_cli_deps.py | 45 ++++++++++++++++++++++ multiversx_sdk_cli/tests/test_cli_deps.sh | 15 -------- 4 files changed, 56 insertions(+), 30 deletions(-) create mode 100644 multiversx_sdk_cli/tests/test_cli_deps.py delete mode 100644 multiversx_sdk_cli/tests/test_cli_deps.sh diff --git a/multiversx_sdk_cli/dependencies/modules.py b/multiversx_sdk_cli/dependencies/modules.py index 19ba3656..4979bd9f 100644 --- a/multiversx_sdk_cli/dependencies/modules.py +++ b/multiversx_sdk_cli/dependencies/modules.py @@ -272,6 +272,7 @@ def install(self, tag: str, overwrite: bool) -> None: return self._do_install(tag) + self._install_sc_meta() self._post_install(tag) def _do_install(self, tag: str) -> None: @@ -291,6 +292,11 @@ def _do_install(self, tag: str) -> None: myprocess.run_process(args) + def _install_sc_meta(self): + logger.info("Installing multiversx-sc-meta") + args = ["cargo", "install", "multiversx-sc-meta"] + myprocess.run_process(args) + def _get_installer_url(self) -> str: if workstation.is_windows(): return "https://win.rustup.rs" @@ -315,23 +321,13 @@ def _is_installed_and_set_to_nightly(self) -> bool: if not is_rust_installed: return is_rust_installed else: - if self._is_the_correct_rust_version_installed(): - return True - else: - return False - - def _is_the_correct_rust_version_installed(self) -> bool: - args = ["mxpy", "deps", "check", "rust"] - already_installed_rust_version = myprocess.run_process(args) + self._recommend_default_rust_version() + return True + def _recommend_default_rust_version(self): module = dependencies.get_module_by_key("rust") default_tag: str = config.get_dependency_tag(module.key) - - if default_tag in already_installed_rust_version: - return True - - show_warning("The rust version you have installed does not match the version we recommand. If you'd like to overwrite your current version please run `mxpy deps install rust --overwrite`.") - return False + show_warning(f"We recommend using rust {default_tag}. If you'd like to overwrite your current version please run `mxpy deps install rust --overwrite`.") def get_directory(self, tag: str) -> Path: tools_folder = workstation.get_tools_folder() diff --git a/multiversx_sdk_cli/tests/shared.sh b/multiversx_sdk_cli/tests/shared.sh index 57f3dda8..8ca40072 100755 --- a/multiversx_sdk_cli/tests/shared.sh +++ b/multiversx_sdk_cli/tests/shared.sh @@ -16,7 +16,7 @@ PROXY="${PROXY:-http://localhost:7950}" CHAIN_ID="${CHAIN_ID:-localnet}" TestUser=./testdata/testUser.pem TestUser2=./testdata/testUser2.pem -RUST_VERSION="nightly-2023-04-24" +RUST_VERSION="nightly-2023-05-26" cleanSandbox() { rm -rf ${SANDBOX} diff --git a/multiversx_sdk_cli/tests/test_cli_deps.py b/multiversx_sdk_cli/tests/test_cli_deps.py new file mode 100644 index 00000000..b5d5ca4c --- /dev/null +++ b/multiversx_sdk_cli/tests/test_cli_deps.py @@ -0,0 +1,45 @@ +import shutil + +from multiversx_sdk_cli.cli import main +from multiversx_sdk_cli.config import get_dependency_tag + + +def test_deps_install_rust(): + default_tag = get_dependency_tag("rust") + return_code = main(["deps", "install", "rust", "--tag", default_tag]) + if return_code: + assert False + else: + assert True + + +def test_deps_install_vmtools(): + return_code = main(["deps", "install", "vmtools"]) + if return_code: + assert False + else: + assert True + + +def test_deps_check_rust(): + return_code = main(["deps", "check", "rust"]) + if return_code: + assert False + else: + assert True + + +def test_check_sc_meta(): + which_sc_meta = shutil.which("sc-meta") + if which_sc_meta: + assert True + elif which_sc_meta is None: + assert False + + +def test_deps_check_vmtools(): + return_code = main(["deps", "check", "vmtools"]) + if return_code: + assert False + else: + assert True diff --git a/multiversx_sdk_cli/tests/test_cli_deps.sh b/multiversx_sdk_cli/tests/test_cli_deps.sh deleted file mode 100644 index e191201b..00000000 --- a/multiversx_sdk_cli/tests/test_cli_deps.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -source "./shared.sh" - -testAll() { - set -x - - ${CLI} --verbose deps install rust --tag=${RUST_VERSION} - ${CLI} --verbose deps install vmtools --overwrite - - ${CLI} --verbose deps check rust - ${CLI} --verbose deps check vmtools - - set +x -}