From b362a3c05788494765321f226001f289552175c3 Mon Sep 17 00:00:00 2001 From: bohendo Date: Fri, 16 Feb 2024 15:52:09 -0500 Subject: [PATCH] force recompilation during initial timing test run --- slither/tools/mutator/__main__.py | 2 +- slither/tools/mutator/utils/testing_generated_mutant.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/slither/tools/mutator/__main__.py b/slither/tools/mutator/__main__.py index 88df24b75..dde8c606b 100644 --- a/slither/tools/mutator/__main__.py +++ b/slither/tools/mutator/__main__.py @@ -204,7 +204,7 @@ def main() -> (None): # pylint: disable=too-many-statements,too-many-branches,t # run and time tests, abort if they're broken start_time = time.time() - if not run_test_cmd(test_command, "", 600): # use a very long timeout this first time + if not run_test_cmd(test_command, "", 0): # no timeout during the first run logger.error(red("Test suite fails before mutation, aborting")) return diff --git a/slither/tools/mutator/utils/testing_generated_mutant.py b/slither/tools/mutator/utils/testing_generated_mutant.py index 3cef50375..ff71a3cbb 100644 --- a/slither/tools/mutator/utils/testing_generated_mutant.py +++ b/slither/tools/mutator/utils/testing_generated_mutant.py @@ -34,13 +34,17 @@ def run_test_cmd(cmd: str, timeout: int | None, target_file: str | None) -> bool elif "hardhat test" in cmd or "truffle test" in cmd and "--bail" not in cmd: cmd += " --bail" + if timeout == 0: + # add --forrce to ensure all contracts are recompiled w/out using cache + cmd += " --force" + try: result = subprocess.run( cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - timeout=timeout, + timeout=timeout if timeout != 0 else None, check=False # True: Raises a CalledProcessError if the return code is non-zero )