From 28a959295bf034010b8a5f9f108c6f7be5ad9949 Mon Sep 17 00:00:00 2001 From: "Rodrigo Q. Saramago" Date: Wed, 26 Apr 2023 14:14:36 +0200 Subject: [PATCH] Move common.sh from test/externalTests to scripts/externalTests --- scripts/common/shell_command.py | 34 ----------------------- {test => scripts}/externalTests/common.sh | 0 test/externalTests/bleeps.sh | 2 +- test/externalTests/brink.sh | 2 +- test/externalTests/chainlink.sh | 2 +- test/externalTests/colony.sh | 2 +- test/externalTests/elementfi.sh | 2 +- test/externalTests/ens.sh | 2 +- test/externalTests/euler.sh | 2 +- test/externalTests/gnosis.sh | 2 +- test/externalTests/gp2.sh | 2 +- test/externalTests/perpetual-pools.sh | 2 +- test/externalTests/pool-together.sh | 2 +- test/externalTests/prb-math.sh | 2 +- test/externalTests/solc-js/solc-js.sh | 2 +- test/externalTests/trident.sh | 2 +- test/externalTests/uniswap.sh | 2 +- test/externalTests/yield-liquidator.sh | 2 +- test/externalTests/zeppelin.sh | 2 +- test/external_tests.py | 13 ++------- 20 files changed, 19 insertions(+), 62 deletions(-) delete mode 100644 scripts/common/shell_command.py rename {test => scripts}/externalTests/common.sh (100%) diff --git a/scripts/common/shell_command.py b/scripts/common/shell_command.py deleted file mode 100644 index e31389bb8283..000000000000 --- a/scripts/common/shell_command.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 -import os -import subprocess - -def run_cmd(command: str, env: dict = None, logfile: str = None) -> int: - """ - Args: - command: command to run - logfile: log file name - env: dictionary holding key-value pairs for bash environment variables - Returns: - int: The exit status of the command. Exit status codes are: - 0 -> Success - 1-255 -> Failure - """ - if logfile is None: - logfile = os.devnull - if env is None: - env = os.environ.copy() - with open( - file=logfile, - mode='w', - encoding='utf8' - ) as log: - ret = subprocess.run( - command, - shell=True, - check=True, - executable='/bin/bash', - env=env, - stdout=log if not logfile else None, - stderr=None - ) - return ret.returncode diff --git a/test/externalTests/common.sh b/scripts/externalTests/common.sh similarity index 100% rename from test/externalTests/common.sh rename to scripts/externalTests/common.sh diff --git a/test/externalTests/bleeps.sh b/test/externalTests/bleeps.sh index 22e54ac9cea0..939552100495 100755 --- a/test/externalTests/bleeps.sh +++ b/test/externalTests/bleeps.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/externalTests/brink.sh b/test/externalTests/brink.sh index 901a0cfc0dec..77dd62f940f8 100755 --- a/test/externalTests/brink.sh +++ b/test/externalTests/brink.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/externalTests/chainlink.sh b/test/externalTests/chainlink.sh index 249a1254cddf..a11266c3b84b 100755 --- a/test/externalTests/chainlink.sh +++ b/test/externalTests/chainlink.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/externalTests/colony.sh b/test/externalTests/colony.sh index 8582411b998d..402865107a8d 100755 --- a/test/externalTests/colony.sh +++ b/test/externalTests/colony.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/externalTests/elementfi.sh b/test/externalTests/elementfi.sh index b667a4bbc08f..b3348e339c9a 100755 --- a/test/externalTests/elementfi.sh +++ b/test/externalTests/elementfi.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/externalTests/ens.sh b/test/externalTests/ens.sh index 77395160d340..7f713f4abd81 100755 --- a/test/externalTests/ens.sh +++ b/test/externalTests/ens.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/externalTests/euler.sh b/test/externalTests/euler.sh index 78e89d147b82..586526124f31 100755 --- a/test/externalTests/euler.sh +++ b/test/externalTests/euler.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/externalTests/gnosis.sh b/test/externalTests/gnosis.sh index 00ea2597e870..de0624c06c57 100755 --- a/test/externalTests/gnosis.sh +++ b/test/externalTests/gnosis.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/externalTests/gp2.sh b/test/externalTests/gp2.sh index 120379478ad4..a73f1453b3a7 100755 --- a/test/externalTests/gp2.sh +++ b/test/externalTests/gp2.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/externalTests/perpetual-pools.sh b/test/externalTests/perpetual-pools.sh index 18fb308af4af..70a14c499338 100755 --- a/test/externalTests/perpetual-pools.sh +++ b/test/externalTests/perpetual-pools.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/externalTests/pool-together.sh b/test/externalTests/pool-together.sh index 86cd3ee684e6..77b3ad1499b2 100755 --- a/test/externalTests/pool-together.sh +++ b/test/externalTests/pool-together.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/externalTests/prb-math.sh b/test/externalTests/prb-math.sh index 78a39519e4c0..99c7c2716cde 100755 --- a/test/externalTests/prb-math.sh +++ b/test/externalTests/prb-math.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/externalTests/solc-js/solc-js.sh b/test/externalTests/solc-js/solc-js.sh index bf7ca87628bd..af325326c2db 100755 --- a/test/externalTests/solc-js/solc-js.sh +++ b/test/externalTests/solc-js/solc-js.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh SOLJSON="$1" VERSION="$2" diff --git a/test/externalTests/trident.sh b/test/externalTests/trident.sh index b5d48b500a20..f02123217a2b 100755 --- a/test/externalTests/trident.sh +++ b/test/externalTests/trident.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/externalTests/uniswap.sh b/test/externalTests/uniswap.sh index 8b07aee84e96..d9a25138f8c5 100755 --- a/test/externalTests/uniswap.sh +++ b/test/externalTests/uniswap.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/externalTests/yield-liquidator.sh b/test/externalTests/yield-liquidator.sh index a224433117dd..8b256d797acf 100755 --- a/test/externalTests/yield-liquidator.sh +++ b/test/externalTests/yield-liquidator.sh @@ -22,7 +22,7 @@ set -e source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/externalTests/zeppelin.sh b/test/externalTests/zeppelin.sh index 2a95fc8ddf20..46b3f2d89886 100755 --- a/test/externalTests/zeppelin.sh +++ b/test/externalTests/zeppelin.sh @@ -27,7 +27,7 @@ set -e export NODE_OPTIONS="--max-old-space-size=4096" source scripts/common.sh -source test/externalTests/common.sh +source scripts/externalTests/common.sh REPO_ROOT=$(realpath "$(dirname "$0")/../..") diff --git a/test/external_tests.py b/test/external_tests.py index c230533a0912..e25311793ed5 100755 --- a/test/external_tests.py +++ b/test/external_tests.py @@ -23,13 +23,7 @@ import os from pathlib import Path import sys - -# Our scripts/ is not a proper Python package so we need to modify PYTHONPATH to import from it -# pragma pylint: disable=import-error,wrong-import-position -SCRIPTS_DIR = Path(__file__).parents[1] / "scripts" -sys.path.insert(0, str(SCRIPTS_DIR)) - -from common.shell_command import run_cmd +import subprocess EXTERNAL_TESTS_DIR = Path(__file__).parent / "externalTests" @@ -39,13 +33,10 @@ class ExternalTestNotFound(Exception): def detect_external_tests() -> dict: - # TODO: Remove `file_path.stem != "common"` when we complete the migration - # of the external tests to python, since there will be no more - # common.sh script in the externalTests folder. return { file_path.stem: file_path for file_path in Path(EXTERNAL_TESTS_DIR).iterdir() - if file_path.is_file() and file_path.suffix == ".sh" and file_path.stem != "common" + if file_path.is_file() and file_path.suffix == ".sh" }