diff --git a/eth_vertigo/cli/main.py b/eth_vertigo/cli/main.py index a0f8e8d..cb7b56d 100644 --- a/eth_vertigo/cli/main.py +++ b/eth_vertigo/cli/main.py @@ -190,7 +190,7 @@ def run( click.echo("[-] We couldn't get valid results by running the tests.\n Aborting") return - click.echo("[+] The project is valid") + click.echo(f"[+] The project is valid (took {round(campaign.base_run_time, 2)} seconds)") click.echo("[*] Storing compilation results") campaign.store_compilation_results() click.echo("[*] Running analysis on {} mutants".format(len(campaign.mutations))) diff --git a/eth_vertigo/interfaces/common/tester.py b/eth_vertigo/interfaces/common/tester.py index 8f303b7..46c2d9a 100644 --- a/eth_vertigo/interfaces/common/tester.py +++ b/eth_vertigo/interfaces/common/tester.py @@ -106,11 +106,15 @@ def run_tests( if mutation: apply_mutation(mutation, temp_dir) + + # only force recompilation when validating the project to get a baseline + force_recompile = False if mutation else True + try: if original_bytecode is not None and original_bytecode != {}: if self.compiler.check_bytecodes(temp_dir, original_bytecode): raise EquivalentMutant - test_command = self.build_test_command(network) + test_command = self.build_test_command(network, force_recompile=force_recompile) result = self.run_test_command(test_command, temp_dir, timeout=timeout) finally: rm_temp_directory(temp_dir) @@ -122,21 +126,20 @@ def instrument_configuration(self, directory, keep_test_names): pass @abstractmethod - def build_test_command(self, network: str): + def build_test_command(self, network: str, force_recompile: bool = False): pass @staticmethod def run_test_command( command: str, working_directory: str, - timeout=None + timeout: int = 600 ) -> Union[Dict[str, TestResult], None]: with TemporaryFile() as stdin, TemporaryFile() as stdout: stdin.seek(0) proc = Popen(command, stdin=stdin, stdout=stdout, stderr=stdout, cwd=working_directory) try: - #TODO: timeout defaults to zero for some reason - proc.wait(timeout=1000000) + proc.wait(timeout=timeout) except TimeoutExpired: proc.kill() raise TimedOut diff --git a/eth_vertigo/interfaces/foundry/tester.py b/eth_vertigo/interfaces/foundry/tester.py index e6d20b5..11cd7a1 100644 --- a/eth_vertigo/interfaces/foundry/tester.py +++ b/eth_vertigo/interfaces/foundry/tester.py @@ -38,8 +38,10 @@ def instrument_configuration(self, directory, keep_test_names: Optional[List[str if keep_test_names: _set_include_tests(self.directory, keep_test_names) - def build_test_command(self, network: Optional[str]) -> List[str]: + def build_test_command(self, network: Optional[str], force_recompile: bool = False) -> List[str]: result = self.foundry_command + ['test', '--json'] # if network: # result.extend(['--network', network]) + if force_recompile: + result.append('--force') return result diff --git a/eth_vertigo/interfaces/hardhat/tester.py b/eth_vertigo/interfaces/hardhat/tester.py index 8150805..28ca73e 100644 --- a/eth_vertigo/interfaces/hardhat/tester.py +++ b/eth_vertigo/interfaces/hardhat/tester.py @@ -36,7 +36,8 @@ def instrument_configuration(self, directory, keep_test_names: Optional[List[str if keep_test_names: _set_include_tests(self.directory, keep_test_names) - def build_test_command(self, network: Optional[str]) -> List[str]: + def build_test_command(self, network: Optional[str], force_recompile: bool = False) -> List[str]: + # todo - support `force_recompile` result = self.hardhat_command + ['test'] # if network: # result.extend(['--network', network]) diff --git a/eth_vertigo/interfaces/truffle/tester.py b/eth_vertigo/interfaces/truffle/tester.py index 22254cb..e8ecc76 100644 --- a/eth_vertigo/interfaces/truffle/tester.py +++ b/eth_vertigo/interfaces/truffle/tester.py @@ -39,7 +39,8 @@ def instrument_configuration(self, working_directory, keep_test_names: Optional[ if keep_test_names: _set_include_tests(working_directory, keep_test_names) - def build_test_command(self, network: Optional[str]) -> List[str]: + def build_test_command(self, network: Optional[str], force_recompile: bool = False) -> List[str]: + # todo - support `force_recompile` result = [self.truffle_location, 'test'] if network: result.extend(['--network', network])