Updated run_test_cmd

pull/2278/head
Vishnuram Rajkumar 10 months ago
parent df42cb66d1
commit 9db7167817
  1. 1
      slither/tools/mutator/__main__.py
  2. 2
      slither/tools/mutator/mutators/abstract_mutator.py
  3. 23
      slither/tools/mutator/utils/testing_generated_mutant.py

@ -165,6 +165,7 @@ def main() -> None:
# mutation
try:
for compilation_unit_of_main_file in sl.compilation_units:
# TODO
for M in _get_mutators(mutators_to_run):
m = M(compilation_unit_of_main_file, int(timeout), test_command, test_directory, contract_name, solc_remappings, verbose, output_folder)
# check whether the contract instance exists or not

@ -97,7 +97,7 @@ class AbstractMutator(metaclass=abc.ABCMeta): # pylint: disable=too-few-public-
return self.contract_exist
@abc.abstractmethod
def _mutate(self, test_cmd: str, test_dir: str) -> Dict:
def _mutate(self) -> Dict:
"""TODO Documentation"""
return {}

@ -16,33 +16,14 @@ def compile_generated_mutant(file_path: str, mappings: str) -> bool:
crytic_compile.CryticCompile(file_path, solc_remaps=mappings)
return True
except: # pylint: disable=broad-except
# logger.error("Error Crytic Compile")
return False
# function to run the tests
# def run_test_suite(cmd: str, dir: str) -> bool:
# try:
# # Change to the foundry folder
# # os.chdir(dir)
# result = subprocess.run(cmd.split(' '), check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# # result = subprocess.run(cmd.split(' '), check=True)
# if not result.stderr:
# return True
# except subprocess.CalledProcessError as e:
# logger.error(f"Error executing '{cmd}': {e}")
# return False
# except Exception as e:
# logger.error(f"An unexpected error occurred: {e}")
# return False
def run_test_cmd(cmd: str, dir: str, timeout: int) -> bool:
# add --fail-fast for foundry tests, to exit after first failure
if "forge test" in cmd and not "--fail-fast" in cmd :
if "forge test" in cmd and not "--fail-fast" in cmd:
cmd += " --fail-fast"
# add --bail for hardhat and truffle tests, to exit after first failure
elif not "--bail" in cmd:
elif "hardhat test" in cmd or "truffle test" and not "--bail" in cmd:
cmd += " --bail"
start = time.time()

Loading…
Cancel
Save