From eebfcef4abc1e8553a11d16effd28a0aa49e612c Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Mon, 5 Feb 2024 18:22:36 +0200 Subject: [PATCH] remove vmtools and contract test command --- CLI.md | 13 +++-- multiversx_sdk_cli/cli_contracts.py | 19 -------- multiversx_sdk_cli/config.py | 5 -- multiversx_sdk_cli/dependencies/install.py | 4 +- multiversx_sdk_cli/dependencies/modules.py | 53 --------------------- multiversx_sdk_cli/projects/__init__.py | 4 +- multiversx_sdk_cli/projects/core.py | 17 +------ multiversx_sdk_cli/projects/project_base.py | 24 +--------- multiversx_sdk_cli/tests/test_cli_deps.py | 12 ----- 9 files changed, 13 insertions(+), 138 deletions(-) diff --git a/CLI.md b/CLI.md index 6f18244f..32da1b6b 100644 --- a/CLI.md +++ b/CLI.md @@ -57,7 +57,7 @@ usage: mxpy contract COMMAND [-h] ... Build, deploy, upgrade and interact with Smart Contracts COMMANDS: - {new,templates,build,clean,test,report,deploy,call,upgrade,query,verify,reproducible-build} + {new,templates,build,clean,report,deploy,call,upgrade,query,verify,reproducible-build} OPTIONS: -h, --help show this help message and exit @@ -69,7 +69,6 @@ new Create a new Smart Contract project based on a te templates List the available Smart Contract templates. build Build a Smart Contract project. clean Clean a Smart Contract project. -test Run scenarios (tests). report Print a detailed report of the smart contracts. deploy Deploy a Smart Contract. call Interact with a Smart Contract (execute function). @@ -1263,11 +1262,11 @@ usage: mxpy deps install [-h] ... Install dependencies or multiversx-sdk modules. positional arguments: - {all,rust,golang,vmtools,testwallets} the dependency to install + {all,rust,golang,testwallets} the dependency to install options: - -h, --help show this help message and exit - --overwrite whether to overwrite an existing installation + -h, --help show this help message and exit + --overwrite whether to overwrite an existing installation ``` ### Dependencies.Check @@ -1280,10 +1279,10 @@ usage: mxpy deps check [-h] ... Check whether a dependency is installed. positional arguments: - {all,rust,golang,vmtools,testwallets} the dependency to check + {all,rust,golang,testwallets} the dependency to check options: - -h, --help show this help message and exit + -h, --help show this help message and exit ``` ## Group **Configuration** diff --git a/multiversx_sdk_cli/cli_contracts.py b/multiversx_sdk_cli/cli_contracts.py index 53cdf3db..cb78b6dc 100644 --- a/multiversx_sdk_cli/cli_contracts.py +++ b/multiversx_sdk_cli/cli_contracts.py @@ -53,14 +53,6 @@ def setup_parser(args: List[str], subparsers: Any) -> Any: sub.add_argument("--path", default=os.getcwd(), help="the project directory (default: current directory)") sub.set_defaults(func=clean) - sub = cli_shared.add_command_subparser(subparsers, "contract", "test", "Run scenarios (tests).") - _add_project_arg(sub) - sub.add_argument("--directory", default="scenarios", - help="🗀 the directory containing the tests (default: %(default)s)") - sub.add_argument("--wildcard", required=False, help="wildcard to match only specific test files") - _add_recursive_arg(sub) - sub.set_defaults(func=run_tests) - sub = cli_shared.add_command_subparser(subparsers, "contract", "report", "Print a detailed report of the smart contracts.") sub.add_argument("--skip-build", action="store_true", default=False, help="skips the step of building of the wasm contracts") sub.add_argument("--skip-twiggy", action="store_true", default=False, help="skips the steps of building the debug wasm files and running twiggy") @@ -213,10 +205,6 @@ def _add_build_options_args(sub: Any): help="for rust projects, optionally specify the suffix of the wasm bytecode output file") -def _add_recursive_arg(sub: Any): - sub.add_argument("-r", "--recursive", dest="recursive", action="store_true", help="locate projects recursively") - - def _add_bytecode_arg(sub: Any): sub.add_argument("--bytecode", type=str, required=True, help="the file containing the WASM bytecode") @@ -300,13 +288,6 @@ def do_report(args: Any): projects.do_report(args, args_dict) -def run_tests(args: Any): - check_if_rust_is_installed() - project_paths = get_project_paths(args) - for project in project_paths: - projects.run_tests(project, args) - - def deploy(args: Any): logger.debug("deploy") cli_shared.check_guardian_and_options_args(args) diff --git a/multiversx_sdk_cli/config.py b/multiversx_sdk_cli/config.py index 01aee78e..f8f33cd8 100644 --- a/multiversx_sdk_cli/config.py +++ b/multiversx_sdk_cli/config.py @@ -3,7 +3,6 @@ from typing import Any, Dict, List from multiversx_sdk_cli import errors, utils -from multiversx_sdk_cli.ux import show_warning SDK_PATH = Path("~/multiversx-sdk").expanduser().resolve() LOCAL_CONFIG_PATH = Path("mxpy.json").resolve() @@ -143,10 +142,6 @@ def _guard_valid_config_deletion(name: str): def get_defaults() -> Dict[str, Any]: return { - "dependencies.vmtools.tag": "v1.5.24", - "dependencies.vmtools.urlTemplate.linux": "https://github.com/multiversx/mx-chain-vm-go/archive/{TAG}.tar.gz", - "dependencies.vmtools.urlTemplate.osx": "https://github.com/multiversx/mx-chain-vm-go/archive/{TAG}.tar.gz", - "dependencies.vmtools.urlTemplate.windows": "https://github.com/multiversx/mx-chain-vm-go/archive/{TAG}.tar.gz", "dependencies.rust.tag": "nightly-2023-12-11", "dependencies.golang.resolution": "SDK", "dependencies.golang.tag": "go1.20.7", diff --git a/multiversx_sdk_cli/dependencies/install.py b/multiversx_sdk_cli/dependencies/install.py index 0ca7d900..61bf0fe4 100644 --- a/multiversx_sdk_cli/dependencies/install.py +++ b/multiversx_sdk_cli/dependencies/install.py @@ -5,8 +5,7 @@ from multiversx_sdk_cli import config, errors from multiversx_sdk_cli.dependencies.modules import (DependencyModule, GolangModule, Rust, - TestWalletsModule, - VMToolsModule) + TestWalletsModule) logger = logging.getLogger("install") @@ -51,7 +50,6 @@ def get_all_deps() -> List[DependencyModule]: return [ Rust(key="rust"), GolangModule(key="golang"), - VMToolsModule(key="vmtools"), TestWalletsModule(key="testwallets") ] diff --git a/multiversx_sdk_cli/dependencies/modules.py b/multiversx_sdk_cli/dependencies/modules.py index 3f21dbd2..4c9a49ac 100644 --- a/multiversx_sdk_cli/dependencies/modules.py +++ b/multiversx_sdk_cli/dependencies/modules.py @@ -135,59 +135,6 @@ def _get_archive_path(self, tag: str) -> Path: return archive -class VMToolsModule(StandaloneModule): - def __init__(self, key: str, aliases: List[str] = []): - super().__init__(key, aliases) - self.repo_name = 'mx-chain-vm-go' - self.organisation = 'multiversx' - - def _post_install(self, tag: str): - dependencies.install_module('golang') - - self.build_binary(tag, 'test') - self.make_binary_symlink_in_parent_folder(tag, 'test', 'run-scenarios') - self.copy_libwasmer_in_parent_directory(tag) - - def build_binary(self, tag: str, binary_name: str): - source_folder = self.binary_source_folder(tag, binary_name) - golang = dependencies.get_module_by_key("golang") - golang_env = golang.get_env() - myprocess.run_process(['go', 'build'], cwd=source_folder, env=golang_env) - - def binary_source_folder(self, tag: str, binary_name: str): - directory = self.get_source_directory(tag) - return directory / 'cmd' / binary_name - - def make_binary_symlink_in_parent_folder(self, tag: str, binary_name: str, symlink_name: str): - source_folder = self.binary_source_folder(tag, binary_name) - binary = source_folder / binary_name - - parent = self.get_parent_directory() - symlink = parent / symlink_name - - symlink.unlink(missing_ok=True) - symlink.symlink_to(binary) - - def copy_libwasmer_in_parent_directory(self, tag: str): - libwasmer_directory = self.get_source_directory(tag) / 'wasmer' - cmd_test_directory = self.get_source_directory(tag) / 'cmd' / 'test' - parent_directory = self.get_parent_directory() - for f in libwasmer_directory.iterdir(): - if f.suffix in ['.dylib', '.so', '.dll']: - # Copy the dynamic library near the "run-scenarios" symlink - shutil.copy(f, parent_directory) - # Though, also copy the dynamic library near the target executable (seems to be necessary on MacOS) - shutil.copy(f, cmd_test_directory) - - def get_env(self) -> Dict[str, str]: - return dict() - - def get_source_directory(self, tag: str) -> Path: - directory = self.get_directory(tag) - first_subdirectory = next(directory.iterdir()) - return first_subdirectory - - class GolangModule(StandaloneModule): def _post_install(self, tag: str): parent_directory = self.get_parent_directory() diff --git a/multiversx_sdk_cli/projects/__init__.py b/multiversx_sdk_cli/projects/__init__.py index db23619f..b65c13eb 100644 --- a/multiversx_sdk_cli/projects/__init__.py +++ b/multiversx_sdk_cli/projects/__init__.py @@ -1,8 +1,8 @@ from multiversx_sdk_cli.projects.core import (build_project, clean_project, - load_project, run_tests) + load_project) from multiversx_sdk_cli.projects.project_base import Project from multiversx_sdk_cli.projects.project_rust import ProjectRust from multiversx_sdk_cli.projects.report.do_report import do_report from multiversx_sdk_cli.projects.templates import Contract -__all__ = ["build_project", "clean_project", "do_report", "run_tests", "load_project", "Project", "ProjectRust", "Contract"] +__all__ = ["build_project", "clean_project", "do_report", "load_project", "Project", "ProjectRust", "Contract"] diff --git a/multiversx_sdk_cli/projects/core.py b/multiversx_sdk_cli/projects/core.py index ebba16e6..0b5275bb 100644 --- a/multiversx_sdk_cli/projects/core.py +++ b/multiversx_sdk_cli/projects/core.py @@ -1,8 +1,8 @@ import logging from pathlib import Path -from typing import Any, List +from typing import List -from multiversx_sdk_cli import dependencies, errors, guards +from multiversx_sdk_cli import errors, guards from multiversx_sdk_cli.projects import shared from multiversx_sdk_cli.projects.constants import (OLD_PROJECT_CONFIG_FILENAME, PROJECT_CONFIG_FILENAME) @@ -42,19 +42,6 @@ def clean_project(directory: Path): logger.info("Project cleaned.") -def run_tests(project_path: Path, args: Any): - directory = Path(args.directory) - wildcard = args.wildcard - - logger.info("run_tests.project: %s", project_path) - - dependencies.install_module("vmtools") - - guards.is_directory(project_path) - project = load_project(project_path) - project.run_tests(directory, wildcard) - - def get_project_paths_recursively(base_path: Path) -> List[Path]: guards.is_directory(base_path) old_markers = list(base_path.glob(f"**/{OLD_PROJECT_CONFIG_FILENAME}")) diff --git a/multiversx_sdk_cli/projects/project_base.py b/multiversx_sdk_cli/projects/project_base.py index 74777af1..c02dfb31 100644 --- a/multiversx_sdk_cli/projects/project_base.py +++ b/multiversx_sdk_cli/projects/project_base.py @@ -1,13 +1,11 @@ -import glob import logging import shutil from abc import abstractmethod from os import path from pathlib import Path -from typing import Any, Dict, List, Union, cast, final +from typing import Any, Dict, List, Union, final -from multiversx_sdk_cli import dependencies, errors, myprocess, utils -from multiversx_sdk_cli.dependencies.modules import StandaloneModule +from multiversx_sdk_cli import dependencies, errors, utils from multiversx_sdk_cli.projects.constants import PROJECT_CONFIG_FILENAME from multiversx_sdk_cli.projects.interfaces import IProject from multiversx_sdk_cli.projects.migrations import migrate_project_config_file @@ -129,24 +127,6 @@ def ensure_config_file(self) -> None: def default_config(self) -> Dict[str, Any]: return dict() - def run_tests(self, tests_directory: Path, wildcard: str = ""): - vmtools = cast(StandaloneModule, dependencies.get_module_by_key("vmtools")) - tool_env = vmtools.get_env() - tool = path.join(vmtools.get_parent_directory(), "run-scenarios") - test_folder = self.directory / tests_directory - - if not wildcard: - args = [tool, str(test_folder)] - myprocess.run_process(args, env=tool_env) - else: - pattern = test_folder / wildcard - test_files = glob.glob(str(pattern)) - - for test_file in test_files: - print("Run test for:", test_file) - args = [tool, test_file] - myprocess.run_process(args, env=tool_env) - def glob_files(folder: Path, pattern: str) -> List[Path]: files = folder.rglob(pattern) diff --git a/multiversx_sdk_cli/tests/test_cli_deps.py b/multiversx_sdk_cli/tests/test_cli_deps.py index 762e3d24..63162d71 100644 --- a/multiversx_sdk_cli/tests/test_cli_deps.py +++ b/multiversx_sdk_cli/tests/test_cli_deps.py @@ -31,18 +31,6 @@ def test_deps_check_rust(): assert which_twiggy and Path.is_file(Path(which_twiggy)) -@pytest.mark.skip_on_windows -def test_deps_install_vmtools(): - return_code = main(["deps", "install", "vmtools"]) - assert return_code == 0 - - -@pytest.mark.skip_on_windows -def test_deps_check_vmtools(): - return_code = main(["deps", "check", "vmtools"]) - assert return_code == 0 - - def test_deps_install_testwallets(): return_code = main(["deps", "install", "testwallets"]) assert return_code == 0